diff options
author | Dan Kegel <dank@oblong.com> | 2016-09-09 20:45:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-12 14:51:18 (GMT) |
commit | 9370b697e994e3b85549f07cbd54223e3e5d714f (patch) | |
tree | 90ce1bedaa2f4385034a7f9f9d0514345a60f282 | |
parent | d5e4cdc0f8c846cdf17f3276d77d352a7644bc88 (diff) | |
download | CMake-9370b697e994e3b85549f07cbd54223e3e5d714f.zip CMake-9370b697e994e3b85549f07cbd54223e3e5d714f.tar.gz CMake-9370b697e994e3b85549f07cbd54223e3e5d714f.tar.bz2 |
Re-order link line to place RPATH entries before libraries
Since we support adding arbitrary flags to the link line via
`target_link_libraries` the project/user may add their own RPATH flags
(typically for system library locations). Re-order the link line to
place our generated RPATH entries before the libraries so that they also
come before flag-specified entries. Otherwise our in-build-tree RPATH
entries may not be preferred by the dynamic loader and we could collide
with libraries in the system directories.
Closes: #16293
-rw-r--r-- | Source/cmLocalGenerator.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 694a9f6..c0ecba3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1531,9 +1531,6 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, linkLibs += " "; } - // Write the library flags to the build rule. - fout << linkLibs; - // Check what kind of rpath flags to use. if (cli.GetRuntimeSep().empty()) { // Each rpath entry gets its own option ("-R a -R b -R c") @@ -1560,6 +1557,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, } } + // Write the library flags to the build rule. + fout << linkLibs; + // Add the linker runtime search path if any. std::string rpath_link = cli.GetRPathLinkString(); if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { |