summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-27 15:23:03 +0000
committerKitware Robot <kwrobot@kitware.com>2019-08-27 11:23:22 -0400
commit843ab7544e319597306a6d9cea4ab8be3296e6c4 (patch)
tree62262c4ccae447a0838c50a50db76c8baf9b9c37 /Tests
parent57fc6c587ad766135f9f2b62a870374e9251281c (diff)
parent4ca0526f8a78e7abbd08e9978d4110f836ccef9b (diff)
downloadcmake-843ab7544e319597306a6d9cea4ab8be3296e6c4.tar.gz
Merge topic 'cmake-initial-cache-dirs'
4ca0526f8a cmake: Pass -S and -B into PreLoad.cmake and -C scripts Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3709
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt8
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt2
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir.cmake0
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt6
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake7
7 files changed, 35 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt
new file mode 100644
index 0000000000..0d8f72e487
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt
@@ -0,0 +1,8 @@
+initial-cache.txt: CMAKE_SOURCE_DIR: .*/C_buildsrcdir/src
+initial-cache.txt: CMAKE_BINARY_DIR: .*/C_buildsrcdir-build/DummyBuildDir
+PreLoad.cmake: CMAKE_SOURCE_DIR: .*/C_buildsrcdir/src
+PreLoad.cmake: CMAKE_BINARY_DIR: .*/C_buildsrcdir-build/DummyBuildDir
+CMakeLists.txt: INITIAL_SOURCE_DIR: .*/C_buildsrcdir/src
+CMakeLists.txt: INITIAL_BINARY_DIR: .*/C_buildsrcdir-build/DummyBuildDir
+CMakeLists.txt: PRELOAD_SOURCE_DIR: .*/C_buildsrcdir/src
+CMakeLists.txt: PRELOAD_BINARY_DIR: .*/C_buildsrcdir-build/DummyBuildDir
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt
new file mode 100644
index 0000000000..c69b11ecfe
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt
@@ -0,0 +1,2 @@
+loading initial cache file .*/C_buildsrcdir/initial-cache.txt
+.*
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake b/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt
new file mode 100644
index 0000000000..adc125ba20
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt
@@ -0,0 +1,6 @@
+# Used to verify that the values match what is passed via -S and -B, and are retained in cache.
+set(INITIAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "defined in initial.cmake")
+set(INITIAL_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "defined in initial.cmake")
+
+message("initial-cache.txt: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
+message("initial-cache.txt: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt
new file mode 100644
index 0000000000..4893fe7118
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt
@@ -0,0 +1,6 @@
+project(C_buildsrcdir)
+
+message("CMakeLists.txt: INITIAL_SOURCE_DIR: ${INITIAL_SOURCE_DIR}")
+message("CMakeLists.txt: INITIAL_BINARY_DIR: ${INITIAL_BINARY_DIR}")
+message("CMakeLists.txt: PRELOAD_SOURCE_DIR: ${PRELOAD_SOURCE_DIR}")
+message("CMakeLists.txt: PRELOAD_BINARY_DIR: ${PRELOAD_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake
new file mode 100644
index 0000000000..5199219288
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake
@@ -0,0 +1,6 @@
+# Used to verify that the values match what is passed via -S and -B, and are retained in cache.
+message("PreLoad.cmake: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
+message("PreLoad.cmake: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
+
+set(PRELOAD_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "value of cmake_binary_dir during preload")
+set(PRELOAD_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "value of cmake_source_dir during preload")
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index dd494231ee..71a38437be 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -391,6 +391,13 @@ run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1)
run_cmake_command(P_directory ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR})
run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake)
+# Documented to return the same result as above even if -S and -B are set to something else.
+# Tests the values of CMAKE_BINARY_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR.
+run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake -S something_else -B something_else_1)
+
+# CMAKE_BINARY_DIR should be determined by -B if specified, and CMAKE_SOURCE_DIR determined by -S if specified.
+run_cmake_with_options(C_buildsrcdir -B DummyBuildDir -S ${RunCMake_SOURCE_DIR}/C_buildsrcdir/src -C ${RunCMake_SOURCE_DIR}/C_buildsrcdir/initial-cache.txt)
+
set(RunCMake_TEST_OPTIONS
"-DFOO=-DBAR:BOOL=BAZ")