Merge topic 'policy-cleanup'

94b2d56017 Help/policy/CMP0015: Remove stray indentation
577e693d3e Help: Use standard policy advice in CMP0000
96a0cded7f Tests: Avoid enabling C unnecessarily in CMP0022 and CMP0023 cases
c941f728ec Tests/CPackComponentsForAll: Update cmake_minimum_required to 3.10
34070c3319 Tests/CMakeCommands/target_link_libraries: Fix keyword consistency
73c334677d Tests: Use latest cmake_minimum_required possible for old policy cases
cde63efaea Tests/ExternalProject: Update sample projects to require CMake 3.31
0d416ad57f Tests/PolicyScope: Use more recent policies
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10022
This commit is contained in:
Brad King
2024-11-22 14:03:07 +00:00
committed by Kitware Robot
56 changed files with 146 additions and 141 deletions

View File

@@ -21,14 +21,12 @@ the project. See documentation of :command:`cmake_minimum_required` for
details.
Note that the command invocation must appear in the ``CMakeLists.txt``
file itself; a call in an included file is not sufficient. However,
the :command:`cmake_policy` command may be called to set policy ``CMP0000``
to ``OLD`` or ``NEW`` behavior explicitly. The ``OLD`` behavior is to
silently ignore the missing invocation. The ``NEW`` behavior is to issue
an error instead of a warning. An included file may set ``CMP0000``
explicitly to affect how this policy is enforced for the main
``CMakeLists.txt`` file.
file itself; a call in an included file is not sufficient. The ``OLD``
behavior was to silently ignore the missing invocation. The ``NEW``
behavior is to issue an error instead of a warning.
This policy was introduced in CMake version 2.6.0.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.0
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
.. include:: STANDARD_ADVICE.txt
.. include:: DEPRECATED.txt

View File

@@ -1,7 +1,7 @@
CMP0015
-------
:command:`link_directories` treats paths relative to the source dir.
:command:`link_directories` treats paths relative to the source dir.
In CMake 2.8.0 and lower the :command:`link_directories` command passed
relative paths unchanged to the linker. In CMake 2.8.1 and above the

View File

