summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-01-22 14:50:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-01-22 14:50:49 (GMT)
commit15c573df4115ab1be01da118c91b4d942e9007d6 (patch)
tree1b053b88a918326e5f6ebf2c91e132474b0fd772
parent39695f6fb316de2289636de483f52d53096ac41d (diff)
parent3ec82b713e51711df0c70f539aea62fc16dd3060 (diff)
downloadCMake-15c573df4115ab1be01da118c91b4d942e9007d6.zip
CMake-15c573df4115ab1be01da118c91b4d942e9007d6.tar.gz
CMake-15c573df4115ab1be01da118c91b4d942e9007d6.tar.bz2
Merge topic 'mark_as_advanced-without-cache'
3ec82b713e cmMarkAsAdvancedCommand: ignore variables which don't exist in the cache 701a5c60e0 cmake: avoid marking local or unused variables as advanced af158149e7 FindOpenSSL: do not mark a local variable as advanced 74f659f1f2 FindCurses: only mark CURSES_EXTRA_LIBRARY when it is used 7e2ae4e96d FindOpenGL: only mark declared cache variables as advanced 7cc02a0c29 FindLua: only mark LUA_MATH_LIBRARY as advanced if required 85cd26b8a6 FindBoost: only mark Boost_DIR as advanced if defined 338c7916ba CTest: avoid marking undeclared cache variables as advanced ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4150
-rw-r--r--CMakeLists.txt1
-rw-r--r--Help/command/mark_as_advanced.rst6
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0102.rst25
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst2
-rw-r--r--Modules/CPack.cmake71
-rw-r--r--Modules/CTest.cmake4
-rw-r--r--Modules/FindBoost.cmake5
-rw-r--r--Modules/FindCurses.cmake5
-rw-r--r--Modules/FindLua.cmake3
-rw-r--r--Modules/FindOpenGL.cmake43
-rw-r--r--Modules/FindOpenSSL.cmake2
-rw-r--r--Source/cmMarkAsAdvancedCommand.cxx62
-rw-r--r--Source/cmPolicies.h5
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-Common.cmake2
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-NEW.cmake13
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-OLD.cmake18
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake16
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0102/CMP0102-WARN.cmake18
-rw-r--r--Tests/RunCMake/CMP0102/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0102/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Utilities/cmlibarchive/CMakeLists.txt1
24 files changed, 264 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f4c111..c7d139b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -264,7 +264,6 @@ macro(CMAKE_SETUP_TESTING)
${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
endif()
mark_as_advanced(DART_ROOT)
- mark_as_advanced(CURL_TESTING)
endmacro()
diff --git a/Help/command/mark_as_advanced.rst b/Help/command/mark_as_advanced.rst
index 5712fb4..e52e623 100644
--- a/Help/command/mark_as_advanced.rst
+++ b/Help/command/mark_as_advanced.rst
@@ -22,3 +22,9 @@ If neither ``FORCE`` nor ``CLEAR`` is specified,
new values will be marked as advanced, but if a
variable already has an advanced/non-advanced state,
it will not be changed.
+
+.. note::
+
+ Policy :policy:`CMP0102` affects the behavior of the ``mark_as_advanced``
+ call. When set to ``NEW``, variables passed to this command which are not
+ already in the cache are ignored. See policy :policy:`CMP0102`.
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 53cf264..c256250 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.17
.. toctree::
:maxdepth: 1
+ CMP0102: mark_as_advanced() does nothing if a cache entry does not exist. </policy/CMP0102>
CMP0101: target_compile_options honors BEFORE keyword in all scopes. </policy/CMP0101>
CMP0100: Let AUTOMOC and AUTOUIC process .hh header files. </policy/CMP0100>
CMP0099: Link properties are transitive over private dependency on static libraries. </policy/CMP0099>
diff --git a/Help/policy/CMP0102.rst b/Help/policy/CMP0102.rst
new file mode 100644
index 0000000..9859006
--- /dev/null
+++ b/Help/policy/CMP0102.rst
@@ -0,0 +1,25 @@
+CMP0102
+-------
+
+The :command:`mark_as_advanced` command no longer creates a cache entry if one
+does not already exist.
+
+In CMake 3.16 and below, if a variable was not defined at all or just defined
+locally, the :command:`mark_as_advanced` command would create a new cache
+entry with an ``UNINITIALIZED`` type and no value. When a :command:`find_path`
+(or other similar ``find_`` command) would next run, it would find this
+undefined cache entry and set it up with an empty string value. This process
+would end up deleting the local variable in the process (due to the way the
+cache works), effectively clearing any stored ``find_`` results that were only
+available in the local scope.
+
+The ``OLD`` behavior for this policy is to create the empty cache definition.
+The ``NEW`` behavior of this policy is to ignore variables which do not
+already exist in the cache.
+
+This policy was introduced in CMake version 3.17. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index fc52e7b..de71d0e 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
@@ -23,6 +23,8 @@ warn by default:
policy :policy:`CMP0082`.
* ``CMAKE_POLICY_WARNING_CMP0089`` controls the warning for
policy :policy:`CMP0089`.
+* ``CMAKE_POLICY_WARNING_CMP0102`` controls the warning for
+ policy :policy:`CMP0102`.
This variable should not be set by a project in CMake code. Project
developers running CMake may set this variable in their cache to
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index e4f75d5..3b46ca5 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -565,8 +565,16 @@ if(NOT CPACK_GENERATOR)
option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF)
+ mark_as_advanced(
+ CPACK_BINARY_BUNDLE
+ CPACK_BINARY_DRAGNDROP
+ CPACK_BINARY_OSXX11
+ CPACK_BINARY_PACKAGEMAKER
+ CPACK_BINARY_PRODUCTBUILD
+ )
else()
option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
+ mark_as_advanced(CPACK_BINARY_TZ)
endif()
option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF)
@@ -576,6 +584,16 @@ if(NOT CPACK_GENERATOR)
option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF)
+ mark_as_advanced(
+ CPACK_BINARY_DEB
+ CPACK_BINARY_FREEBSD
+ CPACK_BINARY_NSIS
+ CPACK_BINARY_RPM
+ CPACK_BINARY_STGZ
+ CPACK_BINARY_TBZ2
+ CPACK_BINARY_TGZ
+ CPACK_BINARY_TXZ
+ )
endif()
else()
option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF)
@@ -583,8 +601,16 @@ if(NOT CPACK_GENERATOR)
option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF)
option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF)
option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
+ mark_as_advanced(
+ CPACK_BINARY_7Z
+ CPACK_BINARY_NSIS
+ CPACK_BINARY_NUGET
+ CPACK_BINARY_WIX
+ CPACK_BINARY_ZIP
+ )
endif()
option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
+ mark_as_advanced(CPACK_BINARY_IFW)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_7Z 7Z)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
@@ -614,6 +640,7 @@ if(NOT CPACK_SOURCE_GENERATOR)
if(UNIX)
if(CYGWIN)
option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
+ mark_as_advanced(CPACK_SOURCE_CYGWIN)
else()
option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF)
option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
@@ -621,10 +648,22 @@ if(NOT CPACK_SOURCE_GENERATOR)
option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON)
option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
+ mark_as_advanced(
+ CPACK_SOURCE_RPM
+ CPACK_SOURCE_TBZ2
+ CPACK_SOURCE_TGZ
+ CPACK_SOURCE_TXZ
+ CPACK_SOURCE_TZ
+ CPACK_SOURCE_ZIP
+ )
endif()
else()
option(CPACK_SOURCE_7Z "Enable to build 7-Zip source packages" ON)
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
+ mark_as_advanced(
+ CPACK_SOURCE_7Z
+ CPACK_SOURCE_ZIP
+ )
endif()
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z)
@@ -637,38 +676,6 @@ if(NOT CPACK_SOURCE_GENERATOR)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
endif()
-# mark the above options as advanced
-mark_as_advanced(
- CPACK_BINARY_7Z
- CPACK_BINARY_BUNDLE
- CPACK_BINARY_CYGWIN
- CPACK_BINARY_DEB
- CPACK_BINARY_DRAGNDROP
- CPACK_BINARY_FREEBSD
- CPACK_BINARY_IFW
- CPACK_BINARY_NSIS
- CPACK_BINARY_NUGET
- CPACK_BINARY_OSXX11
- CPACK_BINARY_PACKAGEMAKER
- CPACK_BINARY_PRODUCTBUILD
- CPACK_BINARY_RPM
- CPACK_BINARY_STGZ
- CPACK_BINARY_TBZ2
- CPACK_BINARY_TGZ
- CPACK_BINARY_TXZ
- CPACK_BINARY_TZ
- CPACK_BINARY_WIX
- CPACK_BINARY_ZIP
- CPACK_SOURCE_7Z
- CPACK_SOURCE_CYGWIN
- CPACK_SOURCE_RPM
- CPACK_SOURCE_TBZ2
- CPACK_SOURCE_TGZ
- CPACK_SOURCE_TXZ
- CPACK_SOURCE_TZ
- CPACK_SOURCE_ZIP
- )
-
# Set some other variables
_cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake
index 1a51bc8..8109108 100644
--- a/Modules/CTest.cmake
+++ b/Modules/CTest.cmake
@@ -243,7 +243,6 @@ if(BUILD_TESTING)
mark_as_advanced(
BZRCOMMAND
- BZR_UPDATE_OPTIONS
COVERAGE_COMMAND
COVERAGE_EXTRA_FLAGS
CTEST_SUBMIT_RETRY_DELAY
@@ -257,13 +256,10 @@ if(BUILD_TESTING)
MAKECOMMAND
MEMORYCHECK_COMMAND
MEMORYCHECK_SUPPRESSIONS_FILE
- PURIFYCOMMAND
- SCPCOMMAND
SLURM_SBATCH_COMMAND
SLURM_SRUN_COMMAND
SITE
SVNCOMMAND
- SVN_UPDATE_OPTIONS
)
if(NOT RUN_FROM_DART)
set(RUN_FROM_CTEST_OR_DART 1)
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 0e84fab..deac9ef 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -248,6 +248,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
# Save project's policies
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
+cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var)
function(_boost_get_existing_target component target_var)
set(names "${component}")
@@ -441,7 +442,9 @@ if (NOT Boost_NO_BOOST_CMAKE)
# Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
# need to delegate them to this find_package call.
find_package(Boost QUIET NO_MODULE)
- mark_as_advanced(Boost_DIR)
+ if (DEFINED Boost_DIR)
+ mark_as_advanced(Boost_DIR)
+ endif ()
# If we found a boost cmake package, then we're done. Print out what we found.
# Otherwise let the rest of the module try to find it.
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index e3e7273..ba56078 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -159,6 +159,10 @@ if(CURSES_USE_NCURSES)
if(NOT CURSES_NCURSES_HAS_CBREAK)
find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}")
find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" )
+
+ mark_as_advanced(
+ CURSES_EXTRA_LIBRARY
+ )
endif()
else()
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
@@ -262,6 +266,5 @@ mark_as_advanced(
CURSES_INCLUDE_PATH
CURSES_CURSES_LIBRARY
CURSES_NCURSES_LIBRARY
- CURSES_EXTRA_LIBRARY
CURSES_FORM_LIBRARY
)
diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake
index caf9d69..0b0c970 100644
--- a/Modules/FindLua.cmake
+++ b/Modules/FindLua.cmake
@@ -211,6 +211,7 @@ if (LUA_LIBRARY)
# include the math library for Unix
if (UNIX AND NOT APPLE AND NOT BEOS)
find_library(LUA_MATH_LIBRARY m)
+ mark_as_advanced(LUA_MATH_LIBRARY)
set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
# include dl library for statically-linked Lua library
@@ -232,6 +233,6 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
-mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
+mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY)
cmake_policy(POP)
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index 23bb001d..74392da 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -130,6 +130,8 @@ foreach(component ${OpenGL_FIND_COMPONENTS})
set(OPENGL_USE_${_COMPONENT} 1)
endforeach()
+set(_OpenGL_CACHE_VARS)
+
if (CYGWIN)
find_path(OPENGL_INCLUDE_DIR GL/gl.h )
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
@@ -137,6 +139,11 @@ if (CYGWIN)
find_library(OPENGL_gl_LIBRARY opengl32 )
find_library(OPENGL_glu_LIBRARY glu32 )
+ list(APPEND _OpenGL_CACHE_VARS
+ OPENGL_INCLUDE_DIR
+ OPENGL_gl_LIBRARY
+ OPENGL_glu_LIBRARY
+ )
elseif (WIN32)
if(BORLAND)
@@ -147,6 +154,10 @@ elseif (WIN32)
set (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32")
endif()
+ list(APPEND _OpenGL_CACHE_VARS
+ OPENGL_gl_LIBRARY
+ OPENGL_glu_LIBRARY
+ )
elseif (APPLE)
# The OpenGL.framework provides both gl and glu
find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL library for OS X")
@@ -155,6 +166,11 @@ elseif (APPLE)
find_path(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC "Include for OpenGL on OS X")
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
+ list(APPEND _OpenGL_CACHE_VARS
+ OPENGL_INCLUDE_DIR
+ OPENGL_gl_LIBRARY
+ OPENGL_glu_LIBRARY
+ )
else()
if (CMAKE_SYSTEM_NAME MATCHES "HP-UX")
# Handle HP-UX cases where we only want to find OpenGL in either hpux64
@@ -194,6 +210,12 @@ else()
/usr/openwin/share/include
/opt/graphics/OpenGL/include
)
+ list(APPEND _OpenGL_CACHE_VARS
+ OPENGL_INCLUDE_DIR
+ OPENGL_GLX_INCLUDE_DIR
+ OPENGL_EGL_INCLUDE_DIR
+ OPENGL_xmesa_INCLUDE_DIR
+ )
# Search for the GLVND libraries. We do this regardless of COMPONENTS; we'll
# take into account the COMPONENTS logic later.
@@ -222,6 +244,13 @@ else()
/usr/shlib
)
+ list(APPEND _OpenGL_CACHE_VARS
+ OPENGL_opengl_LIBRARY
+ OPENGL_glx_LIBRARY
+ OPENGL_egl_LIBRARY
+ OPENGL_glu_LIBRARY
+ )
+
set(_OpenGL_GL_POLICY_WARN 0)
if(NOT DEFINED OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE "")
@@ -268,6 +297,7 @@ else()
${_OPENGL_LIB_PATH}
PATH_SUFFIXES libglvnd
)
+ list(APPEND _OpenGL_CACHE_VARS OPENGL_gl_LIBRARY)
endif()
if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY)
@@ -532,14 +562,5 @@ set(OPENGL_LIBRARY ${OPENGL_LIBRARIES})
# This deprecated setting is for backward compatibility with CMake1.4
set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
-mark_as_advanced(
- OPENGL_INCLUDE_DIR
- OPENGL_xmesa_INCLUDE_DIR
- OPENGL_egl_LIBRARY
- OPENGL_glu_LIBRARY
- OPENGL_glx_LIBRARY
- OPENGL_gl_LIBRARY
- OPENGL_opengl_LIBRARY
- OPENGL_EGL_INCLUDE_DIR
- OPENGL_GLX_INCLUDE_DIR
-)
+mark_as_advanced(${_OpenGL_CACHE_VARS})
+unset(_OpenGL_CACHE_VARS)
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 043fc6c..af713d6 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -458,7 +458,7 @@ find_package_handle_standard_args(OpenSSL
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
)
-mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
+mark_as_advanced(OPENSSL_INCLUDE_DIR)
if(OPENSSL_FOUND)
if(NOT TARGET OpenSSL::Crypto AND
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index ca46e14..45043fa 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -4,8 +4,11 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -28,14 +31,63 @@ bool cmMarkAsAdvancedCommand(std::vector<std::string> const& args,
}
i = 1;
}
+
+ cmMakefile& mf = status.GetMakefile();
+ cmState* state = mf.GetState();
+
for (; i < args.size(); ++i) {
std::string const& variable = args[i];
- cmState* state = status.GetMakefile().GetState();
- if (!state->GetCacheEntryValue(variable)) {
- status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
- variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
- overwrite = true;
+
+ bool issueMessage = false;
+ bool oldBehavior = false;
+ bool ignoreVariable = false;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0102)) {
+ case cmPolicies::WARN:
+ if (mf.PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0102")) {
+ if (!state->GetCacheEntryValue(variable)) {
+ issueMessage = true;
+ }
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ oldBehavior = true;
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ if (!state->GetCacheEntryValue(variable)) {
+ ignoreVariable = true;
+ }
+ break;
+ }
+
+ // First see if we should issue a message about CMP0102
+ if (issueMessage) {
+ std::string err = cmStrCat(
+ "Policy CMP0102 is not set: The variable named \"", variable,
+ "\" is not in the cache. This results in an empty cache entry which "
+ "is no longer created when policy CMP0102 is set to NEW. Run \"cmake "
+ "--help-policy CMP0102\" for policy details. Use the cmake_policy "
+ "command to set the policy and suppress this warning.");
+ mf.IssueMessage(MessageType::AUTHOR_WARNING, err);
}
+
+ // If it's not in the cache and we're using the new behavior, nothing to
+ // see here.
+ if (ignoreVariable) {
+ continue;
+ }
+
+ // Check if we want the old behavior of making a dummy cache entry.
+ if (oldBehavior) {
+ if (!state->GetCacheEntryValue(variable)) {
+ status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
+ variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
+ overwrite = true;
+ }
+ }
+
+ // We need a cache entry to do this.
if (!state->GetCacheEntryValue(variable)) {
cmSystemTools::Error("This should never happen...");
return false;
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index eef41c0..1366ff0 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -302,7 +302,10 @@ class cmMakefile;
17, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0101, \
"target_compile_options honors BEFORE keyword in all scopes.", 3, \
- 17, 0, cmPolicies::WARN)
+ 17, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0102, \
+ "mark_as_advanced() does nothing if a cache entry does not exist.", \
+ 3, 17, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
diff --git a/Tests/RunCMake/CMP0102/CMP0102-Common.cmake b/Tests/RunCMake/CMP0102/CMP0102-Common.cmake
new file mode 100644
index 0000000..61fdad6
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-Common.cmake
@@ -0,0 +1,2 @@
+
+mark_as_advanced(CMP0102_TEST_VARIABLE)
diff --git a/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake b/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake
new file mode 100644
index 0000000..bdf769f
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-NEW.cmake
@@ -0,0 +1,13 @@
+
+cmake_policy(SET CMP0102 NEW)
+
+include (CMP0102-Common.cmake)
+get_property(is_type_set CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE SET)
+if (is_type_set)
+ get_property(type CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE)
+ message(FATAL_ERROR
+ "There is a cache entry for an undefined variable after "
+ "`mark_as_advanced`.")
+endif ()
diff --git a/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake b/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake
new file mode 100644
index 0000000..5c20dd3
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-OLD.cmake
@@ -0,0 +1,18 @@
+
+cmake_policy(SET CMP0102 OLD)
+
+include (CMP0102-Common.cmake)
+get_property(is_type_set CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE SET)
+if (NOT is_type_set)
+ message(FATAL_ERROR
+ "There is a cache entry for an undefined variable after "
+ "`mark_as_advanced`.")
+endif ()
+get_property(type CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE)
+if (NOT type STREQUAL "UNINITIALIZED")
+ message(FATAL_ERROR
+ "The cache type for CMP0102_TEST_VARIABLE is not "
+ "UNINITIALIZED")
+endif ()
diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake b/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake
new file mode 100644
index 0000000..d6ebe4d
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-WARN-Default.cmake
@@ -0,0 +1,16 @@
+
+include (CMP0102-Common.cmake)
+get_property(is_type_set CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE SET)
+if (NOT is_type_set)
+ message(FATAL_ERROR
+ "There is a cache entry for an undefined variable after "
+ "`mark_as_advanced`.")
+endif ()
+get_property(type CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE)
+if (NOT type STREQUAL "UNINITIALIZED")
+ message(FATAL_ERROR
+ "The cache type for CMP0102_TEST_VARIABLE is not "
+ "UNINITIALIZED")
+endif ()
diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt b/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt
new file mode 100644
index 0000000..bb56ec2
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-WARN-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) at CMP0102-Common.cmake:2 \(mark_as_advanced\):
+ Policy CMP0102 is not set: The variable named "CMP0102_TEST_VARIABLE" is
+ not in the cache. This results in an empty cache entry which is no longer
+ created when policy CMP0102 is set to NEW. Run "cmake --help-policy
+ CMP0102" for policy details. Use the cmake_policy command to set the
+ policy and suppress this warning.
+Call Stack \(most recent call first\):
+ CMP0102-WARN.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake b/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake
new file mode 100644
index 0000000..e9a45f1
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMP0102-WARN.cmake
@@ -0,0 +1,18 @@
+
+set(CMAKE_POLICY_WARNING_CMP0102 1)
+
+include (CMP0102-Common.cmake)
+get_property(is_type_set CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE SET)
+if (NOT is_type_set)
+ message(FATAL_ERROR
+ "There is a cache entry for an undefined variable after "
+ "`mark_as_advanced`.")
+endif ()
+get_property(type CACHE CMP0102_TEST_VARIABLE
+ PROPERTY TYPE)
+if (NOT type STREQUAL "UNINITIALIZED")
+ message(FATAL_ERROR
+ "The cache type for CMP0102_TEST_VARIABLE is not "
+ "UNINITIALIZED")
+endif ()
diff --git a/Tests/RunCMake/CMP0102/CMakeLists.txt b/Tests/RunCMake/CMP0102/CMakeLists.txt
new file mode 100644
index 0000000..ef2163c
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0102/RunCMakeTest.cmake b/Tests/RunCMake/CMP0102/RunCMakeTest.cmake
new file mode 100644
index 0000000..9b5df74
--- /dev/null
+++ b/Tests/RunCMake/CMP0102/RunCMakeTest.cmake
@@ -0,0 +1,6 @@
+include(RunCMake)
+
+run_cmake(CMP0102-OLD)
+run_cmake(CMP0102-NEW)
+run_cmake(CMP0102-WARN)
+run_cmake(CMP0102-WARN-Default)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d302fe3..cd6e9ae 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -115,6 +115,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
endif()
add_RunCMake_test(CMP0069)
add_RunCMake_test(CMP0081)
+add_RunCMake_test(CMP0102)
# The test for Policy 65 requires the use of the
# CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 60c8316..26a9aa9 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -281,7 +281,6 @@ IF(BZIP2_FOUND)
ENDIF(USE_BZIP2_DLL)
ENDIF(BZIP2_FOUND)
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
-MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
#