diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2008-10-15 17:56:07 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2008-10-15 17:56:07 (GMT) |
commit | 1777bb502a3c8dbcead54b11fe403e13fe9c225c (patch) | |
tree | e85da2c575bc1e88254287b220e4e236065f3285 /Tests | |
parent | e099dccf4b3772c10c076ec1044dae01da510d28 (diff) | |
download | CMake-1777bb502a3c8dbcead54b11fe403e13fe9c225c.zip CMake-1777bb502a3c8dbcead54b11fe403e13fe9c225c.tar.gz CMake-1777bb502a3c8dbcead54b11fe403e13fe9c225c.tar.bz2 |
BUG: 4244, add a --build option to cmake that can build projects configured by CMake
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeBuildTest.cmake.in | 51 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 6 |
2 files changed, 57 insertions, 0 deletions
diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in new file mode 100644 index 0000000..10abc9e --- /dev/null +++ b/Tests/CMakeBuildTest.cmake.in @@ -0,0 +1,51 @@ +# create the binary directory +make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@") + +# run cmake in the binary directory +execute_process(COMMAND "@CMAKE_CMAKE_COMMAND@" + "@CMAKE_BUILD_TEST_SOURCE_DIR@" + "-G@CMAKE_TEST_GENERATOR@" + WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@" + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake command") +endif(RESULT) + +# Now use the --build option to build the project +execute_process(COMMAND "@CMAKE_CMAKE_COMMAND@" + --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake --build") +endif(RESULT) + +# check for configuration types +set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@) +# run the executable out of the Debug directory if there +# are configuration types +if(CMAKE_CONFIGURATION_TYPES) + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/COnly") +else(CMAKE_CONFIGURATION_TYPES) + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/COnly") +endif(CMAKE_CONFIGURATION_TYPES) +# run the test results +message("running [${RUN_TEST}]") +execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running test COnly") +endif(RESULT) + +# build it again with clean and only COnly target +execute_process(COMMAND "@CMAKE_CMAKE_COMMAND@" + --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug + --clean --target COnly + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake --build") +endif(RESULT) + +# run it again after clean +execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running test COnly after clean ") +endif(RESULT) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 14366b3..336ccf0 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -96,6 +96,12 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") + SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" + "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY) + ADD_TEST(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P + "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake") # If we are running right now with a UnixMakefiles based generator, # build the "Simple" test with the ExtraGenerators, if available |