forked from orocos-toolchain/rtt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply patch from Adolfo Rodriguez to fix Boost/Xerces detection and a…
…dd LibFindMacros
- Loading branch information
Peter Soetens
committed
Jun 3, 2009
1 parent
ba60963
commit aa071ef
Showing
5 changed files
with
181 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
################################################################################ | ||
# | ||
# CMake script for finding Xerces. | ||
# If the optional Xerces_ROOT_DIR environment variable exists, header files and | ||
# libraries will be searched in the Xerces_ROOT_DIR/include and Xerces_ROOT_DIR/libs | ||
# directories, respectively. Otherwise the default CMake search process will be | ||
# used. | ||
# | ||
# This script creates the following variables: | ||
# Xerces_FOUND: Boolean that indicates if the package was found | ||
# Xerces_INCLUDE_DIRS: Paths to the necessary header files | ||
# Xerces_LIBRARIES: Package libraries | ||
# | ||
################################################################################ | ||
|
||
include(LibFindMacros) | ||
|
||
# Get hint from environment variable (if any) | ||
if(NOT $ENV{Xerces_ROOT_DIR} STREQUAL "") | ||
set(Xerces_ROOT_DIR $ENV{Xerces_ROOT_DIR} CACHE PATH "Xerces base directory location (optional, used for nonstandard installation paths)" FORCE) | ||
mark_as_advanced(Xerces_ROOT_DIR) | ||
endif() | ||
|
||
# Header files to find | ||
set(header_NAME xercesc/dom/DOM.hpp) | ||
|
||
# Libraries to find | ||
set(xerces_c_NAME xerces-c) | ||
set(xerces_depdom_NAME xerces-depdom) | ||
|
||
# Find headers and libraries | ||
if(Xerces_ROOT_DIR) | ||
# Use location specified by environment variable | ||
find_path(Xerces_INCLUDE_DIR NAMES ${header_NAME} PATHS ${Xerces_ROOT_DIR}/include NO_DEFAULT_PATH) | ||
find_library(Xerces_c_LIBRARY NAMES ${xerces_c_NAME} PATHS ${Xerces_ROOT_DIR}/lib NO_DEFAULT_PATH) | ||
find_library(Xerces_depdom_LIBRARY NAMES ${xerces_depdom_NAME} PATHS ${Xerces_ROOT_DIR}/lib NO_DEFAULT_PATH) | ||
else() | ||
# Use default CMake search process | ||
find_path(Xerces_INCLUDE_DIR NAMES ${header_NAME}) | ||
find_library(Xerces_c_LIBRARY NAMES ${xerces_c_NAME}) | ||
find_library(Xerces_depdom_LIBRARY NAMES ${xerces_depdom_NAME}) | ||
endif() | ||
|
||
# Set the include dir variables and the libraries and let libfind_process do the rest. | ||
# NOTE: Singular variables for this library, plural for libraries this this lib depends on. | ||
set(Xerces_PROCESS_INCLUDES Xerces_INCLUDE_DIR) | ||
set(Xerces_PROCESS_LIBS Xerces_c_LIBRARY | ||
Xerces_depdom_LIBRARY) | ||
libfind_process(Xerces) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments | ||
# used for the current package. For this to work, the first parameter must be the | ||
# prefix of the current package, then the prefix of the new package etc, which are | ||
# passed to find_package. | ||
macro (libfind_package PREFIX) | ||
set (LIBFIND_PACKAGE_ARGS ${ARGN}) | ||
if (${PREFIX}_FIND_QUIETLY) | ||
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) | ||
endif (${PREFIX}_FIND_QUIETLY) | ||
if (${PREFIX}_FIND_REQUIRED) | ||
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) | ||
endif (${PREFIX}_FIND_REQUIRED) | ||
find_package(${LIBFIND_PACKAGE_ARGS}) | ||
endmacro (libfind_package) | ||
|
||
# Damn CMake developers made the UsePkgConfig system deprecated in the same release (2.6) | ||
# where they added pkg_check_modules. Consequently I need to support both in my scripts | ||
# to avoid those deprecated warnings. Here's a helper that does just that. | ||
# Works identically to pkg_check_modules, except that no checks are needed prior to use. | ||
macro (libfind_pkg_check_modules PREFIX PKGNAME) | ||
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
include(UsePkgConfig) | ||
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) | ||
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
find_package(PkgConfig) | ||
if (PKG_CONFIG_FOUND) | ||
pkg_check_modules(${PREFIX} ${PKGNAME}) | ||
endif (PKG_CONFIG_FOUND) | ||
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
endmacro (libfind_pkg_check_modules) | ||
|
||
# Do the final processing once the paths have been detected. | ||
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain | ||
# all the variables, each of which contain one include directory. | ||
# Ditto for ${PREFIX}_PROCESS_LIBS and library files. | ||
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. | ||
# Also handles errors in case library detection was required, etc. | ||
macro (libfind_process PREFIX) | ||
# Skip processing if already processed during this run | ||
if (NOT ${PREFIX}_FOUND) | ||
# Start with the assumption that the library was found | ||
set (${PREFIX}_FOUND TRUE) | ||
|
||
# Process all includes and set _FOUND to false if any are missing | ||
foreach (i ${${PREFIX}_PROCESS_INCLUDES}) | ||
if (${i}) | ||
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) | ||
mark_as_advanced(${i}) | ||
else (${i}) | ||
set (${PREFIX}_FOUND FALSE) | ||
endif (${i}) | ||
endforeach (i) | ||
|
||
# Process all libraries and set _FOUND to false if any are missing | ||
foreach (i ${${PREFIX}_PROCESS_LIBS}) | ||
if (${i}) | ||
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) | ||
mark_as_advanced(${i}) | ||
else (${i}) | ||
set (${PREFIX}_FOUND FALSE) | ||
endif (${i}) | ||
endforeach (i) | ||
|
||
# Print message and/or exit on fatal error | ||
if (${PREFIX}_FOUND) | ||
if (NOT ${PREFIX}_FIND_QUIETLY) | ||
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") | ||
endif (NOT ${PREFIX}_FIND_QUIETLY) | ||
else (${PREFIX}_FOUND) | ||
if (${PREFIX}_FIND_REQUIRED) | ||
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) | ||
message("${i}=${${i}}") | ||
endforeach (i) | ||
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use the ${PREFIX}_ROOT_DIR environment variable or ccmake to set the missing variables manually.") | ||
else (${PREFIX}_FIND_REQUIRED) # NOTE: else case not included in original file | ||
message (STATUS "Optional library ${PREFIX} NOT FOUND. If the library is already installed, use the ${PREFIX}_ROOT_DIR environment variable or ccmake to set the missing variables manually.") | ||
endif (${PREFIX}_FIND_REQUIRED) | ||
endif (${PREFIX}_FOUND) | ||
endif (NOT ${PREFIX}_FOUND) | ||
endmacro (libfind_process) | ||
|
||
macro(libfind_library PREFIX basename) | ||
set(TMP "") | ||
if(MSVC80) | ||
set(TMP -vc80) | ||
endif(MSVC80) | ||
if(MSVC90) | ||
set(TMP -vc90) | ||
endif(MSVC90) | ||
set(${PREFIX}_LIBNAMES ${basename}${TMP}) | ||
if(${ARGC} GREATER 2) | ||
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) | ||
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) | ||
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) | ||
endif(${ARGC} GREATER 2) | ||
find_library(${PREFIX}_LIBRARY | ||
NAMES ${${PREFIX}_LIBNAMES} | ||
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} | ||
) | ||
endmacro(libfind_library) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters