This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, master has been updated via 843ab7544e319597306a6d9cea4ab8be3296e6c4 (commit) via 4ca0526f8a78e7abbd08e9978d4110f836ccef9b (commit) from 57fc6c587ad766135f9f2b62a870374e9251281c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=843ab7544e319597306a6d9cea4ab8be3296e6c4 commit 843ab7544e319597306a6d9cea4ab8be3296e6c4 Merge: 57fc6c5 4ca0526 Author: Brad King <brad.k...@kitware.com> AuthorDate: Tue Aug 27 15:23:03 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Tue Aug 27 11:23:22 2019 -0400 Merge topic 'cmake-initial-cache-dirs' 4ca0526f8a cmake: Pass -S and -B into PreLoad.cmake and -C scripts Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3709 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ca0526f8a78e7abbd08e9978d4110f836ccef9b commit 4ca0526f8a78e7abbd08e9978d4110f836ccef9b Author: Peter Waller <p...@pwaller.net> AuthorDate: Tue Aug 20 22:32:50 2019 +0100 Commit: Brad King <brad.k...@kitware.com> CommitDate: Tue Aug 27 10:51:40 2019 -0400 cmake: Pass -S and -B into PreLoad.cmake and -C scripts Before this, it was not possible to see what the source or build directories were set to on the command line. Fixes: #19619 diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 810aaa9..0947e41 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -18,6 +18,9 @@ containing :command:`set` commands that use the ``CACHE`` option, not a cache-format file. + References to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` + within the script evaluate to the top-level source and build tree. + ``-D <var>:<type>=<value>, -D <var>=<value>`` Create or update a CMake ``CACHE`` entry. diff --git a/Help/release/dev/cmake-initial-cache-dirs.rst b/Help/release/dev/cmake-initial-cache-dirs.rst new file mode 100644 index 0000000..be91902 --- /dev/null +++ b/Help/release/dev/cmake-initial-cache-dirs.rst @@ -0,0 +1,6 @@ +cmake-initial-cache-dirs +------------------------ + +* The :manual:`cmake(1)` ``-C <initial-cache>`` option now evaluates the + initial cache script with :variable:`CMAKE_SOURCE_DIR` and + :variable:`CMAKE_BINARY_DIR` set to the top-level source and build trees. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4ed17a3..b9902a3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,6 +430,11 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } // Register fake project commands that hint misuse in script mode. GetProjectCommandsInScriptMode(this->GetState()); + // Documented behaviour of CMAKE{,_CURRENT}_{SOURCE,BINARY}_DIR is to be + // set to $PWD for -P mode. + this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); + this->SetHomeOutputDirectory( + cmSystemTools::GetCurrentWorkingDirectory()); this->ReadListFile(args, path); } else if (arg.find("--find-package", 0) == 0) { findPackageMode = true; @@ -459,15 +464,9 @@ void cmake::ReadListFile(const std::vector<std::string>& args, // read in the list file to fill the cache if (!path.empty()) { this->CurrentSnapshot = this->State->Reset(); - std::string homeDir = this->GetHomeDirectory(); - std::string homeOutputDir = this->GetHomeOutputDirectory(); - this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmStateSnapshot snapshot = this->GetCurrentSnapshot(); - snapshot.GetDirectory().SetCurrentBinary( - cmSystemTools::GetCurrentWorkingDirectory()); - snapshot.GetDirectory().SetCurrentSource( - cmSystemTools::GetCurrentWorkingDirectory()); + snapshot.GetDirectory().SetCurrentBinary(this->GetHomeOutputDirectory()); + snapshot.GetDirectory().SetCurrentSource(this->GetHomeDirectory()); snapshot.SetDefaultDefinitions(); cmMakefile mf(gg, snapshot); if (this->GetWorkingMode() != NORMAL_MODE) { @@ -480,8 +479,6 @@ void cmake::ReadListFile(const std::vector<std::string>& args, if (!mf.ReadListFile(path)) { cmSystemTools::Error("Error processing file: " + path); } - this->SetHomeDirectory(homeDir); - this->SetHomeOutputDirectory(homeOutputDir); } // free generic one if generated diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt new file mode 100644 index 0000000..0d8f72e --- /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 0000000..c69b11e --- /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 0000000..e69de29 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 0000000..adc125b --- /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 0000000..4893fe7 --- /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 0000000..5199219 --- /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 dd49423..71a3843 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") ----------------------------------------------------------------------- Summary of changes: Help/manual/OPTIONS_BUILD.txt | 3 +++ Help/release/dev/cmake-initial-cache-dirs.rst | 6 ++++++ Source/cmake.cxx | 17 +++++++---------- Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt | 8 ++++++++ Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt | 2 ++ .../CommandLine/C_buildsrcdir.cmake} | 0 .../CommandLine/C_buildsrcdir/initial-cache.txt | 6 ++++++ .../CommandLine/C_buildsrcdir/src/CMakeLists.txt | 6 ++++++ .../CommandLine/C_buildsrcdir/src/PreLoad.cmake | 6 ++++++ Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 7 +++++++ 10 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 Help/release/dev/cmake-initial-cache-dirs.rst create mode 100644 Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLine/C_buildsrcdir.cmake} (100%) create mode 100644 Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt create mode 100644 Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt create mode 100644 Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits