mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 19:43:23 +08:00
project: non cache <project> prefix variables are also created
Fixes #26243, #25714
This commit is contained in:
@@ -59,9 +59,14 @@ bool cmProjectCommand(std::vector<std::string> const& args,
|
|||||||
mf.AddCacheDefinition(projectName + "_BINARY_DIR",
|
mf.AddCacheDefinition(projectName + "_BINARY_DIR",
|
||||||
mf.GetCurrentBinaryDirectory(),
|
mf.GetCurrentBinaryDirectory(),
|
||||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
"Value Computed by CMake", cmStateEnums::STATIC);
|
||||||
|
mf.AddDefinition(projectName + "_BINARY_DIR",
|
||||||
|
mf.GetCurrentBinaryDirectory());
|
||||||
|
|
||||||
mf.AddCacheDefinition(projectName + "_SOURCE_DIR",
|
mf.AddCacheDefinition(projectName + "_SOURCE_DIR",
|
||||||
mf.GetCurrentSourceDirectory(),
|
mf.GetCurrentSourceDirectory(),
|
||||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
"Value Computed by CMake", cmStateEnums::STATIC);
|
||||||
|
mf.AddDefinition(projectName + "_SOURCE_DIR",
|
||||||
|
mf.GetCurrentSourceDirectory());
|
||||||
|
|
||||||
mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory());
|
mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory());
|
||||||
mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory());
|
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.AddCacheDefinition(projectName + "_IS_TOP_LEVEL",
|
||||||
mf.IsRootMakefile() ? "ON" : "OFF",
|
mf.IsRootMakefile() ? "ON" : "OFF",
|
||||||
"Value Computed by CMake", cmStateEnums::STATIC);
|
"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
|
// Set the CMAKE_PROJECT_NAME variable to be the highest-level
|
||||||
// project name in the tree. If there are two project commands
|
// project name in the tree. If there are two project commands
|
||||||
|
11
Tests/RunCMake/project/ProjectCMP0126.cmake
Normal file
11
Tests/RunCMake/project/ProjectCMP0126.cmake
Normal file
@@ -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()
|
@@ -33,6 +33,7 @@ run_cmake(LanguagesUnordered)
|
|||||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||||
run_cmake(LanguagesUsedButNotEnabled)
|
run_cmake(LanguagesUsedButNotEnabled)
|
||||||
endif()
|
endif()
|
||||||
|
run_cmake(ProjectCMP0126)
|
||||||
run_cmake(ProjectDescription)
|
run_cmake(ProjectDescription)
|
||||||
run_cmake(ProjectDescription2)
|
run_cmake(ProjectDescription2)
|
||||||
run_cmake(ProjectDescriptionNoArg)
|
run_cmake(ProjectDescriptionNoArg)
|
||||||
|
Reference in New Issue
Block a user