CMP0015: Remove support for OLD behavior
This commit is contained in:
parent
8ef1b4001b
commit
a43470b9ba
@ -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
|
||||
|
@ -2,14 +2,10 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmLinkDirectoriesCommand.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
@ -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.", \
|
||||
|
6
Tests/LinkDirectory/External/CMakeLists.txt
vendored
6
Tests/LinkDirectory/External/CMakeLists.txt
vendored
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user