From fa971526199acfa5a36ae7e85fcd668a1685d582 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 02:19:02 -0500 Subject: [PATCH 1/3] Add UTPP_SKIP_TESTS_AS_BUILD_STEP CMake option Helps address #104. --- CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b5aa7e..03f3063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,12 @@ cmake_minimum_required(VERSION 2.8.1) project(UnitTest++) -option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) +option(UTPP_USE_PLUS_SIGN + "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" + ON) +option(UTPP_SKIP_TESTS_AS_BUILD_STEP + "Set this to ON if you do not wish unit tests to run as part of cmake --build" + OFF) if(MSVC14 OR MSVC12) # has the support we need @@ -55,10 +60,15 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -# run unit tests as post build step -add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") +if(${UTPP_SKIP_TESTS_AS_BUILD_STEP}) + add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_SKIP_TESTS_AS_BUILD_STEP is ON") +else() + # run unit tests as post build step + add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") +endif() # add install targets # need a custom install path? From 14f317c40c98835d10b0b6072e667dc1911c3b93 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 02:29:16 -0500 Subject: [PATCH 2/3] Eliminate double-negative in option name / value UTPP_SKIP_TESTS_AS_BUILD_STEP with a default value of OFF was an unfortunate choice, so this changes it to UTPP_RUN_TESTS_AS_BUILD_STEP with a default value of ON. --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f3063..447f4ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,9 @@ project(UnitTest++) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) -option(UTPP_SKIP_TESTS_AS_BUILD_STEP - "Set this to ON if you do not wish unit tests to run as part of cmake --build" - OFF) +option(UTPP_RUN_TESTS_AS_BUILD_STEP + "Set this to OFF if you do not wish unit tests to run as part of cmake --build" + ON) if(MSVC14 OR MSVC12) # has the support we need @@ -60,14 +60,14 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -if(${UTPP_SKIP_TESTS_AS_BUILD_STEP}) +if(${UTPP_RUN_TESTS_AS_BUILD_STEP}) + # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_SKIP_TESTS_AS_BUILD_STEP is ON") + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") else() - # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") + POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_RUN_TESTS_AS_BUILD_STEP is OFF") endif() # add install targets From 6b69ed78bae727246a6f2e1308feabaf28ded093 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Mon, 18 Jul 2016 21:13:03 -0500 Subject: [PATCH 3/3] 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. --- CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 447f4ce..e99ee13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,8 @@ project(UnitTest++) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) -option(UTPP_RUN_TESTS_AS_BUILD_STEP - "Set this to OFF if you do not wish unit tests to run as part of cmake --build" +option(UTPP_INCLUDE_TESTS_IN_BUILD + "Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build" ON) if(MSVC14 OR MSVC12) @@ -60,14 +60,13 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -if(${UTPP_RUN_TESTS_AS_BUILD_STEP}) - # run unit tests as post build step - add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") -else() - add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_RUN_TESTS_AS_BUILD_STEP is OFF") +# run unit tests as post build step +add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") + +if(NOT ${UTPP_INCLUDE_TESTS_IN_BUILD}) + set_target_properties(TestUnitTest++ PROPERTIES EXCLUDE_FROM_ALL 1) endif() # add install targets