[Cmake-commits] CMake branch, next, updated. v2.8.4-1226-g862102a

Eric Noulard eric.noulard at gmail.com
Sat Mar 19 10:34:27 EDT 2011


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  862102ac44016bb3ac75ab41b2f25aa43b05c187 (commit)
       via  d515479117a0c97b0360eb541ced23f58b9266c8 (commit)
      from  52682a93ab3b7b3678968504432258149cea0f67 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=862102ac44016bb3ac75ab41b2f25aa43b05c187
commit 862102ac44016bb3ac75ab41b2f25aa43b05c187
Merge: 52682a9 d515479
Author:     Eric Noulard <eric.noulard at gmail.com>
AuthorDate: Sat Mar 19 10:34:25 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Mar 19 10:34:25 2011 -0400

    Merge topic 'linux-lib64-handling' into next
    
    d515479 fix #0011964 withe the use of a new CMAKE_USE_LIB64_PATH property


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d515479117a0c97b0360eb541ced23f58b9266c8
commit d515479117a0c97b0360eb541ced23f58b9266c8
Author:     Eric NOULARD <eric.noulard at gmail.com>
AuthorDate: Mon Mar 14 21:10:17 2011 +0100
Commit:     Eric NOULARD <eric.noulard at gmail.com>
CommitDate: Sat Mar 19 15:26:50 2011 +0100

    fix #0011964 withe the use of a new CMAKE_USE_LIB64_PATH property
    
    When the property is set cmake (install generator) will automatically
    rename 'lib' to 'lib64' if lib is found as a directory part
    of some DESTINATION ARCHIVE or LIBRARY.

diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
index 6490dd1..64d71ea 100644
--- a/Modules/Platform/Linux.cmake
+++ b/Modules/Platform/Linux.cmake
@@ -47,8 +47,30 @@ ENDIF(DEFINED CMAKE_INSTALL_SO_NO_EXE)
 
 INCLUDE(Platform/UnixPaths)
 
+
 # Debian has lib64 paths only for compatibility so they should not be
 # searched.
 IF(EXISTS "/etc/debian_version")
   SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
-ENDIF(EXISTS "/etc/debian_version")
+ELSE(EXISTS "/etc/debian_version")
+  # Guess whether if we are on a 64 or 32 bits Linux host
+  # and define CMAKE_USE_LIB64_PATH accordingly.
+  # CMAKE_USE_LIB64_PATH would be either "" or "64" on 64 bits host
+  # see amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
+  # If we are cross-compiling don't do anything and let the developer decide.
+  IF(NOT CMAKE_CROSSCOMPILING)
+    FIND_PROGRAM(UNAME_PROGRAM NAMES uname)
+    IF(UNAME_PROGRAM)
+      EXECUTE_PROCESS(COMMAND ${UNAME_PROGRAM} -m
+                      OUTPUT_VARIABLE LINUX_ARCH
+                      ERROR_QUIET
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                     )
+      IF(LINUX_ARCH MATCHES "x86_64")
+        SET_PROPERTY(GLOBAL PROPERTY CMAKE_USE_LIB64_PATH TRUE)
+      ELSE(LINUX_ARCH MATCHES "x86_64")
+        SET_PROPERTY(GLOBAL PROPERTY CMAKE_USE_LIB64_PATH FALSE)
+      ENDIF(LINUX_ARCH MATCHES "x86_64")
+    ENDIF(UNAME_PROGRAM)
+  ENDIF(NOT CMAKE_CROSSCOMPILING)
+ENDIF(EXISTS "/etc/debian_version")
\ No newline at end of file
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 5ee7ddb..c581142 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -86,3 +86,7 @@ LIST(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
 
 # Enable use of lib64 search path variants by default.
 SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
+# However the lib->lib64 automatic name mangling is
+# not the default because it is only set on Linux x86_64
+# and not on Debian based distro
+SET_PROPERTY(GLOBAL PROPERTY CMAKE_USE_LIB64_PATH FALSE)
\ No newline at end of file
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 14deb24..a8d5fa2 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -268,7 +268,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
   privateHeaderArgs.SetGenericArguments(&genericArgs);
   publicHeaderArgs.SetGenericArguments(&genericArgs);
   resourceArgs.SetGenericArguments(&genericArgs);
-
+  if (this->Makefile->GetCMakeInstance()
+        ->GetPropertyAsBool("CMAKE_USE_LIB64_PATH")) {
+    archiveArgs.EnableMangleLibDestination();
+    libraryArgs.EnableMangleLibDestination();
+  }
   success = success && archiveArgs.Finalize();
   success = success && libraryArgs.Finalize();
   success = success && runtimeArgs.Finalize();
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 13ef8ed..bef36f2 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -34,6 +34,7 @@ cmInstallCommandArguments::cmInstallCommandArguments()
 ,Optional      (&Parser, "OPTIONAL"      , &ArgumentGroup)
 ,NamelinkOnly  (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
 ,NamelinkSkip  (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
+,mangleLibDestination(false)
 ,GenericArguments(0)
 {}
 
@@ -153,6 +154,10 @@ bool cmInstallCommandArguments::Finalize()
     }
   this->DestinationString = this->Destination.GetString();
   cmSystemTools::ConvertToUnixSlashes(this->DestinationString);
+  if (this->mangleLibDestination)
+    {
+      this->DoMangleLibDestination();
+    }
   return true;
 }
 
@@ -197,3 +202,24 @@ bool cmInstallCommandArguments::CheckPermissions(
   // This is not a valid permission.
   return false;
 }
+
+bool cmInstallCommandArguments::DoMangleLibDestination() {
+
+  size_t pos = this->DestinationString.find("lib");
+  // We should replace lib, if it is found AND
+  // it is not part of a name
+  if (pos!=std::string::npos) {
+    // "lib" alone
+    if (this->DestinationString.length()==(pos+3)) {
+      this->DestinationString.insert(pos+3,"64");
+    }
+    // something/lib or lib/something or some1/lib/some2
+    if ((this->DestinationString.length()>(pos+3)) &&
+        (this->DestinationString[pos+3]=='/')) {
+      if ((pos==0) || (this->DestinationString[pos-1]=='/')){
+        this->DestinationString.insert(pos+3,"64");
+      }
+    }
+  }
+  return true;
+}
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index 16033ce..eb90609 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -27,6 +27,8 @@ class cmInstallCommandArguments
 
     // Compute destination path.and check permissions
     bool Finalize();
+    /** Enable Lib destination mangling */
+    void EnableMangleLibDestination() {this->mangleLibDestination = true;}
 
     const std::string& GetDestination() const;
     const std::string& GetComponent() const;
@@ -44,6 +46,15 @@ class cmInstallCommandArguments
                                  std::string& perm);
     cmCommandArgumentsHelper Parser;
     cmCommandArgumentGroup ArgumentGroup;
