diff options
author | Brad King <brad.king@kitware.com> | 2018-07-24 17:10:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-07-24 17:14:10 (GMT) |
commit | 6646771b0f4f6ec71a5717a68f74c987eb399b4e (patch) | |
tree | 63d2716322e633af0133f30c7fbb97060ec7d4ea | |
parent | 08eb157c032487b2793e625c554caae33267116d (diff) | |
download | CMake-6646771b0f4f6ec71a5717a68f74c987eb399b4e.zip CMake-6646771b0f4f6ec71a5717a68f74c987eb399b4e.tar.gz CMake-6646771b0f4f6ec71a5717a68f74c987eb399b4e.tar.bz2 |
project: Do not issue CMP0048 warnings on injected call
Fixes: #18202
-rw-r--r-- | Source/cmMakefile.cxx | 2 | ||||
-rw-r--r-- | Source/cmProjectCommand.cxx | 9 | ||||
-rw-r--r-- | Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt | 12 |
3 files changed, 9 insertions, 14 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3c7a4cf..af97f80 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1511,6 +1511,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); } } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a25bd6b..ee44007 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -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, ""); } diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt deleted file mode 100644 index aafa733..0000000 --- a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt +++ /dev/null @@ -1,12 +0,0 @@ -^CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0048 is not set: project\(\) command manages VERSION variables. - Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy - command to set the policy and suppress this warning. - - The following variable\(s\) would be set to empty: - - CMAKE_PROJECT_VERSION - CMAKE_PROJECT_VERSION_MAJOR - CMAKE_PROJECT_VERSION_MINOR - CMAKE_PROJECT_VERSION_PATCH -This warning is for project developers. Use -Wno-dev to suppress it.$ |