opencollada find module. hopefully solves the problem where includes can in an `...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 24 Aug 2011 16:04:35 +0000 (16:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 24 Aug 2011 16:04:35 +0000 (16:04 +0000)
CMakeLists.txt
build_files/cmake/Modules/FindOpenCOLLADA.cmake [new file with mode: 0644]
source/blender/collada/CMakeLists.txt

index 6b84531..366383d 100644 (file)
@@ -450,21 +450,20 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENCOLLADA)
-               set(OPENCOLLADA /usr/local/opencollada CACHE PATH "OpenCollada Directory")
-               mark_as_advanced(OPENCOLLADA)
-               set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
-               set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
-               set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA})
-
-               set(PCRE /usr CACHE PATH "PCRE Directory")
-               mark_as_advanced(PCRE)
-               set(PCRE_LIBPATH ${PCRE}/lib)
-               set(PCRE_LIB pcre)
+               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)
+                       set(EXPAT /usr CACHE PATH "Expat Directory")
+                       mark_as_advanced(EXPAT)
+                       set(EXPAT_LIBPATH ${EXPAT}/lib)
+                       set(EXPAT_LIB expat)
+               else()
+                       set(WITH_OPENCOLLADA OFF)
+               endif()
        endif()
 
        if(WITH_MEM_JEMALLOC)
@@ -689,9 +688,15 @@ elseif(WIN32)
                endif()
 
                if(WITH_OPENCOLLADA)
-                       set(OPENCOLLADA_INCLUDE_DIR
-                               ${LIBDIR}/opencollada/include
+
+                       set(OPENCOLLADA_INCLUDE_DIRS
+                               ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
+                               ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
+                               ${LIBDIR}/opencollada/include/COLLADAFramework/include
+                               ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
+                               ${LIBDIR}/opencollada/include/GeneratedSaxParser/include                        
                        )
+
                        set(OPENCOLLADA_LIBRARIES
                                ${LIBDIR}/opencollada/lib/OpenCOLLADASaxFrameworkLoader.lib
                                ${LIBDIR}/opencollada/lib/OpenCOLLADAFramework.lib
@@ -837,7 +842,13 @@ elseif(WIN32)
 
                if(WITH_OPENCOLLADA)
                        set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
-                       set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
+                       set(OPENCOLLADA_INCLUDE_DIRS
+                               ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
+                               ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
+                               ${LIBDIR}/opencollada/include/COLLADAFramework/include
+                               ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
+                               ${LIBDIR}/opencollada/include/GeneratedSaxParser/include                        
+                       )
                        set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
                        set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
                        set(PCRE_LIB pcre)
@@ -1048,7 +1059,15 @@ elseif(APPLE)
 
        if(WITH_OPENCOLLADA)
                set(OPENCOLLADA ${LIBDIR}/opencollada)
-               set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
+
+               set(OPENCOLLADA_INCLUDE_DIRS
+                       ${LIBDIR}/opencollada/include/COLLADAStreamWriter
+                       ${LIBDIR}/opencollada/include/COLLADABaseUtils
+                       ${LIBDIR}/opencollada/include/COLLADAFramework
+                       ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
+                       ${LIBDIR}/opencollada/include/GeneratedSaxParser
+               )
+
                set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
                set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
                #pcre is bundled with openCollada
diff --git a/build_files/cmake/Modules/FindOpenCOLLADA.cmake b/build_files/cmake/Modules/FindOpenCOLLADA.cmake
new file mode 100644 (file)
index 0000000..eef2049
--- /dev/null
@@ -0,0 +1,123 @@
+# - Find OpenCOLLADA library
+# Find the native OpenCOLLADA includes and library
+# This module defines
+#  OPENCOLLADA_INCLUDE_DIRS, where to find COLLADABaseUtils/ and 
+#                 COLLADAFramework/, Set when OPENCOLLADA_INCLUDE_DIR is found.
+#  OPENCOLLADA_LIBRARIES, libraries to link against to use OpenCOLLADA.
+#  OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
+#                    This can also be an environment variable.
+#  OPENCOLLADA_FOUND, If false, do not try to use OpenCOLLADA.
+#
+# also defined, but not for general use are
+#  OPENCOLLADA_LIBRARY, where to find the OpenCOLLADA library.
+
+#=============================================================================
+# Copyright 2011 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# note about include paths, there are 2 ways includes are set
+#
+# Where '/usr/include/opencollada' is the root dir:
+#   /usr/include/opencollada/COLLADABaseUtils/COLLADABUPlatform.h
+#
+# Where '/opt/opencollada' is the base dir:
+# /opt/opencollada/COLLADABaseUtils/include/COLLADABUPlatform.h
+
+# If OPENCOLLADA_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENCOLLADA_ROOT_DIR AND NOT $ENV{OPENCOLLADA_ROOT_DIR} STREQUAL "")
+  SET(OPENCOLLADA_ROOT_DIR $ENV{OPENCOLLADA_ROOT_DIR})
+ENDIF()
+
+SET(_opencollada_FIND_INCLUDES
+  COLLADAStreamWriter
+  COLLADABaseUtils
+  COLLADAFramework
+  COLLADASaxFrameworkLoader
+  GeneratedSaxParser
+)
+
+SET(_opencollada_FIND_COMPONENTS
+  OpenCOLLADAStreamWriter
+  OpenCOLLADASaxFrameworkLoader
+  OpenCOLLADAFramework
+  OpenCOLLADABaseUtils
+  GeneratedSaxParser
+  UTF
+  MathMLSolver
+  pcre
+  ftoa
+  buffer
+  xml2
+)
+
+SET(_opencollada_SEARCH_DIRS
+  ${OPENCOLLADA_ROOT_DIR}
+  /usr/local
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+)
+
+SET(_opencollada_INCLUDES)
+FOREACH(COMPONENT ${_opencollada_FIND_INCLUDES})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+
+  # need to use this even thouh we are looking for a dir
+  FIND_FILE(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR
+    NAMES
+      ${COMPONENT}/include
+      ${COMPONENT}
+    HINTS
+      # some packagers do this.
+      ${OPENCOLLADA_ROOT_DIR}/include/opencollada
+      ${_opencollada_SEARCH_DIRS}
+    )
+  MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR)
+  LIST(APPEND _opencollada_INCLUDES "${OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR}")
+ENDFOREACH()
+
+
+SET(_opencollada_LIBRARIES)
+FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+
+  FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
+    NAMES
+      ${COMPONENT}
+    HINTS
+      ${_opencollada_SEARCH_DIRS}
+    PATH_SUFFIXES
+      lib64 lib
+    )
+  MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
+  LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
+ENDFOREACH()
+
+
+FIND_LIBRARY(OPENCOLLADA_LIBRARY
+  NAMES
+    jack
+  HINTS
+    ${_opencollada_SEARCH_DIRS}
+  PATH_SUFFIXES
+    lib64 lib
+  )
+
+# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA  DEFAULT_MSG
+    _opencollada_LIBRARIES _opencollada_INCLUDES)
+
+
+IF(OPENCOLLADA_FOUND)
+  SET(OPENCOLLADA_LIBRARIES ${_opencollada_LIBRARIES})
+  SET(OPENCOLLADA_INCLUDE_DIRS ${_opencollada_INCLUDES})
+ENDIF(OPENCOLLADA_FOUND)
index b5c84bc..3466c3a 100644 (file)
@@ -39,27 +39,9 @@ set(INC
 )
 
 set(INC_SYS
-
+       ${OPENCOLLADA_INCLUDE_DIRS}
 )
 
-if(APPLE)
-       list(APPEND INC_SYS
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader
-               ${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser
-       )
-else()
-       list(APPEND INC_SYS
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter/include
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils/include
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework/include
-               ${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader/include
-               ${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser/include
-       )
-endif()
-
 set(SRC
        AnimationImporter.cpp
        ArmatureExporter.cpp