diff --git a/Help/policy/CMP0015.rst b/Help/policy/CMP0015.rst index 2e185069c9..6fbe833601 100644 --- a/Help/policy/CMP0015.rst +++ b/Help/policy/CMP0015.rst @@ -1,6 +1,9 @@ CMP0015 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + :command:`link_directories` treats paths relative to the source dir. In CMake 2.8.0 and lower the :command:`link_directories` command passed @@ -13,7 +16,5 @@ this policy is to use relative paths verbatim in the linker command. The paths by appending the relative path to ``CMAKE_CURRENT_SOURCE_DIR``. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.1 -.. |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/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 395f7ceb5d..d45d495b5b 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -2,14 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLinkDirectoriesCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmList.h" #include "cmMakefile.h" -#include "cmMessageType.h" -#include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -52,29 +48,7 @@ static void AddLinkDir(cmMakefile& mf, std::string const& dir, cmSystemTools::ConvertToUnixSlashes(unixPath); if (!cmSystemTools::FileIsFullPath(unixPath) && !cmGeneratorExpression::StartsWithGeneratorExpression(unixPath)) { - bool convertToAbsolute = false; - std::ostringstream e; - /* clang-format off */ - e << "This command specifies the relative path\n" - << " " << unixPath << "\n" - << "as a link directory.\n"; - /* clang-format on */ - switch (mf.GetPolicyStatus(cmPolicies::CMP0015)) { - case cmPolicies::WARN: - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015); - mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - CM_FALLTHROUGH; - case cmPolicies::OLD: - // OLD behavior does not convert - break; - case cmPolicies::NEW: - // NEW behavior converts - convertToAbsolute = true; - break; - } - if (convertToAbsolute) { - unixPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', unixPath); - } + unixPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', unixPath); } directories.push_back(unixPath); } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 13e09c3a48..841cc8270f 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -56,7 +56,7 @@ class cmMakefile; 8, 0, NEW) \ SELECT(POLICY, CMP0015, \ "link_directories() treats paths relative to the source dir.", 2, 8, \ - 1, WARN) \ + 1, NEW) \ SELECT(POLICY, CMP0016, \ "target_link_libraries() reports error if its only argument " \ "is not a target.", \ diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt index b85e351a04..d2d37228f7 100644 --- a/Tests/LinkDirectory/External/CMakeLists.txt +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -20,13 +20,7 @@ add_executable(myexe3 myexe.c) set_property(TARGET myexe3 PROPERTY OUTPUT_NAME LinkDirectory3) target_link_libraries(myexe3 PRIVATE mylibs) - -# Test CMP0015 OLD behavior: -L../lib -cmake_policy(SET CMP0015 OLD) link_directories(../lib${cfg_dir}) - -# Test CMP0015 NEW behavior: -L${CMAKE_CURRENT_SOURCE_DIR}/lib -cmake_policy(SET CMP0015 NEW) link_directories(lib${cfg_dir}) add_executable(myexe myexe.c)