2 # This module looks for clucene (http://clucene.sf.net) support
3 # It will define the following values
5 # CLUCENE_INCLUDE_DIR = where CLucene/StdHeader.h can be found
6 # CLUCENE_LIBRARY_DIR = where CLucene/clucene-config.h can be found
7 # CLUCENE_LIBRARY = the library to link against CLucene
8 # CLUCENE_VERSION = The CLucene version string
9 # CLucene_FOUND = set to 1 if clucene is found
12 INCLUDE(CheckSymbolExists)
13 INCLUDE(FindLibraryWithDebug)
15 if(NOT CLUCENE_MIN_VERSION)
16 set(CLUCENE_MIN_VERSION "0.9.19")
17 endif(NOT CLUCENE_MIN_VERSION)
19 IF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
20 INCLUDE(${PROJECT_CMAKE}/CLuceneConfig.cmake)
21 ENDIF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
23 SET(TRIAL_LIBRARY_PATHS
24 $ENV{CLUCENE_HOME}/lib${LIB_SUFFIX}
25 ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
26 /usr/local/lib${LIB_SUFFIX}
29 /usr/pkg/lib${LIB_SUFFIX}
31 SET(TRIAL_INCLUDE_PATHS
32 $ENV{CLUCENE_HOME}/include
33 ${CMAKE_INSTALL_PREFIX}/include
39 FIND_LIBRARY_WITH_DEBUG(CLUCENE_LIBRARY
41 NAMES clucene clucene-core
42 PATHS ${TRIAL_LIBRARY_PATHS})
44 MESSAGE(STATUS "Found CLucene library: ${CLUCENE_LIBRARY}")
45 ENDIF (CLUCENE_LIBRARY)
46 FIND_PATH(CLUCENE_INCLUDE_DIR
48 PATHS ${TRIAL_INCLUDE_PATHS})
50 IF (CLUCENE_INCLUDE_DIR)
51 MESSAGE(STATUS "Found CLucene include dir: ${CLUCENE_INCLUDE_DIR}")
52 ENDIF (CLUCENE_INCLUDE_DIR)
55 SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR})
58 SET(CLUCENE_GOOD_VERSION TRUE)
60 FIND_PATH(CLUCENE_LIBRARY_DIR
61 NAMES CLucene/clucene-config.h PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH)
62 IF (CLUCENE_LIBRARY_DIR)
63 MESSAGE(STATUS "Found CLucene library dir: ${CLUCENE_LIBRARY_DIR}")
64 FILE(READ ${CLUCENE_LIBRARY_DIR}/CLucene/clucene-config.h CLCONTENT)
65 STRING(REGEX MATCH "_CL_VERSION +\".*\"" CLMATCH ${CLCONTENT})
67 STRING(REGEX REPLACE "_CL_VERSION +\"(.*)\"" "\\1" CLUCENE_VERSION ${CLMATCH})
68 IF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
69 MESSAGE(ERROR " CLucene version ${CLUCENE_VERSION} is less than the required minimum ${CLUCENE_MIN_VERSION}")
70 SET(CLUCENE_GOOD_VERSION FALSE)
71 ENDIF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
72 IF (CLUCENE_VERSION STREQUAL "0.9.17")
73 MESSAGE(ERROR "CLucene version 0.9.17 is not supported.")
74 SET(CLUCENE_GOOD_VERSION FALSE)
75 ENDIF (CLUCENE_VERSION STREQUAL "0.9.17")
77 ENDIF (CLUCENE_LIBRARY_DIR)
79 IF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
80 SET(CLucene_FOUND TRUE)
81 ENDIF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
84 IF(NOT CLucene_FIND_QUIETLY)
85 MESSAGE(STATUS "Found CLucene: ${CLUCENE_LIBRARY} version ${CLUCENE_VERSION}")
86 ENDIF(NOT CLucene_FIND_QUIETLY)
88 IF(CLucene_FIND_REQUIRED)
89 MESSAGE(FATAL_ERROR "Could not find CLucene.")
90 ENDIF(CLucene_FIND_REQUIRED)