-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
173 lines (152 loc) · 5.2 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
######################
# gaenari build & test
######################
# mkdir build
# cd build
# cmake ..
# cmake --build . --config release
# cmake --install . --prefix install
# ctest --verbose
# (find executables in build/tests/* and just execute it, display in color.)
####################
# build with gaenari
####################
# -------------------
# wrapper/wrapper.cpp
# -------------------
# #include "gaenari/gaenari.hpp"
# int main(void) {
# gaenari::logger::init1("/temp/_log.txt");
# using supul_t = supul::supul::supul_t;
# supul_t::api::project::create("/temp/supul_dir");
# supul_t::api::project::add_field("/temp/supul_dir", "x1", "REAL");
# supul_t::api::project::add_field("/temp/supul_dir", "x2", "INTEGER");
# supul_t::api::project::add_field("/temp/supul_dir", "x3", "TEXT_ID");
# supul_t::api::project::add_field("/temp/supul_dir", "y0", "TEXT_ID");
# supul_t::api::project::x("/temp/supul_dir", {"x1", "x2", "x3"});
# supul_t::api::project::y("/temp/supul_dir", "y0");
# supul_t::api::project::set_property("/temp/supul_dir", "db.type", "sqlite");
# supul_t supul;
# supul.api.lifetime.open("/temp/supul_dir");
# supul.api.model.insert_chunk_csv("/temp/dataset.csv");
# supul.api.model.update();
# supul.api.model.deinit();
# // ...
# supul.api.model.rebuild();
# supul.api.lifetime.close();
# return 0;
# }
#
# ----------------------
# wrapper/CMakeLists.txt
# ----------------------
# cmake_minimum_required(VERSION 3.6)
# project(wrapper)
#
# # call order is important.
#
# add_subdirectory(</path/to/gaenari>)
# check_cpp17_gaenari()
#
# add_executable(wrapper wrapper.cpp)
# add_gaenari(wrapper)
#
# -----
# build
# -----
# wrapper/build$ cmake ..
# wrapper/build$ cmake --build . --config release
cmake_minimum_required(VERSION 3.18)
##########
# settings
##########
# project.
project(gaenari VERSION 1.2)
#################################
# auto git ignore build directory
#################################
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*")
endif()
#########
# include
#########
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/gaenari_util.cmake")
#########
# options
#########
set(_SQLITE_SHA256_ "999826FE4C871F18919FDB8ED7EC9DD8217180854DD1FE21EEA96AED36186729")
set(_ADMLTE_SHA256_ "74AD6048947B00399C4F35B64CD53D0497E59A0C05CC7B2248AE065F933FF39F")
set(SQLITE_VERSION "3360000" CACHE STRING "sqlite version to build. minimum(3350400(=3.35.5) for supporting `returning`)")
set(SQLITE_RELEASE_YEAR "2021" CACHE STRING "release year of SQLITE_VERSION.")
set(SQLITE_SHA256 ${_SQLITE_SHA256_} CACHE STRING "sha256 value of sqlite.zip.")
set(BUILD_WEB true CACHE BOOL "build web-console.")
set(ADMINLTE_VERSION "3.2.0" CACHE STRING "AdminLTE version to use.")
set(ADMINLTE_SHA256 ${_ADMLTE_SHA256_} CACHE STRING "sha256 value of adminlte.zip.")
##################
# global variables
##################
# download directory.
set(DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/download")
# gaenari include directory.
set(GAENARI_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
# sqlite include directory.
set(SQLITE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sqlite")
# cpp-httplib(0.10.4) for web console.
set(CPP_HTTPLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/cpp-httplib-0.10.4")
# gaenari hpp files.
# gaenari has only header files.
# this list is used to build source_group for IDE tools, not compilation.
file(GLOB_RECURSE GAENARI_HPP_FILES
"${GAENARI_INCLUDE_DIR}/*.hpp"
"${GAENARI_INCLUDE_DIR}/*.h"
)
#######
# c++17
#######
check_cpp17_gaenari()
###########
# configure
###########
configure_file("${GAENARI_INCLUDE_DIR}/gaenari/gaenari-config.h.in" "${GAENARI_INCLUDE_DIR}/gaenari/gaenari-config.h")
############
# definition
############
# compile definitions.
set(GAENARI_DEFINITIONS "")
add_compile_definitions(${GAENARI_DEFINITIONS})
#########
# targets
#########
# add sqlite target to build.
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/extern/sqlite")
# add tests target to build.
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests")
# add web console target to build.
if(BUILD_WEB)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/gaenari-web")
endif()
# add files target to edit some files in IDE.
add_custom_target(files SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
"${CMAKE_CURRENT_SOURCE_DIR}/TODO.md"
)
#########################
# for add_gaenari() macro
#########################
set(GAENARI_INCLUDE_DIR_FOR_BUILD ${GAENARI_INCLUDE_DIR} ${SQLITE_INCLUDE_DIR} CACHE INTERNAL "_GAENARI_INCLUDE_DIR_FOR_BUILD")
set(GAEANRI_DEFINITION_FOR_BUILD ${GAENARI_DEFINITIONS} CACHE INTERNAL "_GAEANRI_DEFINITION_FOR_BUILD")
set(GAENARI_LINK_FOR_BUILD sqlite3 CACHE INTERNAL "_GAENARI_LINK_FOR_BUILD")
######
# test
######
# call tests from tests sub-directory.
enable_testing()
#########
# install
#########
# add gaenari header files to install directory.
install(DIRECTORY "${GAENARI_INCLUDE_DIR}" DESTINATION include)
if(BUILD_WEB)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/gaenari-web/web-root" DESTINATION bin)
endif()