-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
131 lines (113 loc) · 3.02 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
cmake_minimum_required( VERSION 3.2.2 )
project( base85 )
### Standard
set( CMAKE_CXX_STANDARD 20 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
### Verbosity
set( CMAKE_COLOR_MAKEFILE ON )
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
### Optimizations
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" )
# Force colored diagnostic messages in Ninja's output
if( CMAKE_GENERATOR STREQUAL "Ninja" )
add_compile_options( -fdiagnostics-color=always )
endif()
# add_compile_options(-march=native)
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()
### libbase85
add_library(
base85
source/Base85/Base85.cpp
)
target_include_directories(
base85
PUBLIC
include
)
### base85
add_executable(
base85-bin
source/main.cpp
)
set_target_properties(
base85-bin PROPERTIES
OUTPUT_NAME "base85"
)
target_include_directories(
base85-bin
PRIVATE
include
)
target_link_libraries(
base85-bin
PRIVATE
base85
)
### Tests
enable_testing()
find_package(Catch2 3 REQUIRED)
add_library(catch ALIAS Catch2::Catch2)
add_executable(
base85-test
tests/base85-enc.cpp
)
target_include_directories(
base85-test
PRIVATE
include
)
target_link_libraries(
base85-test
PRIVATE
base85
Catch2::Catch2WithMain
)
add_test(base85-test base85-test)