10000 Skip test build with same option as run · unittest-cpp/unittest-cpp@6b69ed7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b69ed7

Browse files
committed
Skip test build with same option as run
As part of this, changed the option name to `UTPP_INCLUDE_TESTS_IN_BUILD`. The test target is still added to the build and can be built/run separately using the CMake --target option.
1 parent 14f317c commit 6b69ed7

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ project(UnitTest++)
44
option(UTPP_USE_PLUS_SIGN
55
"Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths"
66
ON)
7-
option(UTPP_RUN_TESTS_AS_BUILD_STEP
8-
"Set this to OFF if you do not wish unit tests to run as part of cmake --build"
7+
option(UTPP_INCLUDE_TESTS_IN_BUILD
8+
"Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build"
99
ON)
1010

1111
if(MSVC14 OR MSVC12)
@@ -60,14 +60,13 @@ endif()
6060

6161
target_link_libraries(TestUnitTest++ UnitTest++)
6262

63-
if(${UTPP_RUN_TESTS_AS_BUILD_STEP})
64-
# run unit tests as post build step
65-
add_custom_command(TARGET TestUnitTest++
66-
POST_BUILD COMMAND TestUnitTest++
67-
COMMENT "Running unit tests")
68-
else()
69-
add_custom_command(TARGET TestUnitTest++
70-
POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_RUN_TESTS_AS_BUILD_STEP is OFF")
63+
# run unit tests as post build step
64+
add_custom_command(TARGET TestUnitTest++
65+
POST_BUILD COMMAND TestUnitTest++
66+
COMMENT "Running unit tests")
67+
68+
if(NOT ${UTPP_INCLUDE_TESTS_IN_BUILD})
69+
set_target_properties(TestUnitTest++ PROPERTIES EXCLUDE_FROM_ALL 1)
7170
endif()
7271

7372
# add install targets

0 commit comments

Comments
 (0)
0