forked from Slontia/lgtbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (68 loc) · 2.6 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
cmake_minimum_required(VERSION 3.0)
project(BotCore LANGUAGES CXX C)
set(CMAKE_SYSTEM_VERSION 1)
# Default build with Debug
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
option(WITH_GCOV "bulid with gcov" FALSE)
option(WITH_ASAN "build with address sanitizier" FALSE)
option(WITH_TEST "build with unittest" TRUE)
option(WITH_CORE "build with bot core" TRUE)
option(WITH_TOOLS "build with tools" TRUE)
option(WITH_GAMES "build with games" TRUE)
option(WITH_IMAGE "allow bot print image" TRUE)
option(WITH_GLOG "build with glog" TRUE)
option(WITH_SQLITE "build with sqlite" TRUE)
# 'char' type in arm machines is 'unsigned char', we should define it as 'signed char'
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -g")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char -g")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/json/include)
if (WITH_IMAGE)
add_subdirectory(third_party/markdown2image)
endif()
if (WITH_GCOV)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fprofile-arcs -ftest-coverage -lgcov --coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -fprofile-arcs -ftest-coverage -lgcov --coverage")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
endif()
if (WITH_ASAN)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif()
if (WITH_SQLITE)
add_definitions(-DWITH_SQLITE)
find_package(SQLite3 REQUIRED)
list(APPEND THIRD_PARTIES SQLite::SQLite3)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/sqlite_modern_cpp/hdr)
endif()
if (WITH_GLOG)
find_package(glog REQUIRED)
list(APPEND THIRD_PARTIES glog)
add_definitions(-DWITH_GLOG)
endif()
if (WITH_TEST)
enable_testing()
endif()
if (WITH_CORE)
add_subdirectory(bot_core)
endif()
if (WITH_TOOLS)
add_subdirectory(tools)
endif()
if (WITH_GAMES)
add_subdirectory(third_party/necessary-and-unnecessary-tiles)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/necessary-and-unnecessary-tiles)
add_subdirectory(third_party/mahjong)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/mahjong)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/tiny_expr)
add_library(tinyexpr SHARED ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tiny_expr/tinyexpr.c)
add_subdirectory(games)
endif()
if (WITH_TEST)
add_subdirectory(game_util) # only build for unittest
add_subdirectory(utility) # only build for unittest
endif()