This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  250ee3ced01448ab865b36de56278afb850d0a94 (commit)
       via  10c044c33862792667f6fc036c397d56f9d7530b (commit)
       via  49c9759abb0e3ebe7a1597ca7acbe51330f94583 (commit)
      from  53c496702fa99a57f8f83e60c479eb39f66b2263 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=250ee3ced01448ab865b36de56278afb850d0a94
commit 250ee3ced01448ab865b36de56278afb850d0a94
Merge: 53c4967 10c044c
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Wed Mar 1 12:35:33 2017 -0500
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Wed Mar 1 12:35:33 2017 -0500

    Merge topic 'implicit-dir-symlinks' into next
    
    10c044c3 cmOrderDirectories: Consider symlinks when checking implicit 
directories
    49c9759a cmOrderDirectories: Factor out implicit directory check


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=10c044c33862792667f6fc036c397d56f9d7530b
commit 10c044c33862792667f6fc036c397d56f9d7530b
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Wed Mar 1 11:55:51 2017 -0500
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Wed Mar 1 12:34:07 2017 -0500

    cmOrderDirectories: Consider symlinks when checking implicit directories
    
    When checking whether a directory is "implicit" (e.g. implicit link
    directory or implicit rpath directory), resolve the real path of both
    sides of the comparison.  Otherwise we will not recognize paths like
    `/usr/lib32` as implicit when `/usr/lib` is implicit and `lib32` is
    actually a symlink to `lib`.  This can lead to addition of unnecessary
    entries to the RPATH of a binary, for example.
    
    Fixes: #16682

diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index d93debe..dfba80e 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -345,12 +345,17 @@ void cmOrderDirectories::AddLanguageDirectories(
 void cmOrderDirectories::SetImplicitDirectories(
   std::set<std::string> const& implicitDirs)
 {
-  this->ImplicitDirectories = implicitDirs;
+  this->ImplicitDirectories.clear();
+  for (std::set<std::string>::iterator i = implicitDirs.begin();
+       i != implicitDirs.end(); ++i) {
+    this->ImplicitDirectories.insert(this->GetRealPath(*i));
+  }
 }
 
 bool cmOrderDirectories::IsImplicitDirectory(std::string const& dir)
 {
-  return this->ImplicitDirectories.find(dir) !=
+  std::string const& real = this->GetRealPath(dir);
+  return this->ImplicitDirectories.find(real) !=
     this->ImplicitDirectories.end();
 }
 
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 9dc540f..e1297fa 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -153,6 +153,9 @@ add_RunCMake_test(TargetPropertyGeneratorExpressions)
 add_RunCMake_test(Languages)
 add_RunCMake_test(LinkStatic)
 add_RunCMake_test(ObjectLibrary)
+if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT 
STREQUAL "ELF")
+  add_RunCMake_test(RuntimePath)
+endif()
 add_RunCMake_test(Swift)
 add_RunCMake_test(TargetObjects)
 add_RunCMake_test(TargetSources)
diff --git a/Tests/RunCMake/RuntimePath/A.c b/Tests/RunCMake/RuntimePath/A.c
new file mode 100644
index 0000000..e9d4195
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/A.c
@@ -0,0 +1,4 @@
+int libA(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/RuntimePath/CMakeLists.txt 
b/Tests/RunCMake/RuntimePath/CMakeLists.txt
new file mode 100644
index 0000000..a640c56
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.7)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake 
b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
new file mode 100644
index 0000000..a9a7f05
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
@@ -0,0 +1,18 @@
+include(RunCMake)
+
+
+function(run_SymlinkImplicit)
+  # Use a single build tree for a few tests without cleaning.
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SymlinkImplicit-build)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+    set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+  endif()
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake(SymlinkImplicit)
+  run_cmake_command(SymlinkImplicit-build ${CMAKE_COMMAND} --build . --config 
Debug)
+  run_cmake_command(SymlinkImplicitCheck
+    ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P 
${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake)
+endfunction()
+run_SymlinkImplicit()
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake 
b/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
new file mode 100644
index 0000000..6578f8f
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+set(lib_dir ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(lib_link ${CMAKE_CURRENT_BINARY_DIR}/libLink)
+set(lib_always ${CMAKE_CURRENT_BINARY_DIR}/libAlways)
+file(MAKE_DIRECTORY ${lib_dir})
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${lib_link})
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${lib_always})
+
+add_library(A SHARED A.c)
+list(APPEND CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${lib_dir})
+set_property(TARGET A PROPERTY LIBRARY_OUTPUT_DIRECTORY ${lib_link})
+
+add_executable(exe main.c)
+target_link_libraries(exe A)
+set_property(TARGET exe PROPERTY RUNTIME_OUTPUT_DIRECTORY 
${CMAKE_CURRENT_BINARY_DIR}/bin)
+set_property(TARGET exe PROPERTY BUILD_RPATH ${lib_always})
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt 
b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt 
b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
new file mode 100644
index 0000000..ad51fd3
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
@@ -0,0 +1,18 @@
+^CMake Error at 
.*/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake:[0-9]+ \(file\):
+  file RPATH_CHANGE could not write new RPATH:
+
+    old-should-not-exist
+
+  to the file:
+
+    .*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/exe
+
+  The current RUNPATH is:
+
+    .*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/libAlways
+
+  which does not contain:
+
+    .*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/libLink
+
+  as was expected\.$
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake 
b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
new file mode 100644
index 0000000..d34742e
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
@@ -0,0 +1,2 @@
+file(COPY ${dir}/bin/exe DESTINATION ${dir})
+file(RPATH_CHANGE FILE "${dir}/exe" OLD_RPATH "${dir}/libLink" NEW_RPATH 
"old-should-not-exist")
diff --git a/Tests/RunCMake/RuntimePath/main.c 
b/Tests/RunCMake/RuntimePath/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+  return 0;
+}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49c9759abb0e3ebe7a1597ca7acbe51330f94583
commit 49c9759abb0e3ebe7a1597ca7acbe51330f94583
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Wed Mar 1 11:55:37 2017 -0500
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Wed Mar 1 12:34:07 2017 -0500

    cmOrderDirectories: Factor out implicit directory check

diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 7744a5a..d93debe 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -287,8 +287,7 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string 
const& fullPath,
         }
       }
 
-      if (this->ImplicitDirectories.find(dir) !=
-          this->ImplicitDirectories.end()) {
+      if (this->IsImplicitDirectory(dir)) {
         this->ImplicitDirEntries.push_back(
           new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
         return;
@@ -316,8 +315,7 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& 
fullPath)
     // Implicit link directories need special handling.
     if (!this->ImplicitDirectories.empty()) {
       std::string dir = cmSystemTools::GetFilenamePath(fullPath);
-      if (this->ImplicitDirectories.find(dir) !=
-          this->ImplicitDirectories.end()) {
+      if (this->IsImplicitDirectory(dir)) {
         this->ImplicitDirEntries.push_back(
           new cmOrderDirectoriesConstraintLibrary(this, fullPath));
         return;
@@ -350,6 +348,12 @@ void cmOrderDirectories::SetImplicitDirectories(
   this->ImplicitDirectories = implicitDirs;
 }
 
+bool cmOrderDirectories::IsImplicitDirectory(std::string const& dir)
+{
+  return this->ImplicitDirectories.find(dir) !=
+    this->ImplicitDirectories.end();
+}
+
 void cmOrderDirectories::SetLinkExtensionInfo(
   std::vector<std::string> const& linkExtensions,
   std::string const& removeExtRegex)
@@ -394,8 +398,7 @@ void cmOrderDirectories::AddOriginalDirectories(
   for (std::vector<std::string>::const_iterator di = dirs.begin();
        di != dirs.end(); ++di) {
     // We never explicitly specify implicit link directories.
-    if (this->ImplicitDirectories.find(*di) !=
-        this->ImplicitDirectories.end()) {
+    if (this->IsImplicitDirectory(*di)) {
       continue;
     }
 
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 90a67e7..d9e0126 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -82,6 +82,8 @@ private:
   // Compare directories after resolving symlinks.
   bool IsSameDirectory(std::string const& l, std::string const& r);
 
+  bool IsImplicitDirectory(std::string const& dir);
+
   std::string const& GetRealPath(std::string const& dir);
   std::map<std::string, std::string> RealPaths;
 

-----------------------------------------------------------------------

Summary of changes:
 Source/cmOrderDirectories.cxx                      |   22 +++++++++++++-------
 Source/cmOrderDirectories.h                        |    2 ++
 Tests/RunCMake/CMakeLists.txt                      |    3 +++
 .../RunCMake/RuntimePath/A.c                       |    2 +-
 .../{Cpplint => RuntimePath}/CMakeLists.txt        |    0
 Tests/RunCMake/RuntimePath/RunCMakeTest.cmake      |   18 ++++++++++++++++
 Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake   |   17 +++++++++++++++
 .../SymlinkImplicitCheck-result.txt}               |    0
 .../RuntimePath/SymlinkImplicitCheck-stderr.txt    |   18 ++++++++++++++++
 .../RuntimePath/SymlinkImplicitCheck.cmake         |    2 ++
 .../RuntimePath}/main.c                            |    0
 11 files changed, 76 insertions(+), 8 deletions(-)
 copy Modules/DummyCXXFile.cxx => Tests/RunCMake/RuntimePath/A.c (51%)
 copy Tests/RunCMake/{Cpplint => RuntimePath}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => 
RuntimePath/SymlinkImplicitCheck-result.txt} (100%)
 create mode 100644 Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
 create mode 100644 Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
 copy Tests/{CMakeOnly/LinkInterfaceLoop => RunCMake/RuntimePath}/main.c (100%)


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to