-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
118 lines (103 loc) · 3.18 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
cmake_minimum_required(VERSION 3.20)
project(Ember VERSION 1.0 LANGUAGES CXX C)
# Set C++ Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set C Standard
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Check and print clang version
find_program(CLANG_EXECUTABLE clang)
if(CLANG_EXECUTABLE)
execute_process(
COMMAND ${CLANG_EXECUTABLE} --version
OUTPUT_VARIABLE CLANG_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Clang version: ${CLANG_VERSION_OUTPUT}")
else()
message(WARNING "Clang not found. Unable to determine version.")
endif()
# Print the C++ and C standard versions
message(STATUS "Using C++ standard version ${CMAKE_CXX_STANDARD}")
message(STATUS "Using C standard version ${CMAKE_C_STANDARD}")
# Set the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
endif()
# Check X11 or Wayland and set the appropriate GLFW backend flag
set(GLFW_BACKEND_X11 0)
set(GLFW_BACKEND_WAYLAND 0)
if(UNIX AND NOT APPLE)
find_package(X11)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND REQUIRED wayland-client wayland-cursor)
if(NOT X11_FOUND)
message(STATUS "X11 not found")
else()
set(GLFW_BACKEND_X11 1)
message(STATUS "Found X11 backend")
endif()
if(NOT WAYLAND_FOUND)
message(STATUS "Wayland not found")
else()
set(GLFW_BACKEND_WAYLAND 1)
message(STATUS "Found Wayland backend")
endif()
if(NOT X11_FOUND AND NOT WAYLAND_FOUND)
message(FATAL_ERROR "Neither X11 nor Wayland found")
endif()
endif()
# Set the output directories
if(BUILD_SHARED_LIBS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Shared/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Shared/)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Shared/)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Static/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Static/)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}-Static/)
endif()
# Include subdirectories
add_subdirectory(Ember)
add_subdirectory(Foundry)
add_subdirectory(Sandbox)
# Set common compile options
function(set_common_compile_options target)
target_compile_options(${target} PRIVATE
$<$<CONFIG:DEBUG>:
-O0
-g
-Wall
-Wextra
-pedantic
-Wshadow
-Wconversion
-Wsign-conversion
-Wunreachable-code
>
$<$<CONFIG:RELEASE>:
-O3
-Wall
-Wextra
-pedantic
>
$<$<CONFIG:RELWITHDEBINFO>:
-O2
-g
-Wall
-Wextra
-pedantic
>
$<$<CONFIG:MINSIZEREL>:
-Os
-Wall
-Wextra
-pedantic
>
)
endfunction()
set_common_compile_options(EmberEngine)
set_common_compile_options(Foundry)
set_common_compile_options(Sandbox)