22# Distributed under the Boost Software License, Version 1.0.
33# https://www.boost.org/LICENSE_1_0.txt
44
5- cmake_minimum_required (VERSION 3.5 ...3.16 )
5+ cmake_minimum_required (VERSION 3.8 ...3.16 )
66
77project (boost_test VERSION "${BOOST_SUPERPROJECT_VERSION} " LANGUAGES CXX )
88
@@ -30,60 +30,74 @@ set(_boost_test_dependencies
3030 Boost::utility
3131)
3232
33- # Compiled targets
33+ option ( BOOST_TEST_HEADERS_ONLY "Boost.Test: Only install headers" OFF )
3434
35- function ( boost_test_add_library name )
35+ set (_boost_test_libraries "" )
3636
37- add_library (boost_${name} ${ARGN} )
38- add_library (Boost::${name} ALIAS boost_${name} )
37+ if (NOT BOOST_TEST_HEADERS_ONLY)
3938
40- target_include_directories (boost_${name} PUBLIC include )
41- target_link_libraries (boost_${name} PUBLIC ${_boost_test_dependencies} )
39+ # Compiled targets
4240
43- target_compile_definitions (boost_${name}
44- PUBLIC BOOST_TEST_NO_LIB
45- # Source files already define BOOST_TEST_SOURCE
46- # PRIVATE BOOST_TEST_SOURCE
47- )
41+ function (boost_test_add_library name )
4842
49- if (BUILD_SHARED_LIBS )
50- target_compile_definitions (boost_${name} PUBLIC BOOST_TEST_DYN_LINK )
51- else ()
52- target_compile_definitions (boost_${name} PUBLIC BOOST_TEST_STATIC_LINK )
53- endif ()
43+ add_library (boost_${name} ${ARGN} )
44+ add_library (Boost::${name} ALIAS boost_${name} )
5445
55- endfunction ()
46+ target_include_directories (boost_${name} PUBLIC include )
47+ target_link_libraries (boost_${name} PUBLIC ${_boost_test_dependencies} )
5648
57- boost_test_add_library ( prg_exec_monitor
58- src/cpp_main.cpp
59- src/debug.cpp
60- src/execution_monitor.cpp
61- )
49+ target_compile_definitions ( boost_${name}
50+ PUBLIC BOOST_TEST_NO_LIB
51+ # Source files already define BOOST_TEST_SOURCE
52+ # PRIVATE BOOST_TEST_SOURCE
53+ )
6254
63- set (SOURCES
64- src/compiler_log_formatter.cpp
65- src/debug.cpp
66- src/decorator.cpp
67- src/execution_monitor.cpp
68- src/framework.cpp
69- src/junit_log_formatter.cpp
70- src/plain_report_formatter.cpp
71- src/progress_monitor.cpp
72- src/results_collector.cpp
73- src/results_reporter.cpp
74- src/test_framework_init_observer.cpp
75- src/test_tools.cpp
76- src/test_tree.cpp
77- src/unit_test_log.cpp
78- src/unit_test_main.cpp
79- src/unit_test_monitor.cpp
80- src/unit_test_parameters.cpp
81- src/xml_log_formatter.cpp
82- src/xml_report_formatter.cpp
83- )
55+ if (WIN32 )
56+ target_compile_definitions (boost_${name} PRIVATE _CRT_SECURE_NO_WARNINGS )
57+ endif ()
58+
59+ if (BUILD_SHARED_LIBS )
60+ target_compile_definitions (boost_${name} PUBLIC BOOST_TEST_DYN_LINK )
61+ else ()
62+ target_compile_definitions (boost_${name} PUBLIC BOOST_TEST_STATIC_LINK )
63+ endif ()
64+
65+ endfunction ()
8466
85- boost_test_add_library (test_exec_monitor STATIC ${SOURCES} src/test_main.cpp )
86- boost_test_add_library (unit_test_framework ${SOURCES} )
67+ boost_test_add_library (prg_exec_monitor
68+ src/cpp_main.cpp
69+ src/debug.cpp
70+ src/execution_monitor.cpp
71+ )
72+
73+ set (SOURCES
74+ src/compiler_log_formatter.cpp
75+ src/debug.cpp
76+ src/decorator.cpp
77+ src/execution_monitor.cpp
78+ src/framework.cpp
79+ src/junit_log_formatter.cpp
80+ src/plain_report_formatter.cpp
81+ src/progress_monitor.cpp
82+ src/results_collector.cpp
83+ src/results_reporter.cpp
84+ src/test_framework_init_observer.cpp
85+ src/test_tools.cpp
86+ src/test_tree.cpp
87+ src/unit_test_log.cpp
88+ src/unit_test_main.cpp
89+ src/unit_test_monitor.cpp
90+ src/unit_test_parameters.cpp
91+ src/xml_log_formatter.cpp
92+ src/xml_report_formatter.cpp
93+ )
94+
95+ boost_test_add_library (test_exec_monitor STATIC ${SOURCES} src/test_main.cpp )
96+ boost_test_add_library (unit_test_framework ${SOURCES} )
97+
98+ set (_boost_test_libraries boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework)
99+
100+ endif ()
87101
88102# Header-only targets
89103
@@ -107,7 +121,7 @@ if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13)
107121
108122 boost_install (
109123 TARGETS
110- boost_prg_exec_monitor boost_test_exec_monitor boost_unit_test_framework
124+ ${_boost_test_libraries}
111125 boost_included_prg_exec_monitor boost_included_test_exec_monitor boost_included_unit_test_framework
112126 VERSION ${BOOST_SUPERPROJECT_VERSION}
113127 HEADER_DIRECTORY include
0 commit comments