aboutsummaryrefslogtreecommitdiffstats
path: root/host/cmake/Modules/UHDBoost.cmake
diff options
context:
space:
mode:
authorSteven Koo <steven.koo@ni.com>2021-03-10 12:21:33 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2021-03-19 15:40:09 -0500
commit9aafc0ace2272746d708dcac6e5daaa50b7da4c7 (patch)
treee26c85e334ca523312719bdae382dda8c18a90c7 /host/cmake/Modules/UHDBoost.cmake
parentada6a4e46770d22d528b2b6fbc2bdd71e5e3064d (diff)
downloaduhd-9aafc0ace2272746d708dcac6e5daaa50b7da4c7.tar.gz
uhd-9aafc0ace2272746d708dcac6e5daaa50b7da4c7.tar.bz2
uhd-9aafc0ace2272746d708dcac6e5daaa50b7da4c7.zip
uhd: enable vcpkg support on windows
vcpkg can be used for the Windows C++ dependencies for uhd with this commit. To use vcpkg on Windows: 1) Copy the custom triplets in host/cmake/vcpkg/ to the vcpkg/triplets/ folder. 2) Install boost and libusb for the custom triplet "vcpkg install libusb:uhd-x64-windows-static-md boost:uhd-x64-windows-static-md" 3) Call CMake with vcpkg toolchain file flags: -DVCPKG_TARGET_TRIPLET=uhd-x64-windows-static-md -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALL_DIR%/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 16 2019" -A x64 Replace the -G with the installed version of Visual Studio and matching architecture. Then build normally by running vcvarsall.bat and msbuild. Signed-off-by: Steven Koo <steven.koo@ni.com>
Diffstat (limited to 'host/cmake/Modules/UHDBoost.cmake')
-rw-r--r--host/cmake/Modules/UHDBoost.cmake26
1 files changed, 20 insertions, 6 deletions
diff --git a/host/cmake/Modules/UHDBoost.cmake b/host/cmake/Modules/UHDBoost.cmake
index 5ebb4acef..eed94cbfe 100644
--- a/host/cmake/Modules/UHDBoost.cmake
+++ b/host/cmake/Modules/UHDBoost.cmake
@@ -118,12 +118,26 @@ endif(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64")
# special Microsoft Visual C handling
if(MSVC)
- set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
- if(BOOST_ALL_DYN_LINK)
- add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
- else(BOOST_ALL_DYN_LINK)
- set(UHD_BOOST_REQUIRED_COMPONENTS) #empty components list for static link
- endif(BOOST_ALL_DYN_LINK)
+ if(VCPKG_TARGET_TRIPLET)
+ message(STATUS " VCPKG Libs")
+ string(FIND ${VCPKG_TARGET_TRIPLET} "static" vcpkg_check_static)
+ string(FIND ${VCPKG_TARGET_TRIPLET} "static-md" vcpkg_check_static_md)
+ if((NOT vcpkg_check_static EQUAL -1) AND vcpkg_check_static_md EQUAL -1)
+ # Statically linked CRT
+ message(STATUS " VCPKG static CRT triplet found. Configuring compiler flags.")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+ endif((NOT vcpkg_check_static EQUAL -1) AND vcpkg_check_static_md EQUAL -1)
+ else(VCPKG_TARGET_TRIPLET)
+ set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
+ if(BOOST_ALL_DYN_LINK)
+ message(STATUS " Dynamic Libs")
+ add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
+ else(BOOST_ALL_DYN_LINK)
+ message(STATUS " Static Libs")
+ set(UHD_BOOST_REQUIRED_COMPONENTS) #empty components list for static link
+ endif(BOOST_ALL_DYN_LINK)
+ endif(VCPKG_TARGET_TRIPLET)
endif(MSVC)
# Starting in CMake 3.15.0, if policy 'CMP0093' is available and set