File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # tests/basic/CMakeLists.txt
2-
31enable_testing ()
42
5- file (GLOB BASIC_TESTS "test_*.cpp" )
6-
7- add_executable (basic_tests ${BASIC_TESTS} )
3+ function (add_basic_suite target_name suite_pattern )
4+ file (GLOB_RECURSE suite_sources CONFIGURE_DEPENDS
5+ "${CMAKE_CURRENT_SOURCE_DIR} /${suite_pattern} "
6+ )
87
9- target_link_libraries (basic_tests PRIVATE GTest::gtest GTest::gmock GTest::gmock_main GTest::gtest_main )
10- target_compile_features (basic_tests PRIVATE cxx_std_23 )
8+ if (NOT suite_sources)
9+ return ()
10+ endif ()
1111
12- target_link_libraries (basic_tests PRIVATE mcpplibs-primitives )
12+ add_executable (${target_name} ${suite_sources} )
13+ target_compile_features (${target_name} PRIVATE cxx_std_23 )
14+ target_link_libraries (${target_name}
15+ PRIVATE
16+ GTest::gtest
17+ GTest::gmock
18+ GTest::gmock_main
19+ GTest::gtest_main
20+ mcpplibs-primitives
21+ )
1322
14- add_test (
15- NAME BASIC_TESTS
16- COMMAND $<TARGET_FILE :basic_tests >
23+ add_test (
24+ NAME ${target_name}
25+ COMMAND $<TARGET_FILE :${target_name} >
1726 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
27+ )
28+ endfunction ()
29+
30+ add_basic_suite (basic_conversion_tests "conversion/**/test_*.cpp" )
31+ add_basic_suite (basic_operations_tests "operations/**/test_*.cpp" )
32+ add_basic_suite (basic_policy_tests "policy/**/test_*.cpp" )
33+ add_basic_suite (basic_primitive_tests "primitive/**/test_*.cpp" )
34+ add_basic_suite (basic_underlying_tests "underlying/**/test_*.cpp" )
35+
36+ add_custom_target (basic_tests )
37+ add_dependencies (basic_tests
38+ basic_conversion_tests
39+ basic_operations_tests
40+ basic_policy_tests
41+ basic_primitive_tests
42+ basic_underlying_tests
1843)
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ add_requires("gtest")
66
77target (" primitives_test" )
88 set_kind (" binary" )
9- add_files (" basic/*.cpp" )
9+ add_files (" basic/main.cpp" )
10+ add_files (" basic/**/test_*.cpp" )
1011 add_deps (" mcpplibs-primitives" )
1112 add_packages (" gtest" )
13+ add_links (" gtest_main" , " gmock_main" )
1214 set_policy (" build.c++.modules" , true )
You can’t perform that action at this time.
0 commit comments