diff options
author | Brad King <brad.king@kitware.com> | 2014-10-31 15:35:07 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-10-31 15:35:07 (GMT) |
commit | 0b8db9ced19bf6ef3fa8a23625b47a7f9bdfdd4e (patch) | |
tree | 78f6e599f593d6fe6e746c5b56e7182253578091 /Tests | |
parent | f2805bd01b011604f95f384ce1759c15503d32cc (diff) | |
parent | 609037f4821c45ed13029074c8669d52c6dc9d71 (diff) | |
download | CMake-0b8db9ced19bf6ef3fa8a23625b47a7f9bdfdd4e.zip CMake-0b8db9ced19bf6ef3fa8a23625b47a7f9bdfdd4e.tar.gz CMake-0b8db9ced19bf6ef3fa8a23625b47a7f9bdfdd4e.tar.bz2 |
Merge topic 'ExternalProject_CMAKE_CACHE_DEFAULT_ARGS'
609037f4 ExternalProject: Add unit tests for CMAKE_CACHE_DEFAULT_ARGS
98cdb658 ExternalProject: Add CMAKE_CACHE_DEFAULT_ARGS arguments
36cf8a1e Tests/Tutorial: Fix when USE_MYMATH is OFF
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/ExternalProjectLocal/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake | 21 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake | 21 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake | 29 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/Tutorial/Step2/tutorial.cxx | 8 | ||||
-rw-r--r-- | Tests/Tutorial/Step3/tutorial.cxx | 8 | ||||
-rw-r--r-- | Tests/Tutorial/Step4/tutorial.cxx | 8 | ||||
-rw-r--r-- | Tests/Tutorial/Step5/tutorial.cxx | 8 | ||||
-rw-r--r-- | Tests/Tutorial/Step6/tutorial.cxx | 8 | ||||
-rw-r--r-- | Tests/Tutorial/Step7/tutorial.cxx | 8 |
13 files changed, 117 insertions, 12 deletions
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index f942197..cbbb555 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -66,6 +66,7 @@ if(can_build_tutorial_step5) 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 LOG_TEST 1 ) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index fd3bb03..a99b46f 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -153,3 +153,4 @@ add_RunCMake_test(CommandLine) add_RunCMake_test(install) add_RunCMake_test(CPackInstallProperties) +add_RunCMake_test(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake new file mode 100644 index 0000000..bf9b12d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -0,0 +1,21 @@ +include(ExternalProject) + +set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") +set(_cache_file "${_tmp_dir}/FOO-cache.cmake") + +ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" + DOWNLOAD_COMMAND "" + CMAKE_CACHE_ARGS "-DFOO:STRING=BAR") + +if(NOT EXISTS "${_cache_file}") + message(FATAL_ERROR "Initial cache not created") +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + message(FATAL_ERROR "Cannot find FOO argument in cache") +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + message(FATAL_ERROR "Expected forced FOO argument") +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake new file mode 100644 index 0000000..c216664 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -0,0 +1,21 @@ +include(ExternalProject) + +set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") +set(_cache_file "${_tmp_dir}/FOO-cache.cmake") + +ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" + DOWNLOAD_COMMAND "" + CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=BAR") + +if(NOT EXISTS "${_cache_file}") + message(FATAL_ERROR "Initial cache not created") +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + message(FATAL_ERROR "Cannot find FOO argument in cache") +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + message(FATAL_ERROR "Expected not forced FOO argument") +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake new file mode 100644 index 0000000..894e183 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake @@ -0,0 +1,29 @@ +include(ExternalProject) + +set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") +set(_cache_file "${_tmp_dir}/FOO-cache.cmake") + +ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" + DOWNLOAD_COMMAND "" + CMAKE_CACHE_ARGS "-DFOO:STRING=BAR" + CMAKE_CACHE_DEFAULT_ARGS "-DBAR:STRING=BAZ") + +if(NOT EXISTS "${_cache_file}") + message(FATAL_ERROR "Initial cache not created") +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + message(FATAL_ERROR "Cannot find FOO argument in cache") +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + message(FATAL_ERROR "Expected forced FOO argument") +endif() + +if(NOT "${_cache}" MATCHES "set\\(BAR \"BAZ\".+\\)") # \(\) + message(FATAL_ERROR "Cannot find BAR argument in cache") +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + message(FATAL_ERROR "Expected not forced BAR argument") +endif() diff --git a/Tests/RunCMake/ExternalProject/CMakeLists.txt b/Tests/RunCMake/ExternalProject/CMakeLists.txt new file mode 100644 index 0000000..c585733 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake new file mode 100644 index 0000000..1614ecc --- /dev/null +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMAKE_CACHE_ARGS) +run_cmake(CMAKE_CACHE_DEFAULT_ARGS) +run_cmake(CMAKE_CACHE_mix) diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step2/tutorial.cxx +++ b/Tests/Tutorial/Step2/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step3/tutorial.cxx +++ b/Tests/Tutorial/Step3/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step4/tutorial.cxx +++ b/Tests/Tutorial/Step4/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step5/tutorial.cxx +++ b/Tests/Tutorial/Step5/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step6/tutorial.cxx +++ b/Tests/Tutorial/Step6/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx index 82b416f..c27da0b 100644 --- a/Tests/Tutorial/Step7/tutorial.cxx +++ b/Tests/Tutorial/Step7/tutorial.cxx @@ -21,12 +21,16 @@ int main (int argc, char *argv[]) } double inputValue = atof(argv[1]); + double outputValue = 0; + if(inputValue >= 0) + { #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + outputValue = sqrt(inputValue); #endif + } fprintf(stdout,"The square root of %g is %g\n", inputValue, outputValue); |