-
Notifications
You must be signed in to change notification settings - Fork 44
/
CMakeLists.txt
153 lines (122 loc) · 4.05 KB
/
CMakeLists.txt
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
project(sdcv)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_policy(VERSION 3.5)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler.cmake")
set(ZLIB_FIND_REQUIRED True)
include(FindZLIB)
set(GLIB2_REQ "'glib-2.0 >= 2.36'")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGLIB2.cmake")
if (NOT GLIB2_FOUND)
message(FATAL_ERROR "sdcv require ${GLIB2_REQ}, "
"make sure that you install it")
endif()
set(WITH_READLINE True CACHE BOOL "Use readline library")
if (WITH_READLINE)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
find_library(READLINE_LIBRARY NAMES readline)
if (NOT (READLINE_INCLUDE_DIR AND READLINE_LIBRARY))
set(WITH_READLINE False CACHE FORCE)
endif ()
endif (WITH_READLINE)
option(ENABLE_NLS "Enable NLS support" True)
set(sdcv_SRCS
src/sdcv.cpp
src/readline.cpp
src/readline.hpp
src/libwrapper.cpp
src/libwrapper.hpp
src/utils.cpp
src/utils.hpp
src/stardict_lib.cpp
src/stardict_lib.hpp
src/dictziplib.cpp
src/dictziplib.hpp
src/distance.cpp
src/distance.hpp
src/mapfile.hpp
)
if (ENABLE_NLS)
find_package(GettextTools REQUIRED)
set(gettext_stockDir "${CMAKE_CURRENT_SOURCE_DIR}/po")
set(gettext_langDir "${CMAKE_CURRENT_BINARY_DIR}/lang")
set(gettext_outDir "${CMAKE_CURRENT_BINARY_DIR}/locale")
set(GETTEXT_TRANSLATIONS_PATH "${CMAKE_INSTALL_PREFIX}/share/locale")
gettext_make_target("lang"
HIERARCHY "{1}/{2}/{3}/{4}.mo"
KEYWORDS "_"
DOMAIN "sdcv"
STOCK_DIR ${gettext_stockDir}
LANG_DIR ${gettext_langDir}
OUT_DIR ${gettext_outDir}
SOURCE ${sdcv_SRCS})
list(APPEND makeCleanFiles ${gettext_outDir})
endif ()
include(CheckFunctionExists)
check_function_exists(mmap HAVE_MMAP)
include(CheckIncludeFile)
check_include_file(locale.h HAVE_LOCALE_H)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(
${ZLIB_INCLUDE_DIR}
${GLIB2_INCLUDE_DIRS}
${READLINE_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/lib
${CMAKE_CURRENT_BINARY_DIR}
)
#
# Packing stuff
#
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "console version of StarDict program")
set(CPACK_PACKAGE_VENDOR "Evgeniy Dushistov <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.org")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "5")
set(CPACK_PACKAGE_VERSION_PATCH "5")
set(sdcv_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
add_definitions(-DVERSION="${sdcv_VERSION}" -DHAVE_CONFIG_H)
add_executable(sdcv ${sdcv_SRCS})
target_link_libraries(sdcv
${GLIB2_LIBRARIES}
${ZLIB_LIBRARIES}
${READLINE_LIBRARY}
)
if (ENABLE_NLS)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "locale")
endif ()
include(CPack)
install(TARGETS sdcv DESTINATION "bin")
install(FILES doc/sdcv.1 DESTINATION "share/man/man1")
install(FILES doc/uk/sdcv.1 DESTINATION "share/man/uk/man1")
if (ENABLE_NLS)
install(DIRECTORY "${gettext_outDir}" DESTINATION "share")
endif ()
option(BUILD_TESTS "Enable automatic testing" False)
if (BUILD_TESTS)
find_program(SHELL_CMD NAMES sh bash
DOC "Shell scripts interpretator command")
message(STATUS "Build tests")
enable_testing()# Force "make test" to works
macro(add_sdcv_shell_test test_name)
add_test(NAME ${test_name}
COMMAND "${SHELL_CMD}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/${test_name}" $<TARGET_FILE:sdcv> "${CMAKE_CURRENT_SOURCE_DIR}/tests")
endmacro()
add_sdcv_shell_test(t_list)
add_sdcv_shell_test(t_use)
add_sdcv_shell_test(t_only_data_dir)
add_sdcv_shell_test(t_synonyms)
add_sdcv_shell_test(t_json)
add_sdcv_shell_test(t_exact)
add_sdcv_shell_test(t_interactive)
add_sdcv_shell_test(t_utf8output)
add_sdcv_shell_test(t_utf8input)
add_sdcv_shell_test(t_datadir)
add_sdcv_shell_test(t_return_code)
add_sdcv_shell_test(t_multiple_results)
add_sdcv_shell_test(t_newlines_in_ifo)
endif (BUILD_TESTS)