+    /**
+     * Mangle the lib destination in order to handle
+     * the special lib64/lib32/lib case on Linux.
+     * the user may have specified DESTINATION lib
+     * and get the final destination as lib64 if the
+     * current host system requires it.
+     * see CMAKE_USE_LIB64_PATH global property
+     */
+    bool DoMangleLibDestination();
   private:
     cmCAString Destination;
     cmCAString Component;
@@ -53,6 +64,12 @@ class cmInstallCommandArguments
     cmCAEnabler Optional;
     cmCAEnabler NamelinkOnly;
     cmCAEnabler NamelinkSkip;
+    /**
+     * This boolean indicate that the destination
+     * has to be mangled in some way.
+     * Currently this only used for lib64 mangling on 64 bit Linux.
+     */
+    bool mangleLibDestination;
 
     std::string DestinationString;
     std::string PermissionsString;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index ea8cdfd..8d2891c 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3223,6 +3223,13 @@ void cmake::DefineProperties(cmake *cm)
      "directories called lib in the search path when building 64-bit "
      "binaries.");
   cm->DefineProperty
+  ("CMAKE_USE_LIB64_PATH", cmProperty::GLOBAL,
+   "Whether INSTALL(TARGETS command should use lib64 instead of lib.",
+   "CMAKE_USE_LIB64_PATH is a boolean specifying whether the "
+   "INSTALL(TARGETS ...) command should automatically mangle *lib/*"
+   "ARCHIVE or LIBRARY destination to *lib64/*. This is automatically"
+   "set by CMake on (non-Debian) Linux x86_64 distributions.");
+  cm->DefineProperty
     ("FIND_LIBRARY_USE_OPENBSD_VERSIONING", cmProperty::GLOBAL,
      "Whether FIND_LIBRARY should find OpenBSD-style shared libraries.",
      "This property is a boolean specifying whether the FIND_LIBRARY "

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

Summary of changes:
 Modules/Platform/Linux.cmake         |   24 +++++++++++++++++++++++-
 Modules/Platform/UnixPaths.cmake     |    4 ++++
 Source/cmInstallCommand.cxx          |    6 +++++-
 Source/cmInstallCommandArguments.cxx |   26 ++++++++++++++++++++++++++
 Source/cmInstallCommandArguments.h   |   17 +++++++++++++++++
 Source/cmake.cxx                     |    7 +++++++
 6 files changed, 82 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list