-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
76 lines (63 loc) · 2.16 KB
/
Copy pathCMakeLists.txt
File metadata and controls
76 lines (63 loc) · 2.16 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
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
cmake_minimum_required(VERSION 3.11)
project(sj4)
option(SJ4_GLOBAL "Use global variables or not" OFF)
option(SJ4_EMBED "Embed main dictionary or not" OFF)
option(SJ4_EMBED_PLUS "Embed pubdic+ as main dictionary or not" OFF)
option(SJ4_NO_UNICODE "Remove Unicode code completely" OFF)
option(SJ4_BUILD_ONLY_LIB "Always build only library" OFF)
option(SJ4_BUILD_TOOLS "Always build tools" OFF)
option(SJ4_NO_TESTS "Build no tests" OFF)
macro(sj4_library name)
file(GLOB_RECURSE ${name}_SRCS lib/${name}/**.c)
add_library(${name} STATIC ${${name}_SRCS})
target_include_directories(${name} PUBLIC include/${name})
if(NOT "${name}" STREQUAL "sj4common")
target_link_libraries(${name} PUBLIC sj4common)
endif()
endmacro()
sj4_library(sj4common)
sj4_library(sj4charset)
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4charset PRIVATE UCS)
endif()
sj4_library(sj4core)
if(SJ4_GLOBAL)
target_compile_definitions(sj4core PUBLIC SJ4_GLOBAL)
endif()
if(SJ4_EMBED_PLUS)
target_compile_definitions(sj4core PUBLIC EMBED_PLUS)
elseif(SJ4_EMBED)
target_compile_definitions(sj4core PUBLIC EMBED)
endif()
sj4_library(sj4rkcv)
if(NOT SJ4_GLOBAL)
sj4_library(sj4lib)
target_link_libraries(sj4lib PUBLIC sj4core sj4charset)
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4lib PRIVATE UCS)
endif()
endif()
if(NOT SJ4_GLOBAL)
sj4_library(sj4ime)
target_link_libraries(sj4ime PUBLIC sj4lib)
endif()
if(SJ4_BUILD_TOOLS OR (NOT CMAKE_BINARY_DIR MATCHES CMAKE_CURRENT_SOURCE_DIR AND NOT SJ4_BUILD_ONLY_LIB))
file(GLOB_RECURSE SJ4MKDIC_SRCS src/sj4mkdic/**.c)
add_executable(sj4mkdic ${SJ4MKDIC_SRCS})
target_include_directories(sj4mkdic PRIVATE include/sj4core)
target_compile_definitions(sj4mkdic PRIVATE ENGLISH)
target_link_libraries(sj4mkdic PRIVATE sj4common sj4charset)
if(NOT SJ4_NO_UNICODE)
target_compile_definitions(sj4mkdic PRIVATE UTF8)
endif()
if(NOT SJ4_GLOBAL AND NOT SJ4_NO_TESTS)
macro(sj4_test name)
file(GLOB_RECURSE ${name}_SRCS src/${name}/**.c)
add_executable(${name} ${${name}_SRCS})
endmacro()
sj4_test(sj4test)
target_link_libraries(sj4test PRIVATE sj4lib)
sj4_test(sj4test2)
target_link_libraries(sj4test2 PRIVATE sj4ime)
endif()
endif()