diff options
author | Brad King <brad.king@kitware.com> | 2024-08-29 12:26:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-08-29 12:26:40 (GMT) |
commit | 90db124cdf658c8565c8329ff968cccb17d3f39e (patch) | |
tree | 2277e232b12abc7a3feb21addc2338351e781fb1 | |
parent | a0317334ae0fe69443d4bffa1ac8ccd81c2fe8d5 (diff) | |
parent | c1ece78d113d39cdfb3c875d726e296c15abe4a8 (diff) | |
download | CMake-90db124cdf658c8565c8329ff968cccb17d3f39e.zip CMake-90db124cdf658c8565c8329ff968cccb17d3f39e.tar.gz CMake-90db124cdf658c8565c8329ff968cccb17d3f39e.tar.bz2 |
Merge topic 'project_ensure_non_cache_variables' into release-3.30
c1ece78d11 project: non cache <project> prefix variables are also created
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !9779
-rw-r--r-- | Source/cmProjectCommand.cxx | 7 | ||||
-rw-r--r-- | Tests/RunCMake/project/ProjectCMP0126.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/project/RunCMakeTest.cmake | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 53166c1..13070dd 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -59,9 +59,14 @@ bool cmProjectCommand(std::vector<std::string> const& args, mf.AddCacheDefinition(projectName + "_BINARY_DIR", mf.GetCurrentBinaryDirectory(), "Value Computed by CMake", cmStateEnums::STATIC); + mf.AddDefinition(projectName + "_BINARY_DIR", + mf.GetCurrentBinaryDirectory()); + mf.AddCacheDefinition(projectName + "_SOURCE_DIR", mf.GetCurrentSourceDirectory(), "Value Computed by CMake", cmStateEnums::STATIC); + mf.AddDefinition(projectName + "_SOURCE_DIR", + mf.GetCurrentSourceDirectory()); mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory()); mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory()); @@ -72,6 +77,8 @@ bool cmProjectCommand(std::vector<std::string> const& args, mf.AddCacheDefinition(projectName + "_IS_TOP_LEVEL", mf.IsRootMakefile() ? "ON" : "OFF", "Value Computed by CMake", cmStateEnums::STATIC); + mf.AddDefinition(projectName + "_IS_TOP_LEVEL", + mf.IsRootMakefile() ? "ON" : "OFF"); // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. If there are two project commands diff --git a/Tests/RunCMake/project/ProjectCMP0126.cmake b/Tests/RunCMake/project/ProjectCMP0126.cmake new file mode 100644 index 0000000..65e3982 --- /dev/null +++ b/Tests/RunCMake/project/ProjectCMP0126.cmake @@ -0,0 +1,11 @@ +cmake_policy(SET CMP0126 NEW) +set(example_SOURCE_DIR "bad/path") +set(example_BINARY_DIR "bad/path") +project(example LANGUAGES) + +if(NOT "${example_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") + message(FATAL_ERROR "example_SOURCE_DIR not set to expected value") +endif() +if(NOT "${example_BINARY_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + message(FATAL_ERROR "example_BINARY_DIR not set to expected value") +endif() diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 16f10be..9c49281 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -33,6 +33,7 @@ run_cmake(LanguagesUnordered) if(RunCMake_GENERATOR MATCHES "Make|Ninja") run_cmake(LanguagesUsedButNotEnabled) endif() +run_cmake(ProjectCMP0126) run_cmake(ProjectDescription) run_cmake(ProjectDescription2) run_cmake(ProjectDescriptionNoArg) |