-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
96 lines (80 loc) · 2.86 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
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0091 NEW)
project(gameboiadvance CXX)
include(cmake/StandardProjectSettings.cmake)
include(cmake/CompilerWarnings.cmake)
include(cmake/Sanitizers.cmake)
include(cmake/Doxygen.cmake)
include(cmake/StaticAnalyzers.cmake)
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
option(LIBRARY_ONLY "Enabled only the core library target" OFF)
option(ENABLE_TESTING "Enable Tests" OFF)
option(ENABLE_PCH "Enable Precompiled Headers" OFF)
option(ENABLE_ASSERTIONS "Enable assertions" OFF)
option(WITH_WARNINGS "Enable compiler warnings" ON)
option(LOG_LEVEL "Log level" "OFF")
set(LOG_LEVELS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
list(FIND LOG_LEVELS ${LOG_LEVEL} LOG_LEVEL_IDX)
message(STATUS "Log level: ${LOG_LEVEL} (${LOG_LEVEL_IDX})")
if(${LOG_LEVEL_IDX} EQUAL -1)
message(WARNING "Unknown log level, turning off logs")
set(LOG_LEVEL_IDX 6)
endif()
add_library(project_options INTERFACE)
target_compile_options(project_options INTERFACE $<IF:$<CXX_COMPILER_ID:MSVC>,/std:c++17,-std=c++17>)
target_compile_definitions(project_options INTERFACE
DEBUG=$<CONFIG:Debug>
WITH_DEBUGGER=$<BOOL:${ENABLE_DEBUGGER}>
$<$<BOOL:${ENABLE_ASSERTIONS}>:ENABLE_ASSERTIONS>
SPDLOG_ACTIVE_LEVEL=${LOG_LEVEL_IDX})
if(NOT MSVC)
option(WITH_LIBCXX "Use libc++" OFF)
if(WITH_LIBCXX)
target_compile_options(project_options INTERFACE -stdlib=libc++)
target_link_options(project_options INTERFACE -lc++)
else()
target_link_libraries(project_options INTERFACE stdc++fs)
endif()
endif()
add_library(project_warnings INTERFACE)
if(WITH_WARNINGS)
set_project_warnings(project_warnings)
endif()
enable_sanitizers(project_options)
enable_doxygen()
if(ENABLE_PCH)
# This sets a global PCH parameter, each project will build its own PCH, which
# is a good idea if any #define's change
target_precompile_headers(project_options INTERFACE
<array> <vector> <string> <unordered_map> <utility>)
endif()
if(NOT LIBRARY_ONLY)
find_package(SFML COMPONENTS window graphics system CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
endif()
find_package(ZLIB REQUIRED)
add_subdirectory(external)
add_subdirectory(gba)
if(NOT LIBRARY_ONLY)
option(ENABLE_DEBUGGER "Enable GameboiAdvance Debugger" OFF)
if(ENABLE_DEBUGGER)
add_subdirectory(gba_debugger)
else()
add_subdirectory(gba_frontend)
endif()
add_executable(gameboiadvance main.cpp)
target_link_libraries(gameboiadvance PRIVATE
gba::gba
$<IF:$<BOOL:${ENABLE_DEBUGGER}>,gba::debugger,gba::frontend>
cxxopts::cxxopts
SDL2::CXX
imgui::sfml
project_warnings
project_options)
endif()
if(ENABLE_TESTING)
enable_testing()
add_subdirectory(test)
endif()