FindToki.cmake
1.59 KB
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
FIND_PATH(Toki_INCLUDE_DIR libtoki/token.h /usr/include /usr/local/include )
FIND_LIBRARY(Toki_LIBRARY NAMES toki PATH /usr/lib /usr/local/lib)
MARK_AS_ADVANCED(Toki_LIBRARY)
MARK_AS_ADVANCED(Toki_INCLUDE_DIR)
IF (Toki_INCLUDE_DIR AND Toki_LIBRARY)
SET(Toki_FOUND TRUE)
ENDIF (Toki_INCLUDE_DIR AND Toki_LIBRARY)
IF (Toki_FOUND)
set(Toki_VERSION 0.0.0)
FIND_FILE(_Toki_VERSION_FILE libtoki/version.h ${Toki_INCLUDE_DIR})
IF (_Toki_VERSION_FILE)
FILE(READ ${_Toki_VERSION_FILE} _Toki_VERSION_CONENTS)
STRING(REGEX REPLACE ".*#define LIBTOKI_VERSION \\\"([0-9.]+)\\\".*" "\\1" Toki_VERSION "${_Toki_VERSION_CONENTS}")
ENDIF (_Toki_VERSION_FILE)
IF (Toki_FIND_VERSION)
IF (Toki_VERSION VERSION_LESS Toki_FIND_VERSION)
IF (Toki_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Toki version too old: ${Toki_VERSION}, requested >= ${Toki_FIND_VERSION}")
ELSE (Toki_FIND_REQUIRED)
IF (NOT Toki_FIND_QUIETLY)
MESSAGE(STATUS "Toki version too old: ${Toki_VERSION}, requested >= ${Toki_FIND_VERSION}")
ENDIF (NOT Toki_FIND_QUIETLY)
ENDIF (Toki_FIND_REQUIRED)
set(Toki_FOUND False)
ENDIF (Toki_VERSION VERSION_LESS Toki_FIND_VERSION)
ENDIF (Toki_FIND_VERSION)
IF (NOT Toki_FIND_QUIETLY)
MESSAGE(STATUS "Found libtoki ${Toki_VERSION}: ${Toki_LIBRARY}")
ENDIF (NOT Toki_FIND_QUIETLY)
ELSE (Toki_FOUND)
IF (Toki_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libtoki")
ELSE (Toki_FIND_REQUIRED)
MESSAGE(STATUS "libtoki not found")
ENDIF (Toki_FIND_REQUIRED)
ENDIF (Toki_FOUND)