-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
145 lines (126 loc) · 3.42 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
cmake_minimum_required( VERSION 3.8.0 )
project( sai )
set( CMAKE_CXX_STANDARD 20 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
set( CMAKE_COLOR_MAKEFILE ON )
set( CMAKE_VERBOSE_MAKEFILE ON )
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
# Determine if we're built as a subproject (using add_subdirectory)
# or if this is the master project.
set( MASTER_PROJECT OFF )
if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
set( MASTER_PROJECT ON )
endif()
# Create Universal Binary on macOS
set( CMAKE_OSX_ARCHITECTURES "arm64;x86_64" )
if( MSVC )
add_compile_options(
/MP # Parallel builds
/permissive- # Stricter C++ conformance
# Warnings
/W3
# Consider these warnings as errors
/we4018 # 'expression': signed/unsigned mismatch
/we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4305 # 'context': truncation from 'type1' to 'type2'
/we4388 # 'expression': signed/unsigned mismatch
/we4389 # 'operator': signed/unsigned mismatch
/we4456 # Declaration of 'identifier' hides previous local declaration
/we4457 # Declaration of 'identifier' hides function parameter
/we4458 # Declaration of 'identifier' hides class member
/we4459 # Declaration of 'identifier' hides global declaration
/we4505 # 'function': unreferenced local function has been removed
/we4547 # 'operator': operator before comma has no effect; expected operator with side-effect
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4715 # 'function': not all control paths return a value
/we4834 # Discarding return value of function with 'nodiscard' attribute
/we5038 # data member 'member1' will be initialized after data member 'member2'
/we5245 # 'function': unreferenced function with internal linkage has been removed
)
elseif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
add_compile_options(
-Wall
-Warray-bounds
-Wextra
-Wimplicit-fallthrough
-Wmissing-declarations
-Wmissing-declarations
-Wmissing-field-initializers
-Wno-attributes
-Wno-invalid-offsetof
-Wno-unused-parameter
-Wreorder
-Wshadow
-Wsign-compare
-Wswitch
-Wuninitialized
-Wunused-function
-Wunused-result
-Wunused-variable
)
endif()
### libsai
add_library(
sai
source/document.cpp
source/ifstream.cpp
source/ifstreambuf.cpp
source/keys.cpp
source/sai.cpp
source/virtualfileentry.cpp
source/virtualfilesystem.cpp
source/virtualpage.cpp
)
target_include_directories(
sai
PUBLIC
include
)
if( MASTER_PROJECT )
### Decryption sample
add_executable(
Thumbnail
samples/Thumbnail.cpp
samples/stb_image_write.c
)
target_link_libraries(
Thumbnail
PRIVATE
sai
)
### Decryption sample
add_executable(
Decrypt
samples/Decrypt.cpp
)
target_link_libraries(
Decrypt
PRIVATE
sai
)
### VFS tree sample
add_executable(
Tree
samples/Tree.cpp
)
target_link_libraries(
Tree
PRIVATE
sai
)
### Document sample
add_executable(
Document
samples/Document.cpp
samples/stb_image_write.c
)
target_link_libraries(
Document
PRIVATE
sai
)
endif()