summaryrefslogtreecommitdiff
path: root/Tests/CMakeOnly
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-01-11 17:04:04 -0500
committerBrad King <brad.king@kitware.com>2012-01-13 14:21:22 -0500
commit9a20abf04a7fc11b53beb545f1555fe9815ae09c (patch)
tree220bea799bb7e628c43e687ab448aa2d22b0f2ab /Tests/CMakeOnly
parentbbed901178852e1fb1a77e4e6fbfe397fb67a20c (diff)
downloadcmake-9a20abf04a7fc11b53beb545f1555fe9815ae09c.tar.gz
Add infrastructure for CMake-only tests
Some tests only need to run CMake to configure and generate a build tree, but not actually perform the build. Add a new "Tests/CMakeOnly" directory dedicated for this purpose. Add a helper script to drive each test by creating a fresh build tree and running CMake on it. Add macro "add_CMakeOnly_test" to help create tests using the script.
Diffstat (limited to 'Tests/CMakeOnly')
-rw-r--r--Tests/CMakeOnly/CMakeLists.txt9
-rw-r--r--Tests/CMakeOnly/Test.cmake.in12
2 files changed, 21 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt
new file mode 100644
index 0000000000..d32e7be244
--- /dev/null
+++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -0,0 +1,9 @@
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Test.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake @ONLY)
+
+macro(add_CMakeOnly_test test)
+ add_test(CMakeOnly.${test} ${CMAKE_CMAKE_COMMAND}
+ -DTEST=${test}
+ -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
+ )
+endmacro()
diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in
new file mode 100644
index 0000000000..aa2d09374f
--- /dev/null
+++ b/Tests/CMakeOnly/Test.cmake.in
@@ -0,0 +1,12 @@
+set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST}")
+set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build")
+file(REMOVE_RECURSE "${binary_dir}")
+file(MAKE_DIRECTORY "${binary_dir}")
+execute_process(
+ COMMAND ${CMAKE_COMMAND} "${source_dir}" -G "@CMAKE_TEST_GENERATOR@"
+ WORKING_DIRECTORY "${binary_dir}"
+ RESULT_VARIABLE result
+ )
+if(result)
+ message(FATAL_ERROR "CMake failed to configure ${TEST}")
+endif()