File tree 3 files changed +38
-4
lines changed 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,13 @@ include(GNUInstallDirs) # This will define the default values fo
27
27
include (InstallRequiredSystemLibraries) # Tell CMake that the `install` target needs to install required system libraries (eg: Windows SDK)
28
28
include (CMakePackageConfigHelpers) # Helper to create relocatable packages
29
29
30
+
30
31
# Custom modules and scripts
31
32
32
33
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" ) # Make our cmake scripts available
33
34
35
+ include (BuildHelpers) # Helpers for writing cmake files
36
+
34
37
###############
35
38
## Options ##
36
39
###############
Original file line number Diff line number Diff line change
1
+ include (CMakeParseArguments)
2
+
3
+ function (make_cc_test)
4
+ if (NOT ENABLE_TESTING)
5
+ return ()
6
+ endif ()
7
+
8
+ cmake_parse_arguments (MAKE_CC_TEST
9
+ ""
10
+ "NAME"
11
+ "SRCS;DEPS;DATA"
12
+ ${ARGN} )
13
+
14
+ set (_NAME "${MAKE_CC_TEST_NAME} " )
15
+
16
+ add_executable (${_NAME} )
17
+ target_sources (${_NAME} PRIVATE ${MAKE_CC_TEST_SRCS} )
18
+ target_link_libraries (${_NAME}
19
+ PRIVATE ${MAKE_CC_TEST_DEPS} gtest gmock gtest_main)
20
+ gtest_discover_tests(${_NAME} )
21
+
22
+
23
+ file (RELATIVE_PATH _DEST_DIR ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
24
+ install (TARGETS ${_NAME} DESTINATION tests/${_DEST_DIR} )
25
+ foreach (_DATA_FILE ${MAKE_CC_TEST_DATA} )
26
+ get_filename_component (SUBPATH ${_DATA_FILE} DIRECTORY )
27
+ install (FILES ${_DATA_FILE} DESTINATION tests/${_DEST_DIR} /${SUBPATH} )
28
+ configure_file (${_DATA_FILE} ${_DATA_FILE} COPYONLY )
29
+ endforeach ()
30
+
31
+ endfunction ()
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ target_sources(simple
10
10
PRIVATE simple.cc)
11
11
12
12
if (ENABLE_TESTING)
13
- add_executable (simple_test)
14
- target_sources (simple_test PRIVATE simple_test.cc)
15
- target_link_libraries (simple_test PRIVATE simple gtest gmock gtest_main)
16
- gtest_discover_tests(simple_test )
13
+ MAKE_CC_TEST(
14
+ NAME simple_test
15
+ SRCS simple_test.cc
16
+ DEPS simple )
17
17
endif ()
You can’t perform that action at this time.
0 commit comments