aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 55db14b6804cc9e46021e7730a75db7b27f0784d (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
cmake_minimum_required(VERSION 3.13)
project(ProjectBrussel LANGUAGES C CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

include(buildtools/cmake/RTTI.cmake)

find_package(OpenGL REQUIRED)
add_subdirectory(3rdparty/glfw)
add_subdirectory(3rdparty/glm)
add_subdirectory(3rdparty/imgui)
add_subdirectory(3rdparty/imguicolortextedit)
add_subdirectory(3rdparty/tracy)

# ==============================================================================

file(GLOB_RECURSE things_common_SOURCES source-common/*.c source-common/*.cpp)
add_library(things_common OBJECT ${things_common_SOURCES})

set_target_properties(things_common PROPERTIES
	CXX_STANDARD 20
	CXX_STANDARD_REQUIRED ON
	CXX_EXTENSIONS OFF

	# Many files include platform headers, we don't want to leak them - it's just simpler to disable unity build for everything
	UNITY_BUILD OFF
)

target_include_directories(things_common PUBLIC source-common)
target_link_libraries(things_common PUBLIC
	# External dependencies
	${CONAN_LIBS}
	glm::glm
)

# ==============================================================================

# NOTE: delibrately not recursive, see README.md in the folder for details
file(GLOB codegen_SOURCES buildtools/codegen/*.c buildtools/codegen/*.cpp)
add_executable(codegen ${codegen_SOURCES})

set_target_properties(codegen PROPERTIES	
	CXX_STANDARD 20
	CXX_STANDARD_REQUIRED ON
	CXX_EXTENSIONS OFF
	UNITY_BUILD OFF
)

target_link_libraries(codegen PRIVATE
	# External dependencies
	${CONAN_LIBS}

	# Project internal components
	things_common
)

target_flag_rtti(codegen OFF)

option(BRUSSEL_CODEGEN_DEBUG_PRINT "Enable debug printing in the code generator or not." OFF)
if(BRUSSEL_CODEGEN_DEBUG_PRINT)
	target_compile_definitions(codegen PRIVATE CODEGEN_DEBUG_PRINT=1)
endif()

# ==============================================================================

file(GLOB_RECURSE things_codegen_base_SOURCES source-codegen-base/*.c source-codegen-base/*.cpp)
add_library(things_codegen_base OBJECT ${things_codegen_base_SOURCES})

set_target_properties(things_codegen_base PROPERTIES
	CXX_STANDARD 20
	CXX_STANDARD_REQUIRED ON
	CXX_EXTENSIONS OFF
)

target_include_directories(things_codegen_base PUBLIC source-codegen-base)
target_link_libraries(things_codegen_base PUBLIC
	# External dependencies
	${CONAN_LIBS}

	# Project internal components
	things_common
)

# ==============================================================================

# add_executable requires at least one source file
add_executable(${PROJECT_NAME} dummy.c)
add_subdirectory(source)

set_target_properties(${PROJECT_NAME} PROPERTIES
	UNITY_BUILD_MODE BATCH
	UNITY_BUILD_UNIQUE_ID "${PROJECT_NAME}_UNITY_ID"
)

set_target_properties(${PROJECT_NAME} PROPERTIES
	CXX_STANDARD 20
	CXX_STANDARD_REQUIRED ON
	CXX_EXTENSIONS OFF
)

target_compile_definitions(${PROJECT_NAME} PRIVATE
	RAPIDJSON_HAS_STDSTRING=1
	IMGUI_DISABLE_OBSOLETE_FUNCTIONS
	BRUSSEL_DEV_ENV=1
)

target_include_directories(${PROJECT_NAME} PRIVATE
	sources
)

target_link_libraries(${PROJECT_NAME} PRIVATE
	# External dependencies
	${CONAN_LIBS}
	OpenGL::GL
	glfw
	glm::glm
	imgui
	ImGuiColorTextEdit
	tracy

	# Project internal components
	things_common
	things_codegen_base
)

option(BRUSSEL_ENABLE_PROFILING "Whether profiling support is enabled or not." OFF)
if(BRUSSEL_ENABLE_PROFILING)
	target_compile_definitions(${PROJECT_NAME}
	PRIVATE
		TRACY_ENABLE
	)
endif()

option(BRUSSEL_ENABLE_EDITOR "Enable editor support or not." ON)
if(BRUSSEL_ENABLE_EDITOR)
	target_compile_definitions(${PROJECT_NAME}
	PRIVATE
		BRUSSEL_ENABLE_EDITOR=1
	)
endif()

option(BRUSSEL_ENABLE_ASAN "Enable AddressSanitizer or not." OFF)
if(BRUSSEL_ENABLE_ASAN)
	target_compile_options(${PROJECT_NAME}
	PRIVATE
		-fsanitize=address
		-fno-omit-frame-pointer
	)
	target_link_options(${PROJECT_NAME}
	PRIVATE
		-fsanitize=address
		-fno-omit-frame-pointer
	)
endif()