-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (104 loc) · 3.17 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
cmake_minimum_required(VERSION 3.18.0)
project(lime)
# Basic compiler settings
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
# ----------- dependencies ------------
set(EXTERNAL_MODULES_PATH "external")
set(INTERNAL_MODULES_PATH "modules")
# external dependencies
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # allow to override variables within the CMakeLists.txt of the library
set(CPPTERMINAL_BUILD_EXAMPLES ON) # disable building examples
set(CPPTERMINAL_ENABLE_INSTALL OFF) # disable the installation of the library
set(CPPTERMINAL_ENABLE_TESTING ON) # disable the tests of the library ... when running 'ctest' we only want to see our own tests
add_subdirectory("${EXTERNAL_MODULES_PATH}/cpp-terminal")
# internal dependencies
enable_testing() # enable testing for internal libraries
add_subdirectory("${INTERNAL_MODULES_PATH}/unicode")
add_subdirectory("${INTERNAL_MODULES_PATH}/cpp-terminal-gui")
# ---------- unix specific libraries ------------
set(UNIX_LIBRARIES "")
if (UNIX)
find_package(X11 REQUIRED)
set(UNIX_LIBRARIES "X11")
endif()
# -------------------------------------------------
# project building process:
add_executable(lime
main.cpp
# lime
lime/Lime.cpp lime/Lime.hpp
)
# Compiler Options for Clang:
# ===========================
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILER_FLAGS
# set compiler flags for debugging
#---------------------------------
$<$<CONFIG:Debug>:
-O0 # disable optimisations
-g # enable debug information
>
# set compiler flags for release
#-------------------------------
$<$<CONFIG:Release>:
-O3 # Enable all Optimisations
>
)
# Compiler Options for GNU:
# =========================
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_FLAGS
# Enable link time optimisations
-flto
# set compiler flags for debugging
#---------------------------------
$<$<CONFIG:Debug>:
-O0 # disable optimisations
-g # enable debug information
-ggdb # extra flag for the debugger
>
# set compiler flags for release
#-------------------------------
$<$<CONFIG:Release>:
-O3 # Enable all Optimisations
>
)
# Compiler Options for MSVC:
# ==========================
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(COMPILER_FLAGS
/W3
/Zc:__cplusplus # enable __cplusplus
# set compiler flags for debugging
#---------------------------------
$<$<CONFIG:Debug>:
# disable optimisations for debugging
/Od
# produces a PDB file in a format that supports the Edit and Continue feature.
# To use Edit and Continue debugging features, you must use this option.
/ZI
>
# set compiler flags for release versions
#----------------------------------------
$<$<CONFIG:Release>:
# Creates fast code
/O2
>
)
else()
message( SEND_ERROR "The compiler you are using is not handeled. Add your compiler and compiler flags to the if(CMAKE_CXX_COMPILER_ID STREQUAL <your compiler>) in the CMakeLists.txt of the root folder")
endif()
#
# Target settings for lime
#
target_compile_options(lime PUBLIC
${COMPILER_FLAGS}
)
target_link_libraries(lime PUBLIC
unicode
cpp-terminal
cpp-terminal-gui
# ----- linux specific libraries -----
${UNIX_LIBRARIES}
)