mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 19:43:23 +08:00
cmake_policy: Add undocumented GET_WARNING command
This command is intended for modules that issue policy warnings so they can get the warning string from CMake in a uniform manner, rather than duplicating the string. Several modules been updated to include an example of the usage of this new command.
This commit is contained in:
@@ -230,11 +230,8 @@ if(DEFINED CMAKE_GENERATOR)
|
|||||||
if(_BundleUtilities_CMP0080 STREQUAL "NEW")
|
if(_BundleUtilities_CMP0080 STREQUAL "NEW")
|
||||||
message(FATAL_ERROR "BundleUtilities cannot be included at configure time!")
|
message(FATAL_ERROR "BundleUtilities cannot be included at configure time!")
|
||||||
elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD")
|
elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD")
|
||||||
message(AUTHOR_WARNING
|
cmake_policy(GET_WARNING CMP0080 _cmp0080_warning)
|
||||||
"Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. "
|
message(AUTHOR_WARNING "${_cmp0080_warning}\n")
|
||||||
"Run \"cmake --help-policy CMP0080\" for policy details. "
|
|
||||||
"Use the cmake_policy command to set the policy and suppress this warning."
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -268,11 +268,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY)
|
if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY)
|
||||||
|
cmake_policy(GET_WARNING CMP0072 _cmp0072_warning)
|
||||||
message(AUTHOR_WARNING
|
message(AUTHOR_WARNING
|
||||||
"Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when available. "
|
"${_cmp0072_warning}\n"
|
||||||
"Run \"cmake --help-policy CMP0072\" for policy details. "
|
|
||||||
"Use the cmake_policy command to set the policy and suppress this warning."
|
|
||||||
"\n"
|
|
||||||
"FindOpenGL found both a legacy GL library:\n"
|
"FindOpenGL found both a legacy GL library:\n"
|
||||||
" OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}\n"
|
" OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}\n"
|
||||||
"and GLVND libraries for OpenGL and GLX:\n"
|
"and GLVND libraries for OpenGL and GLX:\n"
|
||||||
|
@@ -554,11 +554,8 @@ function(SWIG_ADD_LIBRARY name)
|
|||||||
set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
|
set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
|
||||||
else()
|
else()
|
||||||
if (NOT target_name_policy)
|
if (NOT target_name_policy)
|
||||||
message(AUTHOR_WARNING
|
cmake_policy(GET_WARNING CMP0078 _cmp0078_warning)
|
||||||
"Policy CMP0078 is not set. "
|
message(AUTHOR_WARNING "${_cmp0078_warning}\n")
|
||||||
"Run \"cmake --help-policy CMP0078\" for policy details. "
|
|
||||||
"Use the cmake_policy command to set the policy and suppress this warning."
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE)
|
if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE)
|
||||||
set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY)
|
set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY)
|
||||||
|
@@ -46,6 +46,9 @@ bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
if (args[0] == "VERSION") {
|
if (args[0] == "VERSION") {
|
||||||
return this->HandleVersionMode(args);
|
return this->HandleVersionMode(args);
|
||||||
}
|
}
|
||||||
|
if (args[0] == "GET_WARNING") {
|
||||||
|
return this->HandleGetWarningMode(args);
|
||||||
|
}
|
||||||
|
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "given unknown first argument \"" << args[0] << "\"";
|
e << "given unknown first argument \"" << args[0] << "\"";
|
||||||
@@ -181,3 +184,33 @@ bool cmCMakePolicyCommand::HandleVersionMode(
|
|||||||
this->Makefile->SetPolicyVersion(version_min, version_max);
|
this->Makefile->SetPolicyVersion(version_min, version_max);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmCMakePolicyCommand::HandleGetWarningMode(
|
||||||
|
std::vector<std::string> const& args)
|
||||||
|
{
|
||||||
|
if (args.size() != 3) {
|
||||||
|
this->SetError(
|
||||||
|
"GET_WARNING must be given exactly 2 additional arguments.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get arguments.
|
||||||
|
std::string const& id = args[1];
|
||||||
|
std::string const& var = args[2];
|
||||||
|
|
||||||
|
// Lookup the policy number.
|
||||||
|
cmPolicies::PolicyID pid;
|
||||||
|
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "GET_WARNING given policy \"" << id
|
||||||
|
<< "\" which is not known to this version of CMake.";
|
||||||
|
this->SetError(e.str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup the policy warning.
|
||||||
|
this->Makefile->AddDefinition(var,
|
||||||
|
cmPolicies::GetPolicyWarning(pid).c_str());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -37,6 +37,7 @@ private:
|
|||||||
bool HandleSetMode(std::vector<std::string> const& args);
|
bool HandleSetMode(std::vector<std::string> const& args);
|
||||||
bool HandleGetMode(std::vector<std::string> const& args);
|
bool HandleGetMode(std::vector<std::string> const& args);
|
||||||
bool HandleVersionMode(std::vector<std::string> const& args);
|
bool HandleVersionMode(std::vector<std::string> const& args);
|
||||||
|
bool HandleGetWarningMode(std::vector<std::string> const& args);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -236,7 +236,7 @@ class cmMakefile;
|
|||||||
"target_link_libraries allows use with targets in other directories.", 3, \
|
"target_link_libraries allows use with targets in other directories.", 3, \
|
||||||
13, 0, cmPolicies::WARN) \
|
13, 0, cmPolicies::WARN) \
|
||||||
SELECT(POLICY, CMP0080, \
|
SELECT(POLICY, CMP0080, \
|
||||||
"BundleUtilities cannot be included at configure time", 3, 13, 0, \
|
"BundleUtilities cannot be included at configure time.", 3, 13, 0, \
|
||||||
cmPolicies::WARN) \
|
cmPolicies::WARN) \
|
||||||
SELECT(POLICY, CMP0081, \
|
SELECT(POLICY, CMP0081, \
|
||||||
"Relative paths not allowed in LINK_DIRECTORIES target property.", \
|
"Relative paths not allowed in LINK_DIRECTORIES target property.", \
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
CMake Warning \(dev\) at .*/Modules/BundleUtilities\.cmake:[0-9]+ \(message\):
|
CMake Warning \(dev\) at .*/Modules/BundleUtilities\.cmake:[0-9]+ \(message\):
|
||||||
Policy CMP0080 is not set: BundleUtilities prefers not to be included at
|
Policy CMP0080 is not set: BundleUtilities cannot be included at configure
|
||||||
configure time\. Run "cmake --help-policy CMP0080" for policy details\. Use
|
time\. Run "cmake --help-policy CMP0080" for policy details\. Use the
|
||||||
the cmake_policy command to set the policy and suppress this warning\.
|
cmake_policy command to set the policy and suppress this warning\.
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMP0080-WARN\.cmake:[0-9]+ \(include\)
|
||||||
|
CMakeLists\.txt:[0-9]+ \(include\)
|
||||||
|
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
CMake Warning \(dev\) at .*/Modules/UseSWIG.cmake:[0-9]+ \(message\):
|
CMake Warning \(dev\) at .*/Modules/UseSWIG\.cmake:[0-9]+ \(message\):
|
||||||
Policy CMP0078 is not set. Run "cmake --help-policy CMP0078" for policy
|
Policy CMP0078 is not set: UseSWIG generates standard target names\. Run
|
||||||
details. Use the cmake_policy command to set the policy and suppress this
|
"cmake --help-policy CMP0078" for policy details\. Use the cmake_policy
|
||||||
warning.
|
command to set the policy and suppress this warning\.
|
||||||
|
|
||||||
Call Stack \(most recent call first\):
|
Call Stack \(most recent call first\):
|
||||||
CMP0078-common.cmake:6 \(swig_add_library\)
|
CMP0078-common\.cmake:6 \(swig_add_library\)
|
||||||
CMP0078-WARN.cmake:1 \(include\)
|
CMP0078-WARN\.cmake:1 \(include\)
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists\.txt:3 \(include\)
|
||||||
This warning is for project developers. Use -Wno-dev to suppress it.$
|
This warning is for project developers. Use -Wno-dev to suppress it.$
|
||||||
|
Reference in New Issue
Block a user