mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
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>
This commit is contained in:
parent
ada6a4e467
commit
9aafc0ace2
@ -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
|
||||
|
||||
14
host/cmake/vcpkg/uhd-x64-windows-static-md.cmake
Normal file
14
host/cmake/vcpkg/uhd-x64-windows-static-md.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
set(VCPKG_TARGET_ARCHITECTURE x64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
# uhd dynamic links for boost-test and libusb.
|
||||
# The other boost dependencies are static.
|
||||
# This maintains historical compatibility
|
||||
# with previous binaries.
|
||||
if (PORT STREQUAL boost-test)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
endif()
|
||||
|
||||
if (PORT STREQUAL libusb)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
endif()
|
||||
14
host/cmake/vcpkg/uhd-x86-windows-static-md.cmake
Normal file
14
host/cmake/vcpkg/uhd-x86-windows-static-md.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
set(VCPKG_TARGET_ARCHITECTURE x86)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
# uhd dynamic links for boost-test and libusb.
|
||||
# The other boost dependencies are static.
|
||||
# This maintains historical compatibility
|
||||
# with previous binaries.
|
||||
if (PORT STREQUAL boost-test)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
endif()
|
||||
|
||||
if (PORT STREQUAL libusb)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
endif()
|
||||
@ -12,8 +12,11 @@
|
||||
#include <iso646.h>
|
||||
|
||||
// Define ssize_t
|
||||
#include <stddef.h>
|
||||
typedef ptrdiff_t ssize_t;
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
# include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif /* _SSIZE_T_DEFINED */
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
@ -38,8 +38,11 @@
|
||||
# include <ciso646>
|
||||
|
||||
// define ssize_t
|
||||
# include <cstddef>
|
||||
typedef ptrdiff_t ssize_t;
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
# include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif /* _SSIZE_T_DEFINED */
|
||||
|
||||
#endif // BOOST_MSVC
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@ set(util_share_sources_py
|
||||
uhd_power_cal.py
|
||||
)
|
||||
if(ENABLE_USB)
|
||||
find_package(LIBUSB)
|
||||
list(APPEND util_share_sources
|
||||
fx2_init_eeprom.cpp
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user