-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·124 lines (101 loc) · 3.77 KB
/
Copy pathCMakeLists.txt
File metadata and controls
executable file
·124 lines (101 loc) · 3.77 KB
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
cmake_minimum_required(VERSION 3.16)
project(Nebulite LANGUAGES C CXX ASM_NASM)
############################################################
## Include CMake files
include(${CMAKE_SOURCE_DIR}/Tools/CMake/optimizations.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/External/fetchContent.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/External/dependencies.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/External/sdlsettings.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/warnings.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/binarysettings.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/commonsources.cmake)
include(${CMAKE_SOURCE_DIR}/Tools/CMake/nebuliteMacros.cmake)
############################################################
# Info messages
# Echo the start of the configuration
message(STATUS "Starting configuration for project Nebulite")
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Source dir: ${CMAKE_SOURCE_DIR}")
message(STATUS "Binary dir: ${CMAKE_BINARY_DIR}")
############################################################
## General Environment Setup
# Set C++ standard
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Build artifacts go to ./tmp/build_<preset>/ via CMake presets,
# Final binaries are placed in ./bin/ with appropriate naming
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Setup assembler
enable_language(ASM)
# Fix LTO-related toolchain issues if needed
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries for external deps" FORCE)
lto_fix()
# Prepare SDL settings
sdl_setup()
############################################################
## Setup Project
fetchContent()
setup_binary_settings()
setup_common_sources(Nebulite)
configure_common_dependencies(Nebulite)
configure_warnings(Nebulite)
setNebuliteMacros(Nebulite)
target_include_directories(Nebulite PUBLIC ${CMAKE_SOURCE_DIR}/include)
############################################################
# optimize
optimize_rapidjson(Nebulite)
############################################################
# DEBUG
# Check source dir variables
get_cmake_property(_variableNames VARIABLES)
list(SORT _variableNames)
foreach(_variableName ${_variableNames})
if(_variableName MATCHES "SOURCE_DIR$")
message(STATUS "VARIABLE: ${_variableName}=${${_variableName}}")
endif()
endforeach()
# Check compile definitions for Nebulite
get_target_property(_compile_defs Nebulite COMPILE_DEFINITIONS)
foreach(_def ${_compile_defs})
message(STATUS "COMPILE_DEFINITION: ${_def}")
endforeach()
############################################################
## Platform-Specific
##################
# WINDOWS #
##################
if(WIN32)
message(STATUS "Targeting Windows")
# Include Windows-specific configuration
include(${CMAKE_SOURCE_DIR}/Tools/CMake/Platforms/windbuild.cmake)
# Configure for Windows
configure_windows(Nebulite)
# Prefer Win32 threads (avoid forcing pthread/winpthreads)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
set(CMAKE_THREAD_PREFER_PTHREAD FALSE)
set(THREADS_PREFER_PTHREAD_FLAG FALSE)
find_package(Threads REQUIRED)
##################
# APPLE #
##################
elseif(APPLE)
message(STATUS "Targeting macOS")
# Include macOS-specific configuration
include(${CMAKE_SOURCE_DIR}/Tools/CMake/Platforms/macbuild.cmake)
# Configure for macOS
configure_macos(Nebulite)
##################
# LINUX #
##################
elseif(LINUX)
message(STATUS "Targeting Linux")
# Include Linux-specific configuration
include(${CMAKE_SOURCE_DIR}/Tools/CMake/Platforms/linuxbuild.cmake)
# Configure for Linux
configure_linux(Nebulite)
##################
# UNKNOWN #
##################
else()
message(FATAL_ERROR "Unsupported platform")
endif()