cmake: Enable Ubuntu 26.04

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
This commit is contained in:
Martin Anderseck 2026-07-31 13:42:57 +02:00 committed by Martin Anderseck
parent 26c0033d1e
commit 1af4625e84
6 changed files with 23 additions and 7 deletions

View File

@ -143,10 +143,10 @@ if(POLICY CMP0093)
cmake_policy(SET CMP0093 NEW)
endif()
# if no CXX STANDARD is set, default to that required by UHD: c++14
# if no CXX STANDARD is set, default to that required by UHD: c++20
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
message(WARNING "\nC++ standard not yet set; setting to C++14.\n")
set(CMAKE_CXX_STANDARD 20)
message(WARNING "\nC++ standard not yet set; setting to C++20.\n")
endif()
if(${UHD_BOOST_OPTIONAL_COMPONENTS_LEN} GREATER 0)

View File

@ -23,6 +23,10 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}")
include("${CMAKE_CURRENT_LIST_DIR}/UHDMinDepVersions.cmake")
if(POLICY CMP0167)
cmake_policy(PUSH)
cmake_policy(SET CMP0167 NEW)
endif()
include(CMakeFindDependencyMacro)
find_dependency(Boost ${UHD_BOOST_MIN_VERSION}
COMPONENTS
@ -34,6 +38,9 @@ find_dependency(Boost ${UHD_BOOST_MIN_VERSION}
thread
unit_test_framework
)
if(POLICY CMP0167)
cmake_policy(POP)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/UHDTargets.cmake")

View File

@ -34,7 +34,6 @@ find_package(UHD 4.3.0 REQUIRED)
# Set components here, then include UHDBoost to do the actual finding
set(UHD_BOOST_REQUIRED_COMPONENTS
program_options
system
thread
)
set(UHD_BOOST_MIN_VERSION 1.71)

View File

@ -106,9 +106,18 @@ if(NOT DEFINED Boost_USE_STATIC_LIBS OR Boost_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS OFF)
endif()
# Duplicate find_package(Boost) arguments used in UHDBoost.cmake
if(POLICY CMP0167)
cmake_policy(PUSH)
cmake_policy(SET CMP0167 NEW)
endif()
find_package(Boost ${UHD_BOOST_MIN_VERSION} QUIET
COMPONENTS unit_test_framework ${UHD_BOOST_REQUIRED})
if(POLICY CMP0167)
cmake_policy(POP)
endif()
if(Boost_VERBOSE OR Boost_DEBUG)
# After: find_package(Boost REQUIRED COMPONENTS unit_test_framework)
# The actual library file(s) per-config

View File

@ -16,8 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.12)
project(kitchen_sink CXX)
set(CMAKE_CXX_STANDARD 20)
###############################################################################

View File

@ -16,9 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.12)
project(NIRIO_PROGRAMMER CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
### Set up build environment ##################################################
# Choose a static or shared-library build (shared is default, and static will