From c61827ed255432637a335dcff12745c156f619fb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Sep 2011 03:57:11 +0000 Subject: patch from Uncle_Entity on IRC for fedora/collada --- build_files/cmake/Modules/FindOpenCOLLADA.cmake | 27 +++++++- build_files/cmake/Modules/FindPCRE.cmake | 43 ++++++++++++ build_files/cmake/Modules/FindXML2.cmake | 88 +++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 build_files/cmake/Modules/FindPCRE.cmake create mode 100644 build_files/cmake/Modules/FindXML2.cmake (limited to 'build_files') diff --git a/build_files/cmake/Modules/FindOpenCOLLADA.cmake b/build_files/cmake/Modules/FindOpenCOLLADA.cmake index c7637283514..a9a1d544507 100644 --- a/build_files/cmake/Modules/FindOpenCOLLADA.cmake +++ b/build_files/cmake/Modules/FindOpenCOLLADA.cmake @@ -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 index 00000000000..a09375287a6 --- /dev/null +++ b/build_files/cmake/Modules/FindPCRE.cmake @@ -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, +# +# 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 index 00000000000..e9f9fb3ca74 --- /dev/null +++ b/build_files/cmake/Modules/FindXML2.cmake @@ -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 +# +# 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) + -- cgit v1.2.3