summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniele E. Domenichelli <daniele.domenichelli@iit.it>2014-11-30 21:28:43 (GMT)
committerDaniele E. Domenichelli <daniele.domenichelli@iit.it>2014-12-05 09:24:16 (GMT)
commit636f0c1d4fa3f003fff406b27306cd6883bcec75 (patch)
tree7fddedb619d2984ef5624c094e2494c2984a8ff8
parentc90633df9eacb3063669ac0aad9506cea1885582 (diff)
downloadCMake-636f0c1d4fa3f003fff406b27306cd6883bcec75.zip
CMake-636f0c1d4fa3f003fff406b27306cd6883bcec75.tar.gz
CMake-636f0c1d4fa3f003fff406b27306cd6883bcec75.tar.bz2
ExternalProject: Add TEST_EXCLUDE_FROM_MAIN option
If this option is enabled, the test step is created with the EXCLUDE_FROM_MAIN option, and if TEST_BEFORE_INSTALL is enabled, the install step does not depend on the test step. This means that the test step is never executed, unless the test target is explicitly created by calling ExternalProject_Add_StepTarget, or by passing it with the STEP_TARGETS option, or with the EP_STEP_TARGETS directory property.
-rw-r--r--Help/release/dev/ExternalProject_TEST_EXCLUDE_FROM_MAIN.rst6
-rw-r--r--Modules/ExternalProject.cmake25
-rw-r--r--Tests/ExternalProjectLocal/CMakeLists.txt25
3 files changed, 52 insertions, 4 deletions
diff --git a/Help/release/dev/ExternalProject_TEST_EXCLUDE_FROM_MAIN.rst b/Help/release/dev/ExternalProject_TEST_EXCLUDE_FROM_MAIN.rst
new file mode 100644
index 0000000..dfbf108
--- /dev/null
+++ b/Help/release/dev/ExternalProject_TEST_EXCLUDE_FROM_MAIN.rst
@@ -0,0 +1,6 @@
+ExternalProject_TEST_EXCLUDE_FROM_MAIN
+--------------------------------------
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add`
+ command learned a ``TEST_EXCLUDE_FROM_MAIN`` option to exclude tests
+ from the main build.
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index e5616b1..7e4cc37 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -149,6 +149,8 @@ Create custom targets to build projects in external trees
Add test step executed before install step
``TEST_AFTER_INSTALL 1``
Add test step executed after install step
+ ``TEST_EXCLUDE_FROM_MAIN 1``
+ Main target does not depend on the test step
``TEST_COMMAND <cmd>...``
Command to drive test
@@ -2193,12 +2195,13 @@ function(_ep_add_test_command name)
get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
get_property(after TARGET ${name} PROPERTY _EP_TEST_AFTER_INSTALL)
+ get_property(exclude TARGET ${name} PROPERTY _EP_TEST_EXCLUDE_FROM_MAIN)
get_property(cmd_set TARGET ${name} PROPERTY _EP_TEST_COMMAND SET)
# Only actually add the test step if one of the test related properties is
# explicitly set. (i.e. the test step is omitted unless requested...)
#
- if(cmd_set OR before OR after)
+ if(cmd_set OR before OR after OR exclude)
if(cmd_set)
get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND)
else()
@@ -2206,9 +2209,21 @@ function(_ep_add_test_command name)
endif()
if(before)
- set(dep_args DEPENDEES build DEPENDERS install)
+ set(dependees_args DEPENDEES build)
else()
- set(dep_args DEPENDEES install)
+ set(dependees_args DEPENDEES install)
+ endif()
+
+ if(exclude)
+ set(dependers_args "")
+ set(exclude_args EXCLUDE_FROM_MAIN 1)
+ else()
+ if(before)
+ set(dependers_args DEPENDERS install)
+ else()
+ set(dependers_args "")
+ endif()
+ set(exclude_args "")
endif()
get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST)
@@ -2221,7 +2236,9 @@ function(_ep_add_test_command name)
ExternalProject_Add_Step(${name} test
COMMAND ${cmd}
WORKING_DIRECTORY ${binary_dir}
- ${dep_args}
+ ${dependees_args}
+ ${dependers_args}
+ ${exclude_args}
${log}
)
endif()
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt
index cbbb555..9476ab4 100644
--- a/Tests/ExternalProjectLocal/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/CMakeLists.txt
@@ -71,6 +71,31 @@ if(can_build_tutorial_step5)
LOG_TEST 1
)
set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+
+ set(proj TutorialStep5-Local-TestExcludeFromMainBefore)
+ ExternalProject_Add(${proj}
+ URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+ CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
+ TEST_BEFORE_INSTALL 1
+ TEST_EXCLUDE_FROM_MAIN 1
+ STEP_TARGETS test
+ LOG_TEST 1
+ )
+ set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+
+ set(proj TutorialStep5-Local-TestExcludeFromMainAfter)
+ ExternalProject_Add(${proj}
+ URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+ CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
+ TEST_AFTER_INSTALL 1
+ TEST_EXCLUDE_FROM_MAIN 1
+ STEP_TARGETS test
+ LOG_TEST 1
+ )
+ set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+
endif()