File: FindCLucene.cmake

package info (click to toggle)
sword 1.7.3+dfsg-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,584 kB
  • ctags: 5,515
  • sloc: cpp: 41,736; sh: 11,924; ansic: 6,447; objc: 1,362; makefile: 1,239; cs: 897; java: 821; perl: 784; pascal: 681; tcl: 350; xml: 180; python: 79
file content (123 lines) | stat: -rw-r--r-- 3,992 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# SOURCE: http://websvn.kde.org/trunk/kdesupport/strigi/cmake/FindCLucene.cmake?view=log
#
# ONE FIX: /usr/lib64 added to work on Fedora
#


#
# This module looks for clucene (http://clucene.sf.net) support
# It will define the following values
#
# CLUCENE_INCLUDE_DIR  = where CLucene/StdHeader.h can be found
# CLUCENE_LIBRARY_DIR  = where CLucene/clucene-config.h can be found
# CLUCENE_LIBRARY      = the library to link against CLucene
# CLUCENE_VERSION      = The CLucene version string
# CLucene_FOUND        = set to 1 if clucene is found
#

INCLUDE(CheckSymbolExists)
INCLUDE(FindLibraryWithDebug)

if(NOT CLUCENE_MIN_VERSION)
	set(CLUCENE_MIN_VERSION "0.9.19")
endif(NOT CLUCENE_MIN_VERSION)

IF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)
	INCLUDE(${PROJECT_CMAKE}/CLuceneConfig.cmake)
ENDIF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake)

IF(MSVC)
	IF(CMAKE_BUILD_TYPE STREQUAL "Release")
		SET(WIN_CLUCENE_SEARCH_PATH ../clucene-core/src/CLucene/Release)
	ELSE(CMAKE_BUILD_TYPE STREQUAL "Release")
		SET(WIN_CLUCENE_SEARCH_PATH ../clucene-core/src/CLucene/debug)
	ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
	SET(WIN_CLUCENE_INCLUDE_PATH ../clucene-core/src)
ELSE(MSVC)
	SET(WIN_CLUCENE_SEARCH_PATH "")
	SET(WIN_CLUCENE_INCLUDE_PATH "")
ENDIF(MSVC)

SET(TRIAL_LIBRARY_PATHS
	$ENV{CLUCENE_HOME}/lib${LIB_SUFFIX}
	${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
	/usr/local/lib${LIB_SUFFIX}
	/opt/local/lib${LIB_SUFFIX}
	/usr/lib${LIB_SUFFIX}
	/usr/lib64
	/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
	/sw/lib${LIB_SUFFIX}
	/usr/pkg/lib${LIB_SUFFIX}
	${WIN_CLUCENE_SEARCH_PATH}
	)
SET(TRIAL_INCLUDE_PATHS
	$ENV{CLUCENE_HOME}/include
	${CMAKE_INSTALL_PREFIX}/include
	/usr/local/include
	/usr/include
	/sw/include
	/usr/pkg/include
	${WIN_CLUCENE_INCLUDE_PATH}
	)
FIND_LIBRARY_WITH_DEBUG(CLUCENE_LIBRARY
	NAMES clucene clucene-core
	PATHS ${TRIAL_LIBRARY_PATHS})
FIND_PATH(CLUCENE_INCLUDE_DIR
	NAMES CLucene.h
	PATHS ${TRIAL_INCLUDE_PATHS}
	ONLY_CMAKE_FIND_ROOT_PATH)

IF(WIN32)
	SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR})
ENDIF(WIN32)

SET(CLUCENE_GOOD_VERSION TRUE)

FIND_PATH(CLUCENE_LIBRARY_DIR
	NAMES CLucene/clucene-config.h PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH)
IF (CLUCENE_LIBRARY_DIR)
	SET(CLUCENE_INCLUDE_DIR ${CLUCENE_INCLUDE_DIR} ${CLUCENE_LIBRARY_DIR})
	#MESSAGE(STATUS "Found CLucene library dir: ${CLUCENE_LIBRARY_DIR}")
	FILE(READ ${CLUCENE_LIBRARY_DIR}/CLucene/clucene-config.h CLCONTENT)
	STRING(REGEX MATCH "_CL_VERSION +\".*\"" CLMATCH ${CLCONTENT})
	IF (CLMATCH)
		STRING(REGEX REPLACE "_CL_VERSION +\"(.*)\"" "\\1" CLUCENE_VERSION ${CLMATCH})
		IF (CLUCENE_VERSION VERSION_LESS "${CLUCENE_MIN_VERSION}")
			MESSAGE(ERROR " CLucene version ${CLUCENE_VERSION} is less than the required minimum ${CLUCENE_MIN_VERSION}")
			SET(CLUCENE_GOOD_VERSION FALSE)
		ENDIF (CLUCENE_VERSION VERSION_LESS "${CLUCENE_MIN_VERSION}")
		IF (CLUCENE_VERSION STREQUAL "0.9.17")
			MESSAGE(ERROR "CLucene version 0.9.17 is not supported.")
			SET(CLUCENE_GOOD_VERSION FALSE)
		ENDIF (CLUCENE_VERSION STREQUAL "0.9.17")
		IF (CLUCENE_VERSION VERSION_GREATER "2.0")
			MESSAGE (STATUS "Found CLucene 2, enabling compatibility mode")
			SET(CLUCENE2 TRUE)
		ELSE (CLUCENE_VERSION VERSION_GREATER "2.0")
			SET(CLUCENE2 FALSE)
		ENDIF (CLUCENE_VERSION VERSION_GREATER "2.0")
	ENDIF (CLMATCH)
ELSE (CLUCENE_LIBRARY_DIR)
	#MESSAGE(STATUS "CLucene library dir not found.")
ENDIF (CLUCENE_LIBRARY_DIR)

IF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)
	SET(CLucene_FOUND TRUE)
ENDIF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARY AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION)

IF(CLucene_FOUND)
	IF(NOT CLucene_FIND_QUIETLY)
		MESSAGE(STATUS "CLucene: Yes ${CLUCENE_LIBRARY}")
	ENDIF(NOT CLucene_FIND_QUIETLY)
ELSE(CLucene_FOUND)
	IF(CLucene_FIND_REQUIRED)
		MESSAGE(FATAL_ERROR "CLucene: No")
	ENDIF(CLucene_FIND_REQUIRED)
ENDIF(CLucene_FOUND)

MARK_AS_ADVANCED(
	CLUCENE_INCLUDE_DIR
	CLUCENE_LIBRARY_DIR
	CLUCENE_LIBRARY
	)