add more spacing
[personal-kdebase.git] / runtime / cmake / modules / FindCLucene.cmake
blobb7c0e862bce57d6d461c7e900f4e67fb6337e4a9
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}
27   /usr/lib${LIB_SUFFIX}
28   /sw/lib${LIB_SUFFIX}
29   /usr/pkg/lib${LIB_SUFFIX}
30   )
31 SET(TRIAL_INCLUDE_PATHS
32   $ENV{CLUCENE_HOME}/include
33   ${CMAKE_INSTALL_PREFIX}/include
34   /usr/local/include
35   /usr/include
36   /sw/include
37   /usr/pkg/include
38   )
39 FIND_LIBRARY_WITH_DEBUG(CLUCENE_LIBRARY
40   WIN32_DEBUG_POSTFIX d
41   NAMES clucene clucene-core
42   PATHS ${TRIAL_LIBRARY_PATHS})
43 IF (CLUCENE_LIBRARY)
44   MESSAGE(STATUS "Found CLucene library: ${CLUCENE_LIBRARY}")
45 ENDIF (CLUCENE_LIBRARY)
46 FIND_PATH(CLUCENE_INCLUDE_DIR
47   NAMES CLucene.h
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)
54 IF(WIN32)
55   SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR})
56 ENDIF(WIN32)
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})
66   IF (CLMATCH)
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")
76   ENDIF (CLMATCH)
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)
83 IF(CLucene_FOUND)
84   IF(NOT CLucene_FIND_QUIETLY)
85     MESSAGE(STATUS "Found CLucene: ${CLUCENE_LIBRARY} version ${CLUCENE_VERSION}")
86   ENDIF(NOT CLucene_FIND_QUIETLY)
87 ELSE(CLucene_FOUND)
88   IF(CLucene_FIND_REQUIRED)
89     MESSAGE(FATAL_ERROR "Could not find CLucene.")
90   ENDIF(CLucene_FIND_REQUIRED)
91 ENDIF(CLucene_FOUND)
93 MARK_AS_ADVANCED(
94   CLUCENE_INCLUDE_DIR 
95   CLUCENE_LIBRARY_DIR 
96   CLUCENE_LIBRARY 
97   )