Merge topic 'project-injected-no-cmp0048'
6646771b0f
project: Do not issue CMP0048 warnings on injected call08eb157c03
Tests: Add case showing CMP0048 warning on injected project command Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2235
This commit is contained in:
commit
ae2b12a95c
@ -1526,6 +1526,8 @@ void cmMakefile::Configure()
|
||||
project.Name.Lower = "project";
|
||||
project.Arguments.emplace_back("Project", cmListFileArgument::Unquoted,
|
||||
0);
|
||||
project.Arguments.emplace_back("__CMAKE_INJECTED_PROJECT_COMMAND__",
|
||||
cmListFileArgument::Unquoted, 0);
|
||||
listFile.Functions.insert(listFile.Functions.begin(), project);
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
||||
bool haveLanguages = false;
|
||||
bool haveDescription = false;
|
||||
bool haveHomepage = false;
|
||||
bool injectedProjectCommand = false;
|
||||
std::string version;
|
||||
std::string description;
|
||||
std::string homepage;
|
||||
@ -160,6 +161,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
||||
"by a value that expanded to nothing.");
|
||||
resetReporter();
|
||||
};
|
||||
} else if (i == 1 && args[i] == "__CMAKE_INJECTED_PROJECT_COMMAND__") {
|
||||
injectedProjectCommand = true;
|
||||
} else if (doing == DoingVersion) {
|
||||
doing = DoingLanguages;
|
||||
version = args[i];
|
||||
@ -280,8 +283,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
||||
const char* v = this->Makefile->GetDefinition(i);
|
||||
if (v && *v) {
|
||||
if (cmp0048 == cmPolicies::WARN) {
|
||||
vw += "\n ";
|
||||
vw += i;
|
||||
if (!injectedProjectCommand) {
|
||||
vw += "\n ";
|
||||
vw += i;
|
||||
}
|
||||
} else {
|
||||
this->Makefile->AddDefinition(i, "");
|
||||
}
|
||||
|
@ -242,6 +242,7 @@ add_RunCMake_test(math)
|
||||
add_RunCMake_test(message)
|
||||
add_RunCMake_test(option)
|
||||
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
|
||||
add_RunCMake_test(project_injected)
|
||||
add_RunCMake_test(return)
|
||||
add_RunCMake_test(separate_arguments)
|
||||
add_RunCMake_test(set_property)
|
||||
|
0
Tests/RunCMake/project_injected/CMP0048-WARN.cmake
Normal file
0
Tests/RunCMake/project_injected/CMP0048-WARN.cmake
Normal file
3
Tests/RunCMake/project_injected/CMakeLists.txt
Normal file
3
Tests/RunCMake/project_injected/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8.12.2) # old enough to not set CMP0048
|
||||
# no project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
12
Tests/RunCMake/project_injected/RunCMakeTest.cmake
Normal file
12
Tests/RunCMake/project_injected/RunCMakeTest.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
include(RunCMake)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS
|
||||
# Simulate a previous CMake run that used `project(... VERSION ...)`
|
||||
# in a non-injected call site.
|
||||
-DCMAKE_PROJECT_VERSION:STATIC=1.2.3
|
||||
-DCMAKE_PROJECT_VERSION_MAJOR:STATIC=1
|
||||
-DCMAKE_PROJECT_VERSION_MINOR:STATIC=2
|
||||
-DCMAKE_PROJECT_VERSION_PATCH:STATIC=3
|
||||
)
|
||||
run_cmake(CMP0048-WARN)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
Loading…
Reference in New Issue
Block a user