Author: aconway
Date: Wed Aug 27 13:23:21 2014
New Revision: 1620888

URL: http://svn.apache.org/r1620888
Log:
NO-JIRA: Work-around bug in older cmake, finds static python library instead of 
shared.

FindPythonLibs on older versions of cmake (observed on cmake-2.6.4-5.el5.4)
sometimes finds the static archive library (.a) before the shared object
library (.so) This is almost never what you want. Newer
versions (e.g. cmake-2.8.12.2-2.fc20.x86_64) explicitly look for the .so first
and look for the .a library second.

This workaround fixes the problem as follows:
- It is a no-op except on Unix platforms that use the .so prefix.
- On those platforms it does a search for .so only first.
- Finally we do a default search for other platforms (or if .so was not found)

Modified:
    qpid/trunk/qpid/cpp/bindings/CMakeLists.txt

Modified: qpid/trunk/qpid/cpp/bindings/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/CMakeLists.txt?rev=1620888&r1=1620887&r2=1620888&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/bindings/CMakeLists.txt Wed Aug 27 13:23:21 2014
@@ -17,14 +17,37 @@
 # under the License.
 #
 
+# Work-around for bug in older versions of cmake where find_package(PythonLib)
+# finds the static .a library before the the dynamic .so one on Unix.
+# Force search for .so first (this is exactly what newer versions of cmake do.)
+#
+# NOTE: Must be a macro, not a function. find_package in a function sets
+# the package found variables in the function scope, not the parent scope.
+#
+macro(find_python_libs)
+  # Only do this on unix-like systems that use the .so library suffix.
+  if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES MATCHES "\\.so")
+    set(SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) # Save the suffixes.
+    # Look just for shared libraries.
+    set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
+    find_package(PythonLibs)
+    # Restore the suffixes
+    set(CMAKE_FIND_LIBRARY_SUFFIXES ${SUFFIXES})
+  endif()
+  # If we are not on a Unix/.so platform or we didn't find the library with 
the .so search
+  # then do a plain search
+  if (NOT PYTHONLIBS_FOUND)
+    find_package(PythonLibs)
+  endif()
+endmacro(find_python_libs)
 
-find_package(SWIG)
 
+find_package(SWIG)
 if (SWIG_FOUND)
 
   include(UseSWIG)
   find_package(Ruby)
-  find_package(PythonLibs)
+  find_python_libs()
   find_package(PerlLibs)
 
   if ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8))



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to