File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ include(unifex_options)
1515include (unifex_env )
1616include (unifex_flags )
1717
18+ option (UNIFEX_USE_SYSTEM_GTEST "Use system GTest dependency" OFF )
19+
1820# The library target is defined in the source subdirectory
1921add_subdirectory (source )
2022
@@ -32,12 +34,17 @@ if (PROJECT_IS_TOP_LEVEL)
3234 endif (UNIFEX_BUILD_EXAMPLES )
3335 # Tests do use gtest
3436 if (BUILD_TESTING)
35- include (gtest )
36- target_compile_features (gtest PUBLIC cxx_std_17 )
37- target_compile_features (gtest_main PUBLIC cxx_std_17 )
38- if (UNIFEX_CXX_COMPILER_CLANGCL)
39- target_compile_options (gtest PRIVATE -Wno-error )
40- target_compile_options (gtest_main PRIVATE -Wno-error )
37+ if (UNIFEX_USE_SYSTEM_GTEST)
38+ find_package (GTest CONFIG REQUIRED )
39+ # find_package(GMock REQUIRED)
40+ else ()
41+ include (gtest )
42+ target_compile_features (gtest PUBLIC cxx_std_17 )
43+ target_compile_features (gtest_main PUBLIC cxx_std_17 )
44+ if (UNIFEX_CXX_COMPILER_CLANGCL)
45+ target_compile_options (gtest PRIVATE -Wno-error )
46+ target_compile_options (gtest_main PRIVATE -Wno-error )
47+ endif ()
4148 endif ()
4249 add_subdirectory (test )
4350 endif (BUILD_TESTING )
Original file line number Diff line number Diff line change @@ -8,15 +8,15 @@ foreach(file-path ${test-sources})
88 string ( REPLACE ".cpp" "" file-path-without-ext ${file-path} )
99 get_filename_component (file-name ${file-path-without-ext} NAME )
1010 add_executable ( ${file-name} ${file-path} )
11- target_link_libraries (${file-name} PUBLIC unifex gtest_main )
11+ target_link_libraries (${file-name} PUBLIC unifex GTest:: gtest_main )
1212 add_test (NAME "test-${file-name} " COMMAND ${file-name} )
1313endforeach ()
1414
1515if (CXX_MEMORY_RESOURCE_HAVE_PMR)
1616 target_link_libraries (any_unique_test PUBLIC std::memory_resource )
1717endif ()
1818
19- target_link_libraries (any_sender_of_test PUBLIC gmock )
20- target_link_libraries (async_manual_reset_event_test PUBLIC gmock )
21- target_link_libraries (async_scope_test PUBLIC gmock )
22- target_link_libraries (async_scope_v0_test PUBLIC gmock )
19+ target_link_libraries (any_sender_of_test PUBLIC GTest::gmock_main )
20+ target_link_libraries (async_manual_reset_event_test PUBLIC GTest::gmock_main )
21+ target_link_libraries (async_scope_test PUBLIC GTest::gmock_main )
22+ target_link_libraries (async_scope_v0_test PUBLIC GTest::gmock_main )
You can’t perform that action at this time.
0 commit comments