summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ExternalProject
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/ExternalProject')
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake21
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake21
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake29
-rw-r--r--Tests/RunCMake/ExternalProject/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake5
5 files changed, 79 insertions, 0 deletions
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)