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

/CMakeModules/FindCLucene.cmake

Relevant Search: With Applications for Solr and Elasticsearch

For more in depth reading about search, ranking and generally everything you could ever want to know about how lucene, elasticsearch or solr work under the hood I highly suggest this book. Easily one of the most interesting technical books I have read in a long time. If you are tasked with solving search relevance problems even if not in Solr or Elasticsearch it should be your first reference. Amazon Affiliate Link
http://github.com/tomahawk-player/tomahawk
CMake | 131 lines | 101 code | 15 blank | 15 comment | 0 complexity | 3f5b77a9e2abf01e5c735a63583984c4 MD5 | raw file
  1#
  2# This module looks for clucene (http://clucene.sf.net) support
  3# It will define the following values
  4#
  5# CLUCENE_INCLUDE_DIRS = CLUCENE_INCLUDE_DIR + CLUCENE_LIBRARY_DIR
  6# CLUCENE_INCLUDE_DIR  = where CLucene/StdHeader.h can be found
  7# CLUCENE_LIBRARY_DIR  = where CLucene/clucene-config.h can be found
  8# CLUCENE_LIBRARIES    = the libraries to link against CLucene
  9# CLUCENE_VERSION      = The CLucene version string
 10# CLucene_FOUND        = set to 1 if clucene is found
 11#
 12
 13INCLUDE(CheckSymbolExists)
 14INCLUDE(FindLibraryWithDebug)
 15
 16# try to locate a patched unstable version (for comp's sake *sigh*) first
 17FIND_PACKAGE(CLuceneUnstable QUIET)
 18IF(CLUCENEUNSTABLE_FOUND)
 19    SET(CLucene_FOUND TRUE)
 20    SET(CLUCENE_INCLUDE_DIR ${CLUCENE_UNSTABLE_INCLUDE_DIRS})
 21    SET(CLUCENE_INCLUDE_DIRS ${CLUCENE_INCLUDE_DIR})
 22    SET(CLUCENE_LIBRARIES ${CLUCENE_UNSTABLE_LIBS})
 23
 24    #MESSAGE(FATAL_ERROR NARF)
 25ELSE(CLUCENEUNSTABLE_FOUND)
 26IF(CLucene_FIND_VERSION)
 27  SET(CLUCENE_MIN_VERSION ${CLucene_FIND_VERSION})
 28ELSEIF()
 29  SET(CLUCENE_MIN_VERSION "0.9.23")
 30ENDIF(CLucene_FIND_VERSION)
 31
 32IF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
 33  INCLUDE(${PROJECT_CMAKE}/CLuceneConfig.cmake)
 34ENDIF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
 35
 36SET(TRIAL_LIBRARY_PATHS
 37  $ENV{CLUCENE_HOME}/lib${LIB_SUFFIX}
 38  ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
 39  /usr/local/lib${LIB_SUFFIX}
 40  /usr/lib${LIB_SUFFIX}
 41  /sw/lib${LIB_SUFFIX}
 42  /usr/pkg/lib${LIB_SUFFIX}
 43  /usr/lib64
 44  )
 45SET(TRIAL_INCLUDE_PATHS
 46  $ENV{CLUCENE_HOME}/include
 47  ${CMAKE_INSTALL_PREFIX}/include
 48  /usr/local/include
 49  /usr/include
 50  /sw/include
 51  /usr/pkg/include
 52  )
 53FIND_LIBRARY_WITH_DEBUG(CLUCENE_CORE_LIBRARY
 54  WIN32_DEBUG_POSTFIX d
 55  NAMES clucene-core
 56  PATHS ${TRIAL_LIBRARY_PATHS})
 57IF (CLUCENE_CORE_LIBRARY)
 58  MESSAGE(STATUS "Found CLucene core library: ${CLUCENE_CORE_LIBRARY}")
 59ENDIF (CLUCENE_CORE_LIBRARY)
 60FIND_LIBRARY_WITH_DEBUG(CLUCENE_SHARED_LIBRARY
 61  WIN32_DEBUG_POSTFIX d
 62  NAMES clucene-shared
 63  PATHS ${TRIAL_LIBRARY_PATHS})
 64IF (CLUCENE_SHARED_LIBRARY)
 65  MESSAGE(STATUS "Found CLucene shared library: ${CLUCENE_SHARED_LIBRARY}")
 66ENDIF (CLUCENE_SHARED_LIBRARY)
 67
 68IF(CLUCENE_CORE_LIBRARY AND CLUCENE_SHARED_LIBRARY)
 69  SET(CLUCENE_LIBRARIES ${CLUCENE_CORE_LIBRARY} ${CLUCENE_SHARED_LIBRARY})
 70ENDIF(CLUCENE_CORE_LIBRARY AND CLUCENE_SHARED_LIBRARY)
 71
 72FIND_PATH(CLUCENE_INCLUDE_DIR
 73  NAMES CLucene.h
 74  PATHS ${TRIAL_INCLUDE_PATHS})
 75
 76IF (CLUCENE_INCLUDE_DIR)
 77  MESSAGE(STATUS "Found CLucene include dir: ${CLUCENE_INCLUDE_DIR}")
 78ENDIF (CLUCENE_INCLUDE_DIR)
 79
 80IF(WIN32)
 81  SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR})
 82ENDIF(WIN32)
 83
 84SET(CLUCENE_GOOD_VERSION TRUE)
 85
 86FIND_PATH(CLUCENE_LIBRARY_DIR
 87	NAMES CLuceneConfig.cmake/CLuceneConfig.cmake CLucene/CLuceneConfig.cmake
 88       	PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH)
 89IF (CLUCENE_LIBRARY_DIR)
 90  MESSAGE(STATUS "Found CLucene library dir: ${CLUCENE_LIBRARY_DIR}")
 91  # include CLuceneConfig/CLuceneConfig.cmake
 92  IF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake)
 93        INCLUDE(${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake)
 94  ENDIF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake)
 95  # include CLucene/CLuceneConfig.cmake
 96  IF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake)
 97        INCLUDE(${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake)
 98  ENDIF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake)
 99  IF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
