-
Notifications
You must be signed in to change notification settings - Fork 82
/
FindMOSES.cmake
82 lines (73 loc) · 2.85 KB
/
FindMOSES.cmake
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
# - Find MOSES library
#
# This module checks for the required version number and defines
# MOSES_LIBRARIES, the libraries to link against to use MOSES.
# MOSES_LIB_DIR, the location of the libraries
# MOSES_FOUND, If false, do not try to use MOSES
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
FIND_LIBRARY(MOSES_LIBRARY NAMES moses PATHS
/usr/lib
/usr/local/lib
PATH_SUFFIXES moses
)
FIND_LIBRARY(MOSES_EXEC_LIBRARY NAMES moses_exec PATHS
PATH_SUFFIXES moses
)
FIND_LIBRARY(COMBOANT_LIBRARY NAMES comboant PATHS
PATH_SUFFIXES moses
)
FIND_LIBRARY(COMBOREDUCT_LIBRARY NAMES comboreduct PATHS
PATH_SUFFIXES moses
)
FIND_LIBRARY(FEATURE_SELECTION_LIBRARY NAMES feature_selection PATHS
PATH_SUFFIXES moses
)
# Copy the results to the output variables.
IF (MOSES_LIBRARY)
SET(MOSES_FOUND 1)
SET(MOSES_LIBRARIES ${MOSES_LIBRARY} ${MOSES_EXEC_LIBRARY}
${COMBOANT_LIBRARY} ${COMBOREDUCT_LIBRARY}
${FEATURE_SELECTION_LIBRARY})
MESSAGE(STATUS "Found MOSES library: ${MOSES_LIBRARIES}")
ELSE (MOSES_LIBRARY)
SET(MOSES_FOUND 0)
SET(MOSES_LIBRARIES)
ENDIF (MOSES_LIBRARY)
# Check found version against required one
IF (MOSES_FOUND)
FIND_FILE(MOSES_CFG_FILE moses.h
/usr/include
/usr/local/include
)
# IF (DEFINED MOSES_CFG_FILE)
# FILE(READ "${MOSES_CFG_FILE}" _MOSES_VERSION_H_CONTENTS)
# STRING(REGEX MATCH "#define MOSES_VERSION_MAJOR ([0-9])" _MATCH "${_MOSES_VERSION_H_CONTENTS}")
# SET(MOSES_VERSION_MAJOR ${CMAKE_MATCH_1})
# STRING(REGEX MATCH "#define MOSES_VERSION_MINOR ([0-9])" _MATCH "${_MOSES_VERSION_H_CONTENTS}")
# SET(MOSES_VERSION_MINOR ${CMAKE_MATCH_1})
# STRING(REGEX MATCH "#define MOSES_VERSION_PATCH ([0-9])" _MATCH "${_MOSES_VERSION_H_CONTENTS}")
# SET(MOSES_VERSION_PATCH ${CMAKE_MATCH_1})
# set (MOSES_VERSION "${MOSES_VERSION_MAJOR}.${MOSES_VERSION_MINOR}.${MOSES_VERSION_PATCH}")
# MESSAGE(STATUS "Detected MOSES version number: ${MOSES_VERSION}")
# IF (DEFINED MOSES_VERSION AND MOSES_VERSION VERSION_LESS MOSES_FIND_VERSION)
# SET(MOSES_FOUND FALSE)
# MESSAGE(STATUS "Installed version ${MOSES_VERSION} of MOSES does not meet the minimum required version of ${MOSES_FIND_VERSION}")
# ENDIF ()
# ELSE ()
# MESSAGE(STATUS "Unable to find moses.h header file")
# SET(MOSES_FOUND 0)
# ENDIF ()
ENDIF ()
# Report the results.
IF (NOT MOSES_FOUND)
SET(MOSES_DIR_MESSAGE "Required version of MOSES was not found. Make sure the MOSES_LIBRARY environment variable is set.")
MESSAGE(STATUS "${MOSES_DIR_MESSAGE}")
IF (MOSES_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${MOSES_DIR_MESSAGE}")
ENDIF (MOSES_FIND_REQUIRED)
ENDIF (NOT MOSES_FOUND)
MARK_AS_ADVANCED(
MOSES_LIBRARIES
)