PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-2-7-rc1/bibletime/cmake/FindCLucene.cmake

#
CMake | 121 lines | 92 code | 14 blank | 15 comment | 1 complexity | 50e10482cb1b3c8b4c9106c9bd91f1bb MD5 | raw file
  1#
  2# SOURCE: http://websvn.kde.org/trunk/kdesupport/strigi/cmake/FindCLucene.cmake?view=log
  3#
  4# ONE FIX: /usr/lib64 added to work on Fedora
  5#
  6
  7
  8#
  9# This module looks for clucene (http://clucene.sf.net) support
 10# It will define the following values
 11#
 12# CLUCENE_INCLUDE_DIR  = where CLucene/StdHeader.h can be found
 13# CLUCENE_LIBRARY_DIR  = where CLucene/clucene-config.h can be found
 14# CLUCENE_LIBRARY      = the library to link against CLucene
 15# CLUCENE_VERSION      = The CLucene version string
 16# CLucene_FOUND        = set to 1 if clucene is found
 17#
 18
 19INCLUDE(CheckSymbolExists)
 20INCLUDE(FindLibraryWithDebug)
 21
 22if(NOT CLUCENE_MIN_VERSION)
 23	set(CLUCENE_MIN_VERSION "0.9.19")
 24endif(NOT CLUCENE_MIN_VERSION)
 25
 26IF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
 27	INCLUDE(${PROJECT_CMAKE}/CLuceneConfig.cmake)
 28ENDIF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
 29
 30IF(MSVC)
 31	IF(CMAKE_BUILD_TYPE STREQUAL "Release")
 32		SET(WIN_CLUCENE_SEARCH_PATH ../clucene-core/src/CLucene/Release)
 33	ELSE(CMAKE_BUILD_TYPE STREQUAL "Release")
 34		SET(WIN_CLUCENE_SEARCH_PATH ../clucene-core/src/CLucene/debug)
 35	ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
 36	SET(WIN_CLUCENE_INCLUDE_PATH ../clucene-core/src)
 37ELSE(MSVC)
 38	SET(WIN_CLUCENE_SEARCH_PATH "")
 39	SET(WIN_CLUCENE_INCLUDE_PATH "")
 40ENDIF(MSVC)
 41
 42SET(TRIAL_LIBRARY_PATHS
 43	$ENV{CLUCENE_HOME}/lib${LIB_SUFFIX}
 44	${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
 45	/usr/local/lib${LIB_SUFFIX}
 46	/opt/local/lib${LIB_SUFFIX}
 47	/usr/lib${LIB_SUFFIX}
 48	/usr/lib64
 49	/sw/lib${LIB_SUFFIX}
 50	/usr/pkg/lib${LIB_SUFFIX}
 51	${WIN_CLUCENE_SEARCH_PATH}
 52	)
 53SET(TRIAL_INCLUDE_PATHS
 54	$ENV{CLUCENE_HOME}/include
 55	${CMAKE_INSTALL_PREFIX}/include
 56	/usr/local/include
 57	/usr/include
 58	/sw/include
 59	/usr/pkg/include
 60	${WIN_CLUCENE_INCLUDE_PATH}
 61	)
 62FIND_LIBRARY_WITH_DEBUG(CLUCENE_LIBRARY
 63	NAMES clucene clucene-core
 64	PATHS ${TRIAL_LIBRARY_PATHS})
 65IF (CLUCENE_LIBRARY)
 66	MESSAGE(STATUS "Found CLucene library: ${CLUCENE_LIBRARY}")
 67ENDIF (CLUCENE_LIBRARY)
 68FIND_PATH(CLUCENE_INCLUDE_DIR
 69	NAMES CLucene.h
 70	PATHS ${TRIAL_INCLUDE_PATHS})
 71
 72IF (CLUCENE_INCLUDE_DIR)
 73	MESSAGE(STATUS "Found CLucene include dir: ${CLUCENE_INCLUDE_DIR}")
 74ENDIF (CLUCENE_INCLUDE_DIR)
 75
 76IF(WIN32)
 77	SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR})
 78ENDIF(WIN32)
 79
 80SET(CLUCENE_GOOD_VERSION TRUE)
 81
 82FIND_PATH(CLUCENE_LIBRARY_DIR
 83	NAMES CLucene/clucene-config.h PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH)
 84IF (CLUCENE_LIBRARY_DIR)
 85	MESSAGE(STATUS "Found CLucene library dir: ${CLUCENE_LIBRARY_DIR}")
 86	FILE(READ ${CLUCENE_LIBRARY_DIR}/CLucene/clucene-config.h CLCONTENT)
 87	STRING(REGEX MATCH "_CL_VERSION +\".*\"" CLMATCH ${CLCONTENT})
 88	IF (CLMATCH)
 89		STRING(REGEX REPLACE "_CL_VERSION +\"(.*)\"" "\\1" CLUCENE_VERSION ${CLMATCH})
 90	IF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
 91		MESSAGE(ERROR " CLucene version ${CLUCENE_VERSION} is less than the required minimum ${CLUCENE_MIN_VERSION}")
 92			SET(CLUCENE_GOOD_VERSION FALSE)
 93	ENDIF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
 94	IF (CLUCENE_VERSION STREQUAL "0.9.17")
 95		MESSAGE(ERROR "CLucene version 0.9.17 is not supported.")
 96			SET(CLUCENE_GOOD_VERSION FALSE)
 97	ENDIF (CLUCENE_VERSION STREQUAL "0.9.17")
 98	ENDIF (CLMATCH)
 99ELSE (CLUCENE_LIBRARY_DIR)
100	MESSAGE(STATUS "CLucene library dir not found.")
101ENDIF (CLUCENE_LIBRARY_DIR)
102
103IF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
104	SET(CLucene_FOUND TRUE)
105ENDIF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
106
107IF(CLucene_FOUND)
108	IF(NOT CLucene_FIND_QUIETLY)
109		MESSAGE(STATUS "Found CLucene: ${CLUCENE_LIBRARY}")
110	ENDIF(NOT CLucene_FIND_QUIETLY)
111ELSE(CLucene_FOUND)
112	IF(CLucene_FIND_REQUIRED)
113		MESSAGE(FATAL_ERROR "Could not find CLucene.")
114	ENDIF(CLucene_FIND_REQUIRED)
115ENDIF(CLucene_FOUND)
116
117MARK_AS_ADVANCED(
118	CLUCENE_INCLUDE_DIR
119	CLUCENE_LIBRARY_DIR
120	CLUCENE_LIBRARY
121	)