patch from Uncle_Entity on IRC for fedora/collada
authorCampbell Barton <ideasman42@gmail.com>
Thu, 8 Sep 2011 03:57:11 +0000 (03:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 8 Sep 2011 03:57:11 +0000 (03:57 +0000)
CMakeLists.txt
build_files/cmake/Modules/FindOpenCOLLADA.cmake
build_files/cmake/Modules/FindPCRE.cmake [new file with mode: 0644]
build_files/cmake/Modules/FindXML2.cmake [new file with mode: 0644]

index 8b5693f..ea89cbd 100644 (file)
@@ -452,15 +452,8 @@ if(UNIX AND NOT APPLE)
        if(WITH_OPENCOLLADA)
                find_package(OpenCOLLADA)
                if(OPENCOLLADA_FOUND)
-                       set(PCRE /usr CACHE PATH "PCRE Directory")
-                       mark_as_advanced(PCRE)
-                       set(PCRE_LIBPATH ${PCRE}/lib)
-                       set(PCRE_LIB pcre)
-
-                       set(EXPAT /usr CACHE PATH "Expat Directory")
-                       mark_as_advanced(EXPAT)
-                       set(EXPAT_LIBPATH ${EXPAT}/lib)
-                       set(EXPAT_LIB expat)
+                       find_package(XML2)
+                       find_package(PCRE)
                else()
                        set(WITH_OPENCOLLADA OFF)
                endif()
index c763728..a9a1d54 100644 (file)
@@ -49,12 +49,14 @@ SET(_opencollada_FIND_COMPONENTS
   OpenCOLLADAFramework
   OpenCOLLADABaseUtils
   GeneratedSaxParser
-  UTF
   MathMLSolver
-  pcre
+)
+
+# Fedora openCOLLADA package links these statically
+SET(_opencollada_FIND_STATIC_COMPONENTS
+  UTF
   ftoa
   buffer
-  xml2
 )
 
 SET(_opencollada_SEARCH_DIRS
@@ -104,6 +106,25 @@ FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
   LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
 ENDFOREACH()
 
+FOREACH(COMPONENT ${_opencollada_FIND_STATIC_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+
+  FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
+    NAMES
+      ${COMPONENT}
+    HINTS
+      ${_opencollada_SEARCH_DIRS}
+    PATH_SUFFIXES
+      lib64 lib
+      # Ubuntu ppa needs this.
+      lib64/opencollada lib/opencollada
+    )
+  IF(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
+    MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
+    LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
+  ENDIF()
+ENDFOREACH()
+
 
 # handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/build_files/cmake/Modules/FindPCRE.cmake b/build_files/cmake/Modules/FindPCRE.cmake
new file mode 100644 (file)
index 0000000..a093752
--- /dev/null
@@ -0,0 +1,43 @@
+# - Try to find the PCRE regular expression library
+# Once done this will define
+#
+#  PCRE_FOUND - system has the PCRE library
+#  PCRE_INCLUDE_DIR - the PCRE include directory
+#  PCRE_LIBRARIES - The libraries needed to use PCRE
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+
+if (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
+  # Already in cache, be silent
+  set(PCRE_FIND_QUIETLY TRUE)
+endif (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
+       
+if (NOT WIN32)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  find_package(PkgConfig)
+  pkg_check_modules(PC_PCRE QUIET libpcre)
+  set(PCRE_DEFINITIONS ${PC_PCRE_CFLAGS_OTHER})
+endif (NOT WIN32)
+
+find_path(PCRE_INCLUDE_DIR pcre.h
+          HINTS ${PC_PCRE_INCLUDEDIR} ${PC_PCRE_INCLUDE_DIRS}
+          PATH_SUFFIXES pcre)
+
+find_library(PCRE_PCRE_LIBRARY NAMES pcre HINTS ${PC_PCRE_LIBDIR} ${PC_PCRE_LIBRARY_DIRS})
+
+find_library(PCRE_PCREPOSIX_LIBRARY NAMES pcreposix HINTS ${PC_PCRE_LIBDIR} ${PC_PCRE_LIBRARY_DIRS})
+
+include(FindPackageHandleStandardArgs)
+
+IF(NOT WIN32)
+        find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY PCRE_PCREPOSIX_LIBRARY )
+        mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCREPOSIX_LIBRARY PCRE_PCRE_LIBRARY)
+        set(PCRE_LIBRARIES ${PCRE_PCRE_LIBRARY} ${PCRE_PCREPOSIX_LIBRARY})
+ELSE()
+        find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY  )
+        set(PCRE_LIBRARIES ${PCRE_PCRE_LIBRARY} )
+        mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCRE_LIBRARY)
+ENDIF()
diff --git a/build_files/cmake/Modules/FindXML2.cmake b/build_files/cmake/Modules/FindXML2.cmake
new file mode 100644 (file)
index 0000000..e9f9fb3
--- /dev/null
@@ -0,0 +1,88 @@
+# - Try to find XML2
+# Once done this will define
+#
+#  XML2_FOUND - system has XML2
+#  XML2_INCLUDE_DIRS - the XML2 include directory
+#  XML2_LIBRARIES - Link these to use XML2
+#  XML2_DEFINITIONS - Compiler switches required for using XML2
+#
+#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#
+
+
+if (XML2_LIBRARIES AND XML2_INCLUDE_DIRS)
+  # in cache already
+  set(XML2_FOUND TRUE)
+else (XML2_LIBRARIES AND XML2_INCLUDE_DIRS)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+    include(UsePkgConfig)
+    pkgconfig(libxml-2.0 _XML2_INCLUDEDIR _XML2_LIBDIR _XML2_LDFLAGS _XML2_CFLAGS)
+  else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+    find_package(PkgConfig)
+    if (PKG_CONFIG_FOUND)
+      pkg_check_modules(_XML2 libxml-2.0)
+    endif (PKG_CONFIG_FOUND)
+  endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+  find_path(XML2_INCLUDE_DIR
+    NAMES
+      libxml/xpath.h
+    PATHS
+      ${_XML2_INCLUDEDIR}
+      /usr/include
+      /usr/local/include
+      /opt/local/include
+      /sw/include
+    PATH_SUFFIXES
+      libxml2
+  )
+
+  find_library(XML2_LIBRARY
+    NAMES
+      xml2
+    PATHS
+      ${_XML2_LIBDIR}
+      /usr/lib
+      /usr/local/lib
+      /opt/local/lib
+      /sw/lib
+  )
+
+  if (XML2_LIBRARY)
+    set(XML2_FOUND TRUE)
+  endif (XML2_LIBRARY)
+
+  set(XML2_INCLUDE_DIRS
+    ${XML2_INCLUDE_DIR}
+  )
+
+  if (XML2_FOUND)
+    set(XML2_LIBRARIES
+      ${XML2_LIBRARIES}
+      ${XML2_LIBRARY}
+    )
+  endif (XML2_FOUND)
+
+  if (XML2_INCLUDE_DIRS AND XML2_LIBRARIES)
+     set(XML2_FOUND TRUE)
+  endif (XML2_INCLUDE_DIRS AND XML2_LIBRARIES)
+
+  if (XML2_FOUND)
+    if (NOT XML2_FIND_QUIETLY)
+      message(STATUS "Found XML2: ${XML2_LIBRARIES}")
+    endif (NOT XML2_FIND_QUIETLY)
+  else (XML2_FOUND)
+    if (XML2_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find XML2")
+    endif (XML2_FIND_REQUIRED)
+  endif (XML2_FOUND)
+
+  # show the XML2_INCLUDE_DIRS and XML2_LIBRARIES variables only in the advanced view
+  mark_as_advanced(XML2_INCLUDE_DIRS XML2_LIBRARIES)
+
+endif (XML2_LIBRARIES AND XML2_INCLUDE_DIRS)
+