From ce2cd414f080b79d227dc3594ec0c7e6d8b2ca50 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 16 Apr 2025 19:28:37 +0100 Subject: [PATCH 1/2] cmake: Add `BOOST_TEST_HEADERS_ONLY` configuration variable This change allows the build to be configured to install only the Boost.Test headers required for using the headers-only variant of the Unit Test Framework. The `README.md` file at https://github.com/boostorg/cmake should also be updated to mention this new Boost.Test-specific configuration variable. Co-authored-by: Cory Fields --- CMakeLists.txt | 108 +++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7af42838..85c5ca0410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,64 +30,74 @@ set(_boost_test_dependencies Boost::utility ) -# Compiled targets +option(BOOST_TEST_HEADERS_ONLY "Boost.Test: Only install headers" OFF) -function(boost_test_add_library name) +set(_boost_test_libraries "") - add_library(boost_${name} ${ARGN}) - add_library(Boost::${name} ALIAS boost_${name}) +if (NOT BOOST_TEST_HEADERS_ONLY) - target_include_directories(boost_${name} PUBLIC include) - target_link_libraries(boost_${name} PUBLIC ${_boost_test_dependencies}) + # Compiled targets - target_compile_definitions(boost_${name} - PUBLIC BOOST_TEST_NO_LIB - # Source files already define BOOST_TEST_SOURCE - # PRIVATE BOOST_TEST_SOURCE - ) + function(boost_test_add_library name) - if(WIN32) - target_compile_definitions(boost_${name} PRIVATE _CRT_SECURE_NO_WARNINGS) - endif() + add_library(boost_${name} ${ARGN}) + add_library(Boost::${name} ALIAS boost_${name}) - if(BUILD_SHARED_LIBS) - target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_DYN_LINK) - else() - target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_STATIC_LINK) - endif() + target_include_directories(boost_${name} PUBLIC include) + target_link_libraries(boost_${name} PUBLIC ${_boost_test_dependencies}) -endfunction() + target_compile_definitions(boost_${name} + PUBLIC BOOST_TEST_NO_LIB + # Source files already define BOOST_TEST_SOURCE + # PRIVATE BOOST_TEST_SOURCE + ) -boost_test_add_library(prg_exec_monitor - src/cpp_main.cpp - src/debug.cpp - src/execution_monitor.cpp -) + if(WIN32) + target_compile_definitions(boost_${name} PRIVATE _CRT_SECURE_NO_WARNINGS) + endif() -set(SOURCES - src/compiler_log_formatter.cpp - src/debug.cpp - src/decorator.cpp - src/execution_monitor.cpp - src/framework.cpp - src/junit_log_formatter.cpp - src/plain_report_formatter.cpp - src/progress_monitor.cpp - src/results_collector.cpp - src/results_reporter.cpp - src/test_framework_init_observer.cpp - src/test_tools.cpp - src/test_tree.cpp - src/unit_test_log.cpp - src/unit_test_main.cpp - src/unit_test_monitor.cpp - src/unit_test_parameters.cpp - src/xml_log_formatter.cpp - src/xml_report_formatter.cpp -) + if(BUILD_SHARED_LIBS) + target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_DYN_LINK) + else() + target_compile_definitions(boost_${name} PUBLIC BOOST_TEST_STATIC_LINK) + endif() + + endfunction() -boost_test_add_library(test_exec_monitor STATIC ${SOURCES} src/test_main.cpp) -boost_test_add_library(unit_test_framework ${SOURCES}) + boost_test_add_library(prg_exec_monitor + src/cpp_main.cpp + src/debug.cpp + src/execution_monitor.cpp + ) + + set(SOURCES + src/compiler_log_formatter.cpp + src/debug.cpp + src/decorator.cpp + src/execution_monitor.cpp + src/framework.cpp + src/junit_log_formatter.cpp + src/plain_report_formatter.cpp + src/progress_monitor.cpp + src/results_collector.cpp + src/results_reporter.cpp + src/test_framework_init_observer.cpp + src/test_tools.cpp + src/test_tree.cpp + src/unit_test_log.cpp + src/unit_test_main.cpp + src/unit_test_monitor.cpp + src/unit_test_parameters.cpp + src/xml_log_formatter.cpp + src/xml_report_formatter.cpp + ) + + boost_test_add_library(test_exec_monitor STATIC ${SOURCES} src/test_main.cpp) + boost_test_add_library(unit_test_framework ${SOURCES}) + + set(_boost_test_libraries boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework) + +endif() # Header-only targets @@ -111,7 +121,7 @@ if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13) boost_install( TARGETS - boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework + ${_boost_test_libraries} boost_included_prg_exec_monitor boost_included_test_exec_monitor boost_included_unit_test_framework VERSION ${BOOST_SUPERPROJECT_VERSION} HEADER_DIRECTORY include From 5557b0c7e135b491cc3f4fe74eb7d0b567f36b77 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 16 Apr 2025 19:12:18 -0400 Subject: [PATCH 2/2] Move ubuntu 20.04 runs into containers (#446) * Move ubuntu 20.04 runs into containers * Fix syntax error --- .github/workflows/ci.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 056a62cda6..883c095381 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,19 +76,22 @@ jobs: - toolset: gcc-9 cxxstd: "17,2a" address_model: 64 - os: ubuntu-20.04 + os: ubuntu-latest + container: ubuntu:20.04 install: - g++-9-multilib - toolset: gcc-9 cxxstd: "17-gnu,2a-gnu" address_model: 64 - os: ubuntu-20.04 + os: ubuntu-latest + container: ubuntu:20.04 install: - g++-9-multilib - toolset: gcc-10 cxxstd: "17,20" address_model: 64 - os: ubuntu-20.04 + os: ubuntu-latest + container: ubuntu:20.04 install: - g++-10-multilib - toolset: gcc-11 @@ -174,13 +177,15 @@ jobs: - toolset: clang compiler: clang++-9 cxxstd: "17,2a" - os: ubuntu-20.04 + os: ubuntu-latest + container: ubuntu:20.04 install: - clang-9 - toolset: clang compiler: clang++-10 cxxstd: "17,20" - os: ubuntu-20.04 + os: ubuntu-latest + container: ubuntu:20.04 install: - clang-10 - toolset: clang @@ -531,8 +536,8 @@ jobs: fail-fast: false matrix: include: - - { os: ubuntu-20.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' } - - { os: ubuntu-20.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' } + - { os: ubuntu-22.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' } + - { os: ubuntu-22.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' } - { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' } - { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }