From d74210a8bdd34e11929c291872a718ce1b8d159e Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 17 Nov 2024 10:40:02 -0500 Subject: [PATCH] CMP0017: Remove support for OLD behavior --- Help/policy/CMP0017.rst | 9 ++++--- Source/cmMakefile.cxx | 31 ++--------------------- Source/cmPolicies.h | 2 +- Tests/FindPackageCMakeTest/CMakeLists.txt | 5 ---- 4 files changed, 8 insertions(+), 39 deletions(-) diff --git a/Help/policy/CMP0017.rst b/Help/policy/CMP0017.rst index d06ad137e1..7bac8a69c0 100644 --- a/Help/policy/CMP0017.rst +++ b/Help/policy/CMP0017.rst @@ -1,6 +1,9 @@ CMP0017 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + Prefer files from the CMake module directory when including from there. Starting with CMake 2.8.4, if a cmake-module shipped with CMake (i.e. @@ -15,7 +18,5 @@ behavior is to always prefer files from CMAKE_MODULE_PATH over files from the CMake modules directory. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.4 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 88d3c0c041..1a0ec22ada 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3737,16 +3737,6 @@ std::string cmMakefile::GetModulesFile(cm::string_view filename, bool& system, { std::string result; - // We search the module always in CMAKE_ROOT and in CMAKE_MODULE_PATH, - // and then decide based on the policy setting which one to return. - // See CMP0017 for more details. - // The specific problem was that KDE 4.5.0 installs a - // FindPackageHandleStandardArgs.cmake which doesn't have the new features - // of FPHSA.cmake introduced in CMake 2.8.3 yet, and by setting - // CMAKE_MODULE_PATH also e.g. FindZLIB.cmake from cmake included - // FPHSA.cmake from kdelibs and not from CMake, and tried to use the - // new features, which were not there in the version from kdelibs, and so - // failed (" std::string moduleInCMakeRoot; std::string moduleInCMakeModulePath; @@ -3795,25 +3785,8 @@ std::string cmMakefile::GetModulesFile(cm::string_view filename, bool& system, cmValue currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); std::string mods = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/"); if (currentFile && cmSystemTools::IsSubDirectory(*currentFile, mods)) { - switch (this->GetPolicyStatus(cmPolicies::CMP0017)) { - case cmPolicies::WARN: { - auto e = cmStrCat( - "File ", *currentFile, " includes ", moduleInCMakeModulePath, - " (found via CMAKE_MODULE_PATH) which shadows ", moduleInCMakeRoot, - ". This may cause errors later on .\n", - cmPolicies::GetPolicyWarning(cmPolicies::CMP0017)); - this->IssueMessage(MessageType::AUTHOR_WARNING, e); - CM_FALLTHROUGH; - } - case cmPolicies::OLD: - system = false; - result = moduleInCMakeModulePath; - break; - case cmPolicies::NEW: - system = true; - result = moduleInCMakeRoot; - break; - } + system = true; + result = moduleInCMakeRoot; } } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 5a6c4a1b20..bd2071290a 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -64,7 +64,7 @@ class cmMakefile; SELECT(POLICY, CMP0017, \ "Prefer files from the CMake module directory when including from " \ "there.", \ - 2, 8, 4, WARN) \ + 2, 8, 4, NEW) \ SELECT(POLICY, CMP0018, \ "Ignore CMAKE_SHARED_LIBRARY__FLAGS variable.", 2, 8, 9, WARN) \ SELECT(POLICY, CMP0019, \ diff --git a/Tests/FindPackageCMakeTest/CMakeLists.txt b/Tests/FindPackageCMakeTest/CMakeLists.txt index 4153437c56..3e010292a7 100644 --- a/Tests/FindPackageCMakeTest/CMakeLists.txt +++ b/Tests/FindPackageCMakeTest/CMakeLists.txt @@ -12,11 +12,6 @@ set(CMAKE_FIND_USE_INSTALL_PREFIX OFF) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -# Look for a package which uses FindPackageHandleStandardArgs.cmake with the -# new (as of cmake 2.8.3) syntax. This works only if CMP0017 is set to NEW, -# because otherwise FindPackageHandleStandardArgs.cmake from the current -# directory is included (via CMAKE_MODULE_PATH). -cmake_policy(SET CMP0017 NEW) find_package(ZLIB QUIET) # Look for a package that has a find module and may be found.