forked from varnamproject/libvarnam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
134 lines (108 loc) · 4.28 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
##
# Copyright (C) Navaneeth.K.N
#
# This is part of libvarnam. See LICENSE.txt for the license
##
cmake_minimum_required (VERSION 2.8.8)
project(varnam)
message ("Generating project ${PROJECT_NAME}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/deps/cmake_modules/")
set(VARNAM_LIBRARY_NAME "varnam")
set(VARNAM_LIBRARY_NAME_STATIC "varnamstatic")
set(DEPS_LIBRARY_NAME "deps")
set(VARNAM_VERSION_MAJOR 3)
set(VARNAM_VERSION_MINOR 1)
set(VARNAM_VERSION_PATCH 1)
option(BUILD_TESTS "Build tests?" OFF)
option(BUILD_EXAMPLES "Build examples?" OFF)
option(BUILD_TOOLS "Build tools?" OFF)
set(CMAKE_C_FLAGS "-Wall -ansi -pedantic -Wno-long-long -Wconversion -Wformat=2 -Wshadow -Wcast-qual -Wwrite-strings -fPIC")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O2")
IF(MSVC)
set(CMAKE_C_FLAGS "/Wall /wd\"4255;4100\"")
# We don't want to use MSVC's more secure versions of functions. So suppressing the warnings
add_definitions(-DWIN32 -D_CRT_SECURE_NO_WARNINGS)
ENDIF()
if (RECORD_EXEC_TIME)
add_definitions(-D_RECORD_EXEC_TIME)
endif (RECORD_EXEC_TIME)
if (VARNAM_VERBOSE)
add_definitions(-D_VARNAM_VERBOSE)
endif (VARNAM_VERBOSE)
add_definitions(-DHAVE_SNPRINTF -DPREFER_PORTABLE_SNPRINTF -DNEED_ASPRINTF)
add_definitions(-DVARNAM_VERSION="${VARNAM_VERSION_MAJOR}.${VARNAM_VERSION_MINOR}.${VARNAM_VERSION_PATCH}")
# Append the source files here
list (APPEND VARNAM_SOURCES
util.c
lru_cache.c
vutf8.c
trie.c
strbuf.c
transliterate.c
symbol-table.c
words-table.c
varray.c
token.c
vword.c
learn.c
rendering.c
lang_detection.c
renderer/ml_unicode.c
varnam.c
)
# Append the header files here. this will get copied to include directory
list (APPEND VARNAM_INCLUDE_FILES
varnam.h
api.h
result-codes.h
vtypes.h
util.h
varray.h
vutf8.h
langcodes.h
)
add_subdirectory(deps)
if (BUILD_TESTS)
# Build tests
add_subdirectory(tests)
endif ()
if (BUILD_EXAMPLES)
# Build examples
add_subdirectory(examples)
endif ()
if (BUILD_TOOLS)
# Build tools
add_subdirectory(tools)
endif ()
# Generate pkg-config file
configure_file(varnam.pc.in varnam.pc @ONLY)
configure_file(varnamstatic.pc.in varnamstatic.pc @ONLY)
add_definitions(-DSQLITE_CASE_SENSITIVE_LIKE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS)
# Create a shared and static library libvarnam
add_library (varnam_core OBJECT ${VARNAM_SOURCES})
add_library (${VARNAM_LIBRARY_NAME_STATIC} STATIC $<TARGET_OBJECTS:${DEPS_LIBRARY_NAME}> $<TARGET_OBJECTS:varnam_core>)
add_library (${VARNAM_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:${DEPS_LIBRARY_NAME}> $<TARGET_OBJECTS:varnam_core>)
SET_TARGET_PROPERTIES(${VARNAM_LIBRARY_NAME} PROPERTIES
VERSION ${VARNAM_VERSION_MAJOR}.${VARNAM_VERSION_MINOR}.${VARNAM_VERSION_PATCH}
SOVERSION ${VARNAM_VERSION_MAJOR})
# a custom target to compile scheme files
add_custom_target (vst command ./varnamc --compile schemes/ml && ./varnamc --compile schemes/hi)
# Makes the distro
add_custom_target (distro command ./makedistro.sh "${VARNAM_VERSION_MAJOR}.${VARNAM_VERSION_MINOR}.${VARNAM_VERSION_PATCH}")
INSTALL ( TARGETS ${VARNAM_LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
INSTALL ( TARGETS ${VARNAM_LIBRARY_NAME_STATIC} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
INSTALL ( FILES ${VARNAM_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/lib${VARNAM_LIBRARY_NAME})
INSTALL ( FILES deps/sqlite3.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/lib${VARNAM_LIBRARY_NAME}/deps)
INSTALL ( FILES deps/uthash.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/lib${VARNAM_LIBRARY_NAME}/deps)
INSTALL ( FILES varnam.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
INSTALL ( FILES varnamstatic.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
# Hack to install VST files as they are generated by vst target and not available when cmake . was run
INSTALL ( CODE "file(GLOB vst_files \"schemes/*.vst\")" CODE "file(INSTALL \${vst_files} DESTINATION \${CMAKE_INSTALL_PREFIX}/share/varnam/vst)")
INSTALL_PROGRAMS(/bin FILES varnamc varnamruby.rb)
IF(MSVC)
target_link_libraries(${VARNAM_LIBRARY_NAME})
else()
# sqlite requires pthread and dl
target_link_libraries(${VARNAM_LIBRARY_NAME} pthread dl)
ENDIF()