forked from iwongu/sqlite3pp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
129 lines (109 loc) · 2.92 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
cmake_minimum_required(VERSION 3.9)
project( sqnice
VERSION 0.1.0
DESCRIPTION "A nice C++ API for SQLite"
LANGUAGES CXX C
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
option(USE_LOCAL_SQLITE "Use copy of sqlite in the vendor subdirectory" OFF)
option(USE_LOCAL_SQLCIPHER "Use copy of SQLCipher in the vendor subdirectory" OFF)
#### CONFIG
if (MSVC)
# MSVC:
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0A00 -DNOMINMAX)
set(USE_LOCAL_SQLITE ON) #FIXME: Don't override the option
else()
# Clang & GCC:
add_compile_options(
-Werror
-Wall
-Wpedantic
-Wno-unknown-pragmas
)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# GCC-specific:
add_compile_options(
-Wno-psabi # suppress annoying GCC ABI warning
-Wno-sign-compare # apparently comes with `pedantic` in GCC
-D_FORTIFY_SOURCE=2 # static+dynamic buffer-overflow checks
)
else()
# Clang-specific:
add_compile_options(
-Wno-nullability-extension
-Wno-gnu-zero-variadic-macro-arguments
-Wno-gnu-statement-expression-from-macro-expansion
-Wno-ambiguous-reversed-operator
)
endif()
endif()
if (USE_LOCAL_SQLCIPHER)
include_directories( BEFORE SYSTEM
vendor/sqlcipher/
)
elseif (USE_LOCAL_SQLITE)
include_directories( BEFORE SYSTEM
vendor/sqlite/
)
endif()
add_library( sqnice STATIC
src/base.cc
src/blob_stream.cc
src/database.cc
src/functions.cc
src/pool.cc
src/query.cc
src/transaction.cc
)
target_include_directories( sqnice PUBLIC
include/
)
if (USE_LOCAL_SQLCIPHER)
target_sources( sqnice PRIVATE
vendor/sqlcipher/sqlite3.c
)
set_source_files_properties(
vendor/sqlcipher/sqlite3.c PROPERTIES COMPILE_OPTIONS "-Wno-error"
)
target_compile_definitions(sqnice PRIVATE
SQLITE_HAS_CODEC
SQLITE_TEMP_STORE=3
)
if(APPLE)
target_compile_definitions(sqnice PRIVATE
SQLCIPHER_CRYPTO_CC # Use Apple's CommonCrypto lib for encryption
)
target_link_libraries( sqnice INTERFACE
"-framework CoreFoundation"
"-framework Security"
)
else()
target_compile_definitions(sqnice PRIVATE
SQLCIPHER_CRYPTO_OPENSSL
)
target_link_libraries( sqnice INTERFACE
crypto
)
endif()
elseif (USE_LOCAL_SQLITE)
target_sources( sqnice PRIVATE
vendor/sqlite/sqlite3.c
)
else()
target_link_libraries( sqnice INTERFACE
sqlite3
)
endif()
#### TESTS
add_executable( sqnice_tests
test/testdb.cc
test/testfunctions.cc
test/testquery.cc
test/test_main.cc
)
target_link_libraries( sqnice_tests
sqnice
)