Skip to content

Commit

Permalink
Add vcpkg CONTROL file and portfile to build nmos-cpp with vcpkg.
Browse files Browse the repository at this point in the history
  • Loading branch information
aholzinger committed Mar 8, 2020
1 parent 35d14cc commit 7957bf1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vcpkg/ports/nmos-cpp/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Source: nmos-cpp
Version: 1.0.0
Homepage: https://github.com/aholzinger/nmos-cpp
Description: nmos-cpp is an implementation of the AMWA Networked Media Open Specifications in C++, licensed under the terms of the Apache License 2.0.
Build-Depends: boost, cpprestsdk, openssl
77 changes: 77 additions & 0 deletions vcpkg/ports/nmos-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO aholzinger/nmos-cpp
REF 35d14cce1eef2107345419ae690df97d8e17e17e
SHA512 9be9f836231333cdbdfa3efdd871331f3b0de116862977528153a0e24896b30a163ce7e732c0fc3201507b2c772fb3ad729bce1f121d30dbb4f68a006f9cd0da
HEAD_REF master
)

set (NMOS_CPP_OPTIONS_DEBUG)
set (NMOS_CPP_OPTIONS_RELEASE)
set (NMOS_CPP_LINKAGE_SUFFIX)

if (${VCPKG_LIBRARY_LINKAGE} STREQUAL "static")
set(NMOS_CPP_LINKAGE_SUFFIX "-${VCPKG_LIBRARY_LINKAGE}")
endif()

set(NMOS_CPP_BOOST_SYSTEM_USE_UTF8_OPTION "-DNMOS_CPP_BOOST_SYSTEM_USE_UTF8=1")
set(NMOS_CPP_INCLUDE_DIR_PREFIX_OPTION "-DNMOS_CPP_INCLUDE_DIR_PREFIX=nmos-cpp")

if (DEFINED VCPKG_TARGET_IS_WINDOWS AND ${VCPKG_TARGET_IS_WINDOWS} STREQUAL "1")
set(WEBSOCKETPP_INCLUDE_DIR "${VCPKG_ROOT_PATH}/packages/websocketpp_${VCPKG_TARGET_ARCHITECTURE}-windows${NMOS_CPP_LINKAGE_SUFFIX}/include/websocketpp")
if (${VCPKG_LIBRARY_LINKAGE} STREQUAL "static")
set (NMOS_CPP_OPTIONS_DEBUG "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug")
set (NMOS_CPP_OPTIONS_RELEASE "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded")
else()
# not yet tested
if (${VCPKG_LIBRARY_LINKAGE} STREQUAL "dynamic")
set (NMOS_CPP_OPTIONS_DEBUG "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL")
set (NMOS_CPP_OPTIONS_RELEASE "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL")
endif()
endif()
else()
# not yet tested
# perhaps this isn't necessary
if (DEFINED VCPKG_TARGET_IS_LINUX AND ${VCPKG_TARGET_IS_LINUX} STREQUAL "1")
set(WEBSOCKETPP_INCLUDE_DIR "${VCPKG_ROOT_PATH}/packages/websocketpp_${VCPKG_TARGET_ARCHITECTURE}-linux${NMOS_CPP_LINKAGE_SUFFIX}/include/websocketpp")
endif()
endif()

if (DEFINED WEBSOCKETPP_INCLUDE_DIR)
set(NMOS_CPP_WEBSOCKETPP_INCLUDE_DIR_OPTION "-DWEBSOCKETPP_INCLUDE_DIR=${WEBSOCKETPP_INCLUDE_DIR}")
endif()

set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)

set(OPTIONS)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
${NMOS_CPP_BOOST_SYSTEM_USE_UTF8_OPTION}
${NMOS_CPP_INCLUDE_DIR_PREFIX_OPTION}
${NMOS_CPP_WEBSOCKETPP_INCLUDE_DIR_OPTION}
OPTIONS_DEBUG
${NMOS_CPP_OPTIONS_DEBUG}
OPTIONS_RELEASE
${NMOS_CPP_OPTIONS_RELEASE}
)

vcpkg_install_cmake()

message(STATUS "CURRENT_PACKAGES_DIR = ${CURRENT_PACKAGES_DIR}")

# vcpkg_fixup_cmake_targets(CONFIG_PATH share/nmos-cpp)
# vcpkg_fixup_cmake_targets()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/share)

file(INSTALL
${SOURCE_PATH}/LICENSE
DESTINATION ${CURRENT_PACKAGES_DIR}/share/nmos-cpp RENAME copyright)

vcpkg_copy_pdbs()

0 comments on commit 7957bf1

Please sign in to comment.