These changes are required to build on Ubuntu 26.04 cleanly while still
maintaining backwards compatibility until Ubuntu 22.04.
- Set CMP0167 to NEW in UHD CMake paths that resolve Boost
- Scope policy changes with guard checks so older CMake versions remain
compatible
- Ensure dependency resolution order applies policy before Boost
discovery in package config
- Reduce CMake 3.30+ FindBoost policy warnings without breaking Ubuntu
22.04-era toolchains
With the most recent changes, Boost.Thread and all Boost date/time
libraries are no longer required. This updates the CMake and Debian
files to reflect those changes.
Enable NEW cmake policy CMP0167 that stops using the depreciated FindBoost
module and rely in upstream BoostConfig.cmake configuration files.
This may also avoid conflicts between upstream BoostConfig.cmake configuration
files and the depreciated, legacy implementation in FindBoost.
Fixes issue introduced in UHD 4.9.0.1, that prevents local builds on Windows
against prebuild Boost binary (as described in the user manual).
Change is preserving use of Boost library symbols (i.e. Boost::<module>),
but requires use of a different cmake configuration and Boost 1.73.0 or later.
For details see updates to host/docs/build.dox.in for details.
This has multiple reasons:
- We use CMake's FindBoost
(https://cmake.org/cmake/help/v3.12/module/FindBoost.html) which can
resolve dependencies itself. We only use boost::system in tandem with
Boost::asio, which we already list as a dependency.
- There are combinations of CMake versions and Boost versions, where
specifying this will link against the stub library of Boost::system
(this is a header-only library since Boost 1.69). Removing it from the
list avoids any kind of linkage.
Note that UHDBoost.cmake has some compatibility hacks for Boost::system,
which we now also remove.
Our internal helper UHDBoost.cmake includes several hacks for Boost
version compatibility. Now that we require at least Boost 1.71, these
hacks are just clutter and can be removed.
Building static libraries with UHD was broken due to the way that
UHDBoost was structured. The following changes to UHDBoost.cmake were
applied:
- This file no longer observes ENABLE_STATIC_LIBS. That's because in UHD,
setting ENABLE_STATIC_LIBS is supposed to build both static and shared
libraries, but the way UHDBoost.cmake was written, it would apply
settings for static builds to all libraries. If ENABLE_STATIC_LIBS was
set, then this would cause linker errors.
- As a consequence, users of UHDBoost.cmake must specify
Boost_USE_STATIC_LIBS manually before including it.
- BUILD_SHARED_LIBS is no longer modified. UHD always specifies the
correct library modifier (SHARED, STATIC, etc.) directly in the
add_library() call, and that is good practice. By overriding
BUILD_SHARED_LIBS in UHDBoost.cmake, this file can make changes to
CMake files that call add_library() without a modifier.
In host/lib/CMakeLists.txt, we now call UHDBoost a second time for
static builds but set Boost_USE_STATIC_LIBS beforehand. This allows to
specify linker targets for the static library independently from the
shared library.
We also factored out some common library property manipulations that are
shared between uhd and uhd_static.
This installs UHDPython.cmake to lib/uhd/, so that OOT RFNoC modules can
use it (and don't have to use a version that ships with the OOT). This
makes maintanance of that file a lot easier.
Now that this file can (and should) be used outside of UHD, we
"namespace" the macros and functions by prefacing them with 'UHD_'
(e.g., there's now UHD_PYTHON_CHECK_MODULE).
This file requires creating UHDMinDepVersions.cmake, which also gets
installed.
Previously, applying `-DUHD_BOOST_REQUIRED` to the cmake command line
would do nothing. Now, it is possible to skip Boost checking, e.g., to
only build the manual by calling
cmake -DUHD_BOOST_REQUIRED=OFF -DENABLE_LIBUHD=OFF
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>
Also install UHDBoost.cmake along with the CMake UHD find scripts, so
that it can be used by external modules. Tweak the UHDConfig.cmake
script so that, once installed, the new UHDBoost.cmake script is found.
Note that the project using UHD must first find UHD before trying to find
Boost. Also note that if the C++ standard is not set before UHDBoost is
loaded, it will be set to that currently used by UHD: C++14.