@@ -610,7 +610,7 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
, DebugMode(this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE") ||
this->Target->GetProperty("LINK_DEPENDS_DEBUG_MODE").IsOn())
, LinkLanguage(linkLanguage)
, LinkType(CMP0003_ComputeLinkType(
, LinkType(ComputeLinkType(
this->Config, this->Makefile->GetCMakeInstance()->GetDebugConfigs()))
, Strategy(strategy)

View File

@@ -264,9 +264,6 @@ public:
cmLinkInterface const* GetLinkInterface(
const std::string& config, const cmGeneratorTarget* headTarget) const;
void ComputeLinkInterface(const std::string& config,
cmOptionalLinkInterface& iface,
const cmGeneratorTarget* head) const;
enum class UseTo
{

View File

@@ -683,13 +683,6 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
return iface.Exists ? &iface : nullptr;
}
void cmGeneratorTarget::ComputeLinkInterface(
const std::string& config, cmOptionalLinkInterface& iface,
cmGeneratorTarget const* headTarget) const
{
this->ComputeLinkInterface(config, iface, headTarget, false);
}
void cmGeneratorTarget::ComputeLinkInterface(
const std::string& config, cmOptionalLinkInterface& iface,
cmGeneratorTarget const* headTarget, bool secondPass) const
@@ -1449,8 +1442,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
std::vector<std::string> debugConfigs =
this->Makefile->GetCMakeInstance()->GetDebugConfigs();
cmTargetLinkLibraryType linkType =
CMP0003_ComputeLinkType(config, debugConfigs);
cmTargetLinkLibraryType linkType = ComputeLinkType(config, debugConfigs);
cmTarget::LinkLibraryVectorType const& oldllibs =
this->Target->GetOriginalLinkLibraries();

View File

@@ -153,7 +153,7 @@ struct cmOptionalLinkImplementation : public cmLinkImplementation
};
/** Compute the link type to use for the given configuration. */
inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
inline cmTargetLinkLibraryType ComputeLinkType(
const std::string& config, std::vector<std::string> const& debugConfigs)
{
// No configuration is always optimized.

View File

@@ -277,6 +277,21 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
warnCompat);
}
namespace {
bool IsFromLegacyInstallEXPORT(cmMakefile* mf, unsigned int majorVer,
unsigned int minorVer, unsigned int patchVer)
{
return majorVer == 2 && minorVer == 6 && patchVer == 0 &&
mf->GetStateSnapshot().CanPopPolicyScope() &&
cmSystemTools::Strucmp(mf->GetBacktrace().Top().Name.c_str(),
"cmake_policy") == 0;
}
#define ADVICE_UPDATE_VERSION_ARGUMENT \
"Update the VERSION argument <min> value. Or, use the <min>...<max> " \
"syntax to tell CMake that the project requires at least <min> but has " \
"been updated to work with policies introduced by <max> or earlier."
}
bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
unsigned int minorVer,
unsigned int patchVer,
@@ -285,19 +300,13 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
// Warn about policy versions for which support will be removed.
if (warnCompat == WarnCompat::On &&
(majorVer < 3 || (majorVer == 3 && minorVer < 10)) &&
// Avoid warning on calls generated by install(EXPORT)
// Silently tolerate cmake_policy calls generated by install(EXPORT)
// in CMake versions prior to 3.18.
!(majorVer == 2 && minorVer == 6 && patchVer == 0 &&
mf->GetStateSnapshot().CanPopPolicyScope() &&
cmSystemTools::Strucmp(mf->GetBacktrace().Top().Name.c_str(),
"cmake_policy") == 0)) {
!IsFromLegacyInstallEXPORT(mf, majorVer, minorVer, patchVer)) {
mf->IssueMessage(
MessageType::DEPRECATION_WARNING,
"Compatibility with CMake < 3.10 will be removed from "
"a future version of CMake.\n"
"Update the VERSION argument <min> value. Or, use the <min>...<max> "
"syntax to tell CMake that the project requires at least <min> but has "
"been updated to work with policies introduced by <max> or earlier.");
"a future version of CMake.\n" ADVICE_UPDATE_VERSION_ARGUMENT);
}
// now loop over all the policies and set them as appropriate

View File

@@ -1,7 +1,7 @@
# Using 2.8 will trigger a deprecation warning. In this case it's explicitly
# intentional since the tests checks various policy implementations prior to
# 3.10
cmake_minimum_required(VERSION 2.8.10) # old enough to not set CMP0022
cmake_minimum_required(VERSION 2.8.11) # old enough to not set CMP0022
if(POLICY CMP0129)
cmake_policy(SET CMP0129 NEW)
@@ -151,7 +151,7 @@ add_subdirectory(SubDirB)
target_link_libraries(SubDirB TopDirImported)
add_subdirectory(SubDirC)
target_link_libraries(SubDirC PRIVATE SubDirC2)
target_link_libraries(TopDir SubDirC)
target_link_libraries(TopDir PRIVATE SubDirC)
add_library(TopDirImported IMPORTED INTERFACE)
target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported)
cmake_policy(POP)

View File

@@ -74,9 +74,9 @@ static bool testCreateFromPolicyMap()
std::make_shared<cmDebugger::cmDebuggerVariablesManager>();
cmPolicies::PolicyMap policyMap;
policyMap.Set(cmPolicies::CMP0000, cmPolicies::NEW);
policyMap.Set(cmPolicies::CMP0003, cmPolicies::WARN);
policyMap.Set(cmPolicies::CMP0005, cmPolicies::OLD);
policyMap.Set(cmPolicies::CMP0178, cmPolicies::NEW);
policyMap.Set(cmPolicies::CMP0179, cmPolicies::WARN);
policyMap.Set(cmPolicies::CMP0180, cmPolicies::OLD);
auto vars = cmDebugger::cmDebuggerVariablesHelper::Create(
variablesManager, "Locals", true, policyMap);
@@ -84,9 +84,9 @@ static bool testCreateFromPolicyMap()
variablesManager->HandleVariablesRequest(
CreateVariablesRequest(vars->GetId()));
ASSERT_TRUE(variables.size() == 3);
ASSERT_VARIABLE(variables[0], "CMP0000", "NEW", "string");
ASSERT_VARIABLE(variables[1], "CMP0003", "WARN", "string");
ASSERT_VARIABLE(variables[2], "CMP0005", "OLD", "string");
ASSERT_VARIABLE(variables[0], "CMP0178", "NEW", "string");
ASSERT_VARIABLE(variables[1], "CMP0179", "WARN", "string");
ASSERT_VARIABLE(variables[2], "CMP0180", "OLD", "string");
return true;
}

View File

@@ -7,7 +7,7 @@
# Depending on the CPack generator and on some CPACK_xxx var values
# the generator may produce a single (NSIS, productbuild)
# or several package files (Archive Generators, RPM, DEB)
cmake_minimum_required(VERSION 2.8.3.20101130 FATAL_ERROR)
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(CPackComponentsForAll)
# Use GNUInstallDirs in order to enforce lib64 if needed

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
project (EmptyProperty)
set_property(DIRECTORY APPEND

View File

@@ -168,7 +168,7 @@ if(EP_TEST_CVS)
ExternalProject_Add(${proj}
SOURCE_DIR ${local_cvs_repo}
URL ${CMAKE_CURRENT_SOURCE_DIR}/cvsrepo.tgz
URL_MD5 55fc85825ffdd9ed2597123c68b79f7e
URL_MD5 287399370738adfe932e036cbe38d5b0
BUILD_COMMAND ""
CONFIGURE_COMMAND "${CVS_EXECUTABLE}" --version
INSTALL_COMMAND ""
@@ -190,11 +190,11 @@ if(EP_TEST_CVS)
# CVS by date stamp:
#
set(proj TutorialStep1-CVS-20090626)
set(proj TutorialStep1-CVS-20241115)
ExternalProject_Add(${proj}
CVS_REPOSITORY ":local:${local_cvs_repo}"
CVS_MODULE "TutorialStep1"
CVS_TAG "-D2009-06-26 16:50:00 UTC"
CVS_TAG "-D2024-11-15 23:11:00 UTC"
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -229,7 +229,7 @@ if(EP_TEST_CVS)
INSTALL_COMMAND ""
DEPENDS "SetupLocalCVSRepository"
DEPENDS "EmptyNoOpProject"
DEPENDS "TutorialStep1-CVS-20090626"
DEPENDS "TutorialStep1-CVS-20241115"
DEPENDS "TutorialStep1-CVS-testtag1"
)
set_property(TARGET ${proj} PROPERTY FOLDER "CVS")
@@ -248,7 +248,7 @@ if(EP_TEST_SVN)
ExternalProject_Add(${proj}
SOURCE_DIR ${local_svn_repo}
URL ${CMAKE_CURRENT_SOURCE_DIR}/svnrepo.tgz
URL_MD5 2f468be4ed1fa96377fca0cc830819c4
URL_MD5 0d75c80611c998e36c36f4a9e1e739d0
BUILD_COMMAND ""
CONFIGURE_COMMAND "${Subversion_SVN_EXECUTABLE}" --version
INSTALL_COMMAND ""
@@ -258,10 +258,10 @@ if(EP_TEST_SVN)
# SVN by date stamp:
#
set(proj TutorialStep1-SVN-20090626)
set(proj TutorialStep1-SVN-20241115)
ExternalProject_Add(${proj}
SVN_REPOSITORY "${local_svn_repo_url}"
SVN_REVISION "-r{2009-06-26 16:50:00 +0000}"
SVN_REVISION "-r{2024-11-15 23:23:00 +0000}"
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -272,10 +272,10 @@ if(EP_TEST_SVN)
# SVN by revision number:
#
set(proj TutorialStep1-SVN-r2)
set(proj TutorialStep1-SVN-r3)
ExternalProject_Add(${proj}
SVN_REPOSITORY "${local_svn_repo_url}"
SVN_REVISION "-r2"
SVN_REVISION "-r3"
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -320,7 +320,7 @@ if(EP_TEST_GIT)
set(proj TutorialStep1-GIT-byhash)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_TAG 57418671a0a0e371e7bac532337152595fbe0df5 # generated by gitrepo.bash
GIT_TAG 4ed00009457732fc8b6d75f6159bbc384119c3d1 # generated by gitrepo.bash
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -568,7 +568,7 @@ if(EP_TEST_HG)
set(proj TutorialStep1-HG-byhash)
ExternalProject_Add(${proj}
HG_REPOSITORY "${local_hg_repo}"
HG_TAG dd2ce38a6b8a
HG_TAG fc5a0c915390
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -621,8 +621,8 @@ enable_testing()
# BuildTree tests:
#
if(EP_TEST_CVS)
add_test(TutorialStep1-CVS-20090626-BuildTreeTest
"${binary_base}/TutorialStep1-CVS-20090626/Tutorial" 4)
add_test(TutorialStep1-CVS-20241115-BuildTreeTest
"${binary_base}/TutorialStep1-CVS-20241115/Tutorial" 4)
add_test(TutorialStep1-CVS-testtag1-BuildTreeTest
"${binary_base}/TutorialStep1-CVS-testtag1/Tutorial" 64)
@@ -632,11 +632,11 @@ if(EP_TEST_CVS)
endif()
if(EP_TEST_SVN)
add_test(TutorialStep1-SVN-20090626-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-20090626/Tutorial" 100)
add_test(TutorialStep1-SVN-20241115-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-20241115/Tutorial" 100)
add_test(TutorialStep1-SVN-r2-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-r2/Tutorial" 99)
add_test(TutorialStep1-SVN-r3-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-r3/Tutorial" 99)
add_test(TutorialStep1-SVN-trunk-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98)

Binary file not shown.

View File

@@ -13,6 +13,9 @@ export GIT_AUTHOR_NAME='testauthor'
export GIT_AUTHOR_EMAIL='testauthor@cmake.org'
export GIT_COMMITTER_NAME='testauthor'
export GIT_COMMITTER_EMAIL='testauthor@cmake.org'
export GIT_CONFIG_NOSYSTEM=1
export GIT_CONFIG_GLOBAL="$tmpdir/.gitconfig"
git config --global protocol.file.allow always
(
cd "$tmpdir"
@@ -23,7 +26,7 @@ rm -f gitrepo.git/hooks/*.sample
mkdir gitrepo
cd gitrepo
git init -b "$defaultBranch"
echo 'cmake_minimum_required(VERSION 3.19)
echo 'cmake_minimum_required(VERSION 3.31)
project(Example NONE)
add_custom_target(example ALL
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/example.cmake.in example.cmake
@@ -43,7 +46,7 @@ rm -f gitrepo-sub.git/hooks/*.sample
mkdir gitrepo-sub
cd gitrepo-sub
git init -b "$defaultBranch"
echo 'cmake_minimum_required(VERSION 3.19)
echo 'cmake_minimum_required(VERSION 3.31)
project(ExampleWithSub NONE)
file(STRINGS "${CMAKE_SOURCE_DIR}/.git/config" git_config_strings
REGEX "^\\[submodule")

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -79,7 +79,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local")
set(proj TutorialStep1-LocalTAR)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
URL_MD5 a87c5b47c0201c09ddfe1d5738fdb1e3
URL_MD5 e3774630066d0df5b9074cb777d72802
LIST_SEPARATOR ::
PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
@@ -94,7 +94,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR")
set(proj TutorialStep1-LocalNoDirTAR)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar"
URL_MD5 d09e3d370c5c908fa035c30939ee438e
URL_MD5 a7357d2e8a52cc807957634ea135eb31
LIST_SEPARATOR @@
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
-DTEST_LIST:STRING=1@@2@@3
@@ -115,7 +115,7 @@ ExternalProject_Add_Step(${proj} mypatch
set(proj TutorialStep1-LocalTGZ)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz"
URL_MD5 38c648e817339c356f6be00eeed79bd0
URL_MD5 c04edffa0520d5468d51ecd13a971828
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
INSTALL_COMMAND ""
LOG_BUILD 1
@@ -126,7 +126,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ")
set(proj TutorialStep1-LocalNoDirTGZ)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
URL_HASH SHA256=496229e2a5ed620a37c385ad9406004a18026beab8b55dd2c4565d4b7f1d5383
URL_HASH SHA256=b9aff8a865842b21cb3bc2ec8bed426b46ef560518962a81242c7f2e089c00de
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ""

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.31)
project (Tutorial)
# The version number.

View File

@@ -189,16 +189,16 @@ endif()
file(REMOVE_RECURSE ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals)
if(do_git_tests)
check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 1 REBASE)
check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 1 0 REBASE)
check_a_tag(origin/master b5f0fc2d442b72dd29e655c329af0062e1f8d129 1 1 REBASE)
check_a_tag(tag1 4209914b424925d6f1b558d79454d60967d4b0f3 1 0 REBASE)
# With the Git UPDATE_COMMAND performance patch, this will not require a
# 'git fetch'
check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 0 0 REBASE)
check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1 0 REBASE)
check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 0 0 REBASE)
check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 1 REBASE)
check_a_tag(tag1 4209914b424925d6f1b558d79454d60967d4b0f3 0 0 REBASE)
check_a_tag(tag2 ae72641040f1c9512f152d08afb6909f0498f958 1 0 REBASE)
check_a_tag(4209914b42 4209914b424925d6f1b558d79454d60967d4b0f3 0 0 REBASE)
check_a_tag(origin/master b5f0fc2d442b72dd29e655c329af0062e1f8d129 1 1 REBASE)
# This is a remote symbolic ref, so it will always trigger a 'git fetch'
check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 1 REBASE)
check_a_tag(origin/master b5f0fc2d442b72dd29e655c329af0062e1f8d129 1 1 REBASE)
foreach(strategy IN ITEMS CHECKOUT REBASE_CHECKOUT)
# Move local master back, then apply a change that will cause a conflict
@@ -232,7 +232,7 @@ if(do_git_tests)
message(FATAL_ERROR "Could not commit conflicting change.")
endif()
# This should discard our commit but leave behind an annotated tag
check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 1 ${strategy})
check_a_tag(origin/master b5f0fc2d442b72dd29e655c329af0062e1f8d129 1 1 ${strategy})
endforeach()
# This file matches a .gitignore rule that the last commit defines. We can't
@@ -242,7 +242,7 @@ if(do_git_tests)
# doesn't choke on it.
set(ignoredFile ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT/ignored_item)
file(TOUCH ${ignoredFile})
check_a_tag(origin/master b5752a26ae448410926b35c275af3c192a53722e 1 1 REBASE)
check_a_tag(origin/master b5f0fc2d442b72dd29e655c329af0062e1f8d129 1 1 REBASE)
if(NOT EXISTS ${ignoredFile})
message(FATAL_ERROR "Ignored file is missing")
endif()

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
project(LibName)
# this is a test to make sure that relative path
# LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH work

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
project( LinkLine )
# Makes sure that the library order as specified by the user are

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
project( LinkLineOrder )
# This tests ensures that the order of libraries are preserved when

View File

@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.31)
# Make sure a policy set differently by our includer is now correct.
cmake_policy(GET CMP0003 cmp)
check(CMP0003 "NEW" "${cmp}")
cmake_policy(GET CMP0180 cmp)
check(CMP0180 "NEW" "${cmp}")
# Test allowing the top-level file to not have cmake_minimum_required.
cmake_policy(SET CMP0000 OLD)

View File

@@ -12,9 +12,7 @@ endfunction()
#-----------------------------------------------------------------------------
# Test using a development framework that sets policies for us.
# Policy CMP0011 should not be set at this point.
cmake_policy(GET CMP0011 cmp)
check(CMP0011 "" "${cmp}")
cmake_policy(SET CMP0011 OLD)
# Put the test modules in the search path.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
@@ -23,22 +21,22 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Foo)
# Check policies set by the package.
cmake_policy(GET CMP0003 cmp)
check(CMP0003 "OLD" "${cmp}")
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "NEW" "${cmp}")
cmake_policy(GET CMP0180 cmp)
check(CMP0180 "OLD" "${cmp}")
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "NEW" "${cmp}")
cmake_policy(GET CMP0011 cmp)
check(CMP0011 "NEW" "${cmp}")
# Make sure an included file cannot change policies.
include(Bar)
cmake_policy(GET CMP0003 cmp)
check(CMP0003 "OLD" "${cmp}")
cmake_policy(GET CMP0180 cmp)
check(CMP0180 "OLD" "${cmp}")
# Allow the included file to change policies.
include(Bar NO_POLICY_SCOPE)
cmake_policy(GET CMP0003 cmp)
check(CMP0003 "NEW" "${cmp}")
cmake_policy(GET CMP0180 cmp)
check(CMP0180 "NEW" "${cmp}")
#-----------------------------------------------------------------------------
# Test function and macro policy recording.
@@ -46,65 +44,65 @@ check(CMP0003 "NEW" "${cmp}")
# Create the functions in an isolated scope in which we change policies.
cmake_policy(PUSH)
if(1)
# Change CMP0002
cmake_policy(SET CMP0002 OLD)
# Change CMP0179
cmake_policy(SET CMP0179 OLD)
function(func1)
# CMP0002 should be changed when this function is invoked
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "OLD" "${cmp}")
# CMP0179 should be changed when this function is invoked
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "OLD" "${cmp}")
# The undocumented PARENT_SCOPE option sees the caller's setting.
cmake_policy(GET CMP0002 cmp PARENT_SCOPE)
check(CMP0002 "NEW" "${cmp}")
cmake_policy(GET CMP0179 cmp PARENT_SCOPE)
check(CMP0179 "NEW" "${cmp}")
endfunction()
# Unset CMP0002
cmake_policy(VERSION 2.4)
# Unset CMP0179
cmake_policy(VERSION 3.30)
macro(macro1)
# CMP0002 should be unset when this macro is invoked
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "" "${cmp}")
# CMP0179 should be unset when this macro is invoked
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "" "${cmp}")
# The undocumented PARENT_SCOPE option sees the caller's setting.
cmake_policy(GET CMP0002 cmp PARENT_SCOPE)
check(CMP0002 "NEW" "${cmp}")
cmake_policy(GET CMP0179 cmp PARENT_SCOPE)
check(CMP0179 "NEW" "${cmp}")
# Setting the policy should work here and also in the caller.
cmake_policy(SET CMP0002 OLD)
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "OLD" "${cmp}")
cmake_policy(SET CMP0179 OLD)
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "OLD" "${cmp}")
endmacro()
endif()
cmake_policy(POP)
# CMP0002 should still be NEW in this context.
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "NEW" "${cmp}")
# CMP0179 should still be NEW in this context.
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "NEW" "${cmp}")
# Check the recorded policies
func1()
macro1()
# The macro should have changed CMP0002.
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "OLD" "${cmp}")
# The macro should have changed CMP0179.
cmake_policy(GET CMP0179 cmp)
check(CMP0179 "OLD" "${cmp}")
#-----------------------------------------------------------------------------
# Test CMAKE_POLICY_DEFAULT_CMP<NNNN> variable.
cmake_policy(PUSH)
set(CMAKE_POLICY_DEFAULT_CMP0010 OLD) # ignored
set(CMAKE_POLICY_DEFAULT_CMP0012 OLD) # honored
set(CMAKE_POLICY_DEFAULT_CMP0013 NEW) # honored
set(CMAKE_POLICY_DEFAULT_CMP0014 "") # noop
cmake_policy(VERSION 2.6.3)
cmake_policy(GET CMP0010 cmp)
check(CMP0010 "NEW" "${cmp}")
cmake_policy(GET CMP0012 cmp)
check(CMP0012 "OLD" "${cmp}")
cmake_policy(GET CMP0013 cmp)
check(CMP0013 "NEW" "${cmp}")
cmake_policy(GET CMP0014 cmp)
check(CMP0014 "" "${cmp}")
set(CMAKE_POLICY_DEFAULT_CMP0170 OLD) # ignored
set(CMAKE_POLICY_DEFAULT_CMP0171 OLD) # honored
set(CMAKE_POLICY_DEFAULT_CMP0172 NEW) # honored
set(CMAKE_POLICY_DEFAULT_CMP0173 "") # noop
cmake_policy(VERSION 3.30)
cmake_policy(GET CMP0170 cmp)
check(CMP0170 "NEW" "${cmp}")
cmake_policy(GET CMP0171 cmp)
check(CMP0171 "OLD" "${cmp}")
cmake_policy(GET CMP0172 cmp)
check(CMP0172 "NEW" "${cmp}")
cmake_policy(GET CMP0173 cmp)
check(CMP0173 "" "${cmp}")
cmake_policy(POP)
#-----------------------------------------------------------------------------

View File

@@ -1,2 +1,2 @@
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0003 OLD)
cmake_minimum_required(VERSION 3.31)
cmake_policy(SET CMP0180 OLD)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
# a simple test case
project (PreOrder)
set(CMAKE_IGNORE_DEPENDENCIES_ORDERING 1)

View File

@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
cmake_minimum_required(VERSION 2.8.10)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)

View File

@@ -1,5 +1,5 @@
project(CMP0022-NOWARN-static-NEW)
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)

View File

@@ -1,5 +1,5 @@
project(CMP0022-NOWARN-static)
enable_language(CXX)
add_library(foo STATIC empty_vs6_1.cpp)
add_library(bar STATIC empty_vs6_2.cpp)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN-empty-old)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN)
enable_language(CXX)
add_library(foo STATIC empty_vs6_1.cpp)
add_library(bar STATIC empty_vs6_2.cpp)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN-tll)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN)
enable_language(CXX)
cmake_policy(SET CMP0042 NEW)

View File

@@ -1,5 +1,5 @@
project(cmp0022NEW)
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)

View File

@@ -1,5 +1,5 @@
project(cmp0022NEW)
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)
if(RunCMake_TEST STREQUAL "CMP0044-WARN")
cmake_policy(VERSION 2.8.11) # old enough to not set CMP0044
cmake_policy(VERSION 2.8.12) # old enough to not set CMP0044
endif()
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -45,6 +45,7 @@ endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ExternalFrameworks/CMakeLists.txt
[[
cmake_minimum_required(VERSION 3.31)
project(ExternalFrameworks)
add_library(staticFrameworkExt STATIC func6.c)
add_library(sharedFrameworkExt SHARED func7.c)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN)
enable_language(CXX)
cmake_policy(SET CMP0023 NEW)

View File

@@ -1,5 +1,5 @@
project(CMP0022-WARN)
enable_language(CXX)
cmake_policy(SET CMP0023 NEW)

View File

@@ -1,5 +1,5 @@
cmake_policy(VERSION 2.8.11)
project(CMP0022-WARN)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)

View File

@@ -1,5 +1,5 @@
cmake_policy(VERSION 2.8.11)
project(CMP0022-WARN)
enable_language(CXX)
add_library(foo SHARED empty_vs6_1.cpp)
add_library(bar SHARED empty_vs6_2.cpp)

View File

@@ -1,4 +1,4 @@
# a SBCS test case
cmake_minimum_required(VERSION 3.10)
project (SBCS)
add_definitions(-D_SBCS)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
set(CMAKE_SUPPRESS_REGENERATION 1)
project(LIB1)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.10)
set(CMAKE_SUPPRESS_REGENERATION 1)
project(VSEXTERNAL_LIB2)