100    MESSAGE(ERROR " CLucene version ${CLUCENE_VERSION} is less than the required minimum ${CLUCENE_MIN_VERSION}")
101    SET(CLUCENE_GOOD_VERSION FALSE)
102  ENDIF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}")
103  IF (CLUCENE_VERSION STREQUAL "0.9.17")
104    MESSAGE(ERROR "CLucene version 0.9.17 is not supported.")
105    SET(CLUCENE_GOOD_VERSION FALSE)
106  ENDIF (CLUCENE_VERSION STREQUAL "0.9.17")
107ENDIF (CLUCENE_LIBRARY_DIR)
108
109IF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARIES AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
110  SET(CLucene_FOUND TRUE)
111  SET(CLUCENE_INCLUDE_DIRS ${CLUCENE_LIBRARY_DIR} ${CLUCENE_INCLUDE_DIR})
112ENDIF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARIES AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
113
114ENDIF(CLUCENEUNSTABLE_FOUND)
115
116IF(CLucene_FOUND)
117  IF(NOT CLucene_FIND_QUIETLY)
118    MESSAGE(STATUS "Found CLucene: ${CLUCENE_LIBRARIES} version ${CLUCENE_VERSION}")
119  ENDIF(NOT CLucene_FIND_QUIETLY)
120ELSE(CLucene_FOUND)
121  IF(CLucene_FIND_REQUIRED)
122    MESSAGE(FATAL_ERROR "Could not find CLucene.")
123  ENDIF(CLucene_FIND_REQUIRED)
124ENDIF(CLucene_FOUND)
125
126MARK_AS_ADVANCED(
127  CLUCENE_INCLUDE_DIRS
128  CLUCENE_INCLUDE_DIR
129  CLUCENE_LIBRARY_DIR
130  CLUCENE_LIBRARIES
131  )