-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
94 lines (83 loc) · 4.15 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
# minimum CMake version required for C++20 support, among other things
cmake_minimum_required(VERSION 3.15)
# detect if simmonitor is being used as a sub-project of another CMake project
if(NOT DEFINED PROJECT_NAME)
set(SIMMONITOR_SUBPROJECT OFF)
else()
set(SIMMONITOR_SUBPROJECT ON)
endif()
SET_SOURCE_FILES_PROPERTIES( src/simmonitor.c PROPERTIES LANGUAGE C)
#set(CMAKE_BUILD_TYPE Debug)
project(simmonitor)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed -ldl")
set(FREETYPE_INCLUDE_DIR /usr/include/freetype2)
#find_package(eclipse-paho-mqtt-c REQUIRED)
add_subdirectory(src/simmonitor/gameloop)
add_subdirectory(src/simmonitor/simulatorapi)
add_subdirectory(src/simmonitor/helper)
add_subdirectory(src/simmonitor/slog)
add_subdirectory(src/simmonitor/fbgfx)
add_subdirectory(src/simmonitor/db)
add_subdirectory(src/simmonitor/ui)
add_subdirectory(src/simmonitor/telemetry)
add_executable(simmonitor src/simmonitor/simmonitor.c)
target_include_directories(simmonitor PUBLIC config ${FREETYPE_INCLUDE_DIR})
target_link_libraries(simmonitor xdg-basedir m ncursesw argtable2 config gameloop helper slog simulatorapi db ui telemetry uv hoel jansson GL GLU GLEW glfw fbgfx freetype microhttpd tar)
add_compile_definitions(simmonitor SIMMAP_ALL)
# used for enabling additional compiler options if supported
include(CheckCXXCompilerFlag)
function(enable_cxx_compiler_flag_if_supported flag)
message(STATUS "[simmonitor] Checking if compiler supports warning flag '${flag}'")
check_cxx_compiler_flag("${flag}" flag_supported)
if(flag_supported)
message(STATUS "[simmonitor] Enabling warning flag '${flag}'")
target_compile_options(simmonitor INTERFACE "${flag}")
endif()
unset(flag_supported CACHE)
endfunction()
# enable a large amount of extra warnings, regardless of build mode
if (MSVC) # MSVC supports different warning options to GCC/Clang
enable_cxx_compiler_flag_if_supported("/W3") # set warning level 3
# if tests are enabled, enable converting all warnings to errors too
if (ENABLE_TESTS)
# add_compile_options(/WX)
enable_cxx_compiler_flag_if_supported("/WX")
endif()
else() # GCC/Clang warning option
# NOTE: GCC and Clang support most of the same options, but neither supports all
# of the others'. By only enabling them if supported, we get graceful failure
# when trying to enable unsupported flags
# e.g. at the time of writing, GCC does not support -Wdocumentation
#
# enable all warnings about 'questionable constructs'
enable_cxx_compiler_flag_if_supported("-Wall")
# issue 'pedantic' warnings for strict ISO compliance
enable_cxx_compiler_flag_if_supported("-pedantic")
# enable 'extra' strict warnings
enable_cxx_compiler_flag_if_supported("-Wextra")
# enable sign conversion warnings
enable_cxx_compiler_flag_if_supported("-Wsign-conversion")
# enable warnings about mistakes in Doxygen documentation
enable_cxx_compiler_flag_if_supported("-Wdocumentation")
# if tests are enabled, enable converting all warnings to errors too
if (ENABLE_TESTS)
enable_cxx_compiler_flag_if_supported("-Werror")
# exclude the following kinds of warnings from being converted into errors
# unknown-pragma is useful to have as a warning but not as an error, if you have
# pragmas which are for the consumption of one compiler only
enable_cxx_compiler_flag_if_supported("-Wno-error=unknown-pragmas")
# unused variable and function warnings are helpful but we don't need them as errors
enable_cxx_compiler_flag_if_supported("-Wno-error=unused-function")
enable_cxx_compiler_flag_if_supported("-Wno-error=unused-variable")
enable_cxx_compiler_flag_if_supported("-Wno-error=unused-parameter")
enable_cxx_compiler_flag_if_supported("-Wno-error=unused-private-field")
enable_cxx_compiler_flag_if_supported("-Wno-error=unused-but-set-variable")
endif()
endif()
# library
# unit tests --only enable if requested AND we're not building as a sub-project
if(ENABLE_TESTS AND NOT simmonitor_SUBPROJECT)
message(STATUS "[simmonitor] Unit Tests Enabled")
add_subdirectory(tests)
enable_testing()
endif()