naspro
view naspro-bridges-bad/cmake/FindRedland.cmake @ 174:4f7243a606b1
Updated copyright notices and build system
| author | Stefano D'Angelo <zanga.mail@gmail.com> |
|---|---|
| date | Sat May 01 21:51:33 2010 +0300 (2010-05-01) |
| parents | |
| children |
line source
1 # - Try to find the Redland rdf libraries (http://librdf.org/)
2 # Once done this will define
3 #
4 # REDLAND_FOUND - system has Redland
5 # REDLAND_LIBRARIES - Link these to use REDLAND
6 # REDLAND_INCLUDE_DIR - Include directory for using the redland library
7 # REDLAND_VERSION - The redland version string
8 #
9 # Specifying the minimum required version via the find_package() interface
10 # is also supported by this module.
12 # Always empty, so remove it from the docs for now, Alex
13 # REDLAND_DEFINITIONS - Compiler switches required for using REDLAND
15 # (c) 2007-2009 Sebastian Trueg <trueg@kde.org>
16 #
17 # Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
18 #
19 # Redistribution and use is allowed according to the terms of the BSD license.
20 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
23 find_program(
24 REDLAND_CONFIG_EXECUTABLE
25 NAMES redland-config
26 )
28 if(REDLAND_CONFIG_EXECUTABLE)
29 EXECUTE_PROCESS(
30 COMMAND ${REDLAND_CONFIG_EXECUTABLE} --version
31 OUTPUT_VARIABLE REDLAND_VERSION
32 OUTPUT_STRIP_TRAILING_WHITESPACE
33 )
34 if(REDLAND_VERSION)
36 # extract include paths from redland-config
37 execute_process(
38 COMMAND ${REDLAND_CONFIG_EXECUTABLE} --cflags
39 OUTPUT_VARIABLE redland_LIBS_ARGS)
40 string( REPLACE " " ";" redland_LIBS_ARGS ${redland_LIBS_ARGS} )
41 foreach( _ARG ${redland_LIBS_ARGS} )
42 if(${_ARG} MATCHES "^-I")
43 string(REGEX REPLACE "^-I" "" _ARG ${_ARG})
44 string( REPLACE "\n" "" _ARG ${_ARG} )
45 list(APPEND redland_INCLUDE_DIRS ${_ARG})
46 endif(${_ARG} MATCHES "^-I")
47 endforeach(_ARG)
49 # extract lib paths from redland-config
50 execute_process(
51 COMMAND ${REDLAND_CONFIG_EXECUTABLE} --libs
52 OUTPUT_VARIABLE redland_CFLAGS_ARGS)
53 string( REPLACE " " ";" redland_CFLAGS_ARGS ${redland_CFLAGS_ARGS} )
54 foreach( _ARG ${redland_CFLAGS_ARGS} )
55 if(${_ARG} MATCHES "^-L")
56 string(REGEX REPLACE "^-L" "" _ARG ${_ARG})
57 list(APPEND redland_LIBRARY_DIRS ${_ARG})
58 endif(${_ARG} MATCHES "^-L")
59 endforeach(_ARG)
60 endif(REDLAND_VERSION)
61 endif(REDLAND_CONFIG_EXECUTABLE)
63 # This one is always empty, Alex
64 # set(REDLAND_DEFINITIONS ${redland_CFLAGS})
67 find_path(REDLAND_INCLUDE_DIR redland.h
68 HINTS
69 ${redland_INCLUDE_DIRS}
70 /usr/X11/include
71 PATH_SUFFIXES redland
72 )
74 find_library(REDLAND_LIBRARIES NAMES rdf librdf
75 HINTS
76 ${redland_LIBRARY_DIRS}
77 )
79 set(_REDLAND_VERSION_OK TRUE)
80 if(NOT WIN32)
82 # Look for unresolved symbols in shared librdf_storage_* libs
83 set(_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
84 set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
85 set(_REDLAND_STORAGE_LIBS)
86 foreach(_STORAGE_LIB rdf_storage_mysql rdf_storage_sqlite rdf_storage_tstore rdf_storage_postgresql rdf_storage_virtuoso)
87 set(_LIB_PATH NOTFOUND)
88 find_library(_LIB_PATH
89 ${_STORAGE_LIB}
90 HINTS
91 ${redland_LIBRARY_DIRS}
92 PATH_SUFFIXES redland
93 )
94 if(_LIB_PATH)
95 set(_REDLAND_STORAGE_LIBS ${_REDLAND_STORAGE_LIBS} ${_LIB_PATH})
96 endif(_LIB_PATH)
97 endforeach(_STORAGE_LIB)
98 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_SUFFIXES})
99 if(_REDLAND_STORAGE_LIBS)
100 message(STATUS "Found Redland storage: ${_REDLAND_STORAGE_LIBS}")
101 try_run(_TEST_EXITCODE _TEST_COMPILED
102 "${CMAKE_CURRENT_BINARY_DIR}"
103 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CheckLibraryLoads.c"
104 CMAKE_FLAGS "-DLINK_LIBRARIES=dl"
105 RUN_OUTPUT_VARIABLE _OUTPUT
106 ARGS ${_REDLAND_STORAGE_LIBS}
107 )
108 if(NOT "${_TEST_EXITCODE}" EQUAL 0)
109 set(_REDLAND_VERSION_OK)
110 message(STATUS "${_OUTPUT}")
111 message(STATUS "Redland with broken NEEDED section detected, disabling")
112 endif(NOT "${_TEST_EXITCODE}" EQUAL 0)
113 endif(_REDLAND_STORAGE_LIBS)
115 endif(NOT WIN32)
117 include(FindPackageHandleStandardArgs)
118 find_package_handle_standard_args(Redland DEFAULT_MSG REDLAND_CONFIG_EXECUTABLE REDLAND_LIBRARIES REDLAND_LIBRARIES _REDLAND_VERSION_OK)
120 mark_as_advanced(REDLAND_INCLUDE_DIR_TMP
121 REDLAND_INCLUDE_DIR
122 REDLAND_LIBRARIES)
