Skip to content

Commit fa97152

Browse files
committed
Add UTPP_SKIP_TESTS_AS_BUILD_STEP CMake option
Helps address #104.
1 parent 510903c commit fa97152

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
cmake_minimum_required(VERSION 2.8.1)
22
project(UnitTest++)
33

4-
option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON)
4+
option(UTPP_USE_PLUS_SIGN
5+
"Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths"
6+
ON)
7+
option(UTPP_SKIP_TESTS_AS_BUILD_STEP
8+
"Set this to ON if you do not wish unit tests to run as part of cmake --build"
9+
OFF)
510

611
if(MSVC14 OR MSVC12)
712
# has the support we need
@@ -55,10 +60,15 @@ endif()
5560

5661
target_link_libraries(TestUnitTest++ UnitTest++)
5762

58-
# run unit tests as post build step
59-
add_custom_command(TARGET TestUnitTest++
60-
POST_BUILD COMMAND TestUnitTest++
61-
COMMENT "Running unit tests")
63+
if(${UTPP_SKIP_TESTS_AS_BUILD_STEP})
64+
add_custom_command(TARGET TestUnitTest++
65+
POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_SKIP_TESTS_AS_BUILD_STEP is ON")
66+
else()
67+
# run unit tests as post build step
68+
add_custom_command(TARGET TestUnitTest++
69+
POST_BUILD COMMAND TestUnitTest++
70+
COMMENT "Running unit tests")
71+
endif()
6272

6373
# add install targets
6474
# need a custom install path?

0 commit comments

Comments
 (0)