blob: f17335af64f84ee7fe309f85fe69f9eb967cc298 (
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
option(BUILD_CORE_TESTS "Whether to make executable tests or not." OFF)
set(TARGET_LOCALE "en_US" CACHE STRING "Locale to build.")
option(BUILD_CORE_WITH_OPENGL2_BACKEND ON)
option(BUILD_CORE_WITH_OPENGL3_BACKEND ON)
option(BUILD_CORE_WITH_VULKAN_BACKEND ON)
if(WIN32)
option(BUILD_CORE_WITH_DX11_BACKEND ON)
option(BUILD_CORE_WITH_DX12_BACKEND ON)
elseif(APPLE)
option(BUILD_CORE_WITH_METAL_BACKEND ON)
endif()
message("CpltCore: generating executable CpltCore")
if(BUILD_CORE_WITH_OPENGL2_BACKEND OR
BUILD_CORE_WITH_OPENGL3_BACKEND OR
BUILD_CORE_WITH_VULKAN_BACKEND OR
BUILD_CORE_WITH_METAL_BACKEND)
list(APPEND CPLT_CORE_SOURCES_SPECIAL
${CMAKE_SOURCE_DIR}/3rdparty/imgui/backend/imgui_impl_glfw.cpp
)
endif()
if(BUILD_CORE_WITH_DX11_BACKEND OR BUILD_CORE_WITH_DX12_BACKEND)
list(APPEND CPLT_CORE_SOURCES_SPECIAL
${CMAKE_SOURCE_DIR}/3rdparty/imgui/backend/imgui_impl_win32.cpp
)
endif()
file(GLOB_RECURSE CPLT_CORE_SOURCES_NORMAL
${CMAKE_CURRENT_LIST_DIR}/src/*.h
${CMAKE_CURRENT_LIST_DIR}/src/*.c
${CMAKE_CURRENT_LIST_DIR}/src/*.m
${CMAKE_CURRENT_LIST_DIR}/src/*.hpp
${CMAKE_CURRENT_LIST_DIR}/src/*.cpp
${CMAKE_CURRENT_LIST_DIR}/src/*.mm
)
add_executable(CpltCore ${CPLT_CORE_SOURCES_SPECIAL} ${CPLT_CORE_SOURCES_NORMAL})
set(CPLT_CORE_SOURCES_NORMAL_UNITY_EXCLUDED
src/Entrypoint/main.cpp
src/Entrypoint/Backend_OpenGL2.cpp
src/Entrypoint/Backend_OpenGL3.cpp
src/Entrypoint/Backend_Vulkan.cpp
src/Entrypoint/Backend_DirectX11.cpp
src/Entrypoint/Backend_DirectX12.cpp
src/Entrypoint/Backend_Metal.mm
src/UI/UI_DatabaseView.cpp
src/UI/UI_Items.cpp
src/UI/UI_MainWindow.cpp
src/UI/UI_Settings.cpp
src/UI/UI_Templates.cpp
src/UI/UI_Utils.cpp
src/UI/UI_Workflows.cpp
src/Utils/IO/FileStream.cpp
)
set_source_files_properties(
${CPLT_CORE_SOURCES_SPECIAL}
${CPLT_CORE_SOURCES_NORMAL_UNITY_EXCLUDED}
PROPERTIES
SKIP_UNITY_BUILD_INCLUSION ON
)
target_include_directories(CpltCore PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_SOURCE_DIR}/3rdparty/iconfontheaders
${CMAKE_SOURCE_DIR}/3rdparty/imgui
${CMAKE_SOURCE_DIR}/3rdparty/imgui-node-editor
)
target_link_libraries(CpltCore
PRIVATE
${CONAN_LIBS}
imgui
implot
imgui-node-editor
SQLiteCpp
)
if(NOT BUILD_CORE_TESTS)
target_compile_definitions(CpltCore PRIVATE DOCTEST_CONFIG_DISABLE=1)
endif()
if(NOT TARGET_LOCALE STREQUAL "en_US")
target_compile_definitions(CpltCore
PRIVATE
TARGET_LOCALE=${TARGET_LOCALE}
TARGET_LOCALE_FILE="Locale/${TARGET_LOCALE}.h"
)
endif()
if(WIN32)
message("CpltCore: - building with DirectX11 backend ${BUILD_CORE_WITH_DX11_BACKEND}")
message("CpltCore: - building with DirectX12 backend ${BUILD_CORE_WITH_DX12_BACKEND}")
target_compile_definitions(CpltCore
PRIVATE
BUILD_CORE_WITH_DX11_BACKEND=$<BOOL:${BUILD_CORE_WITH_DX11_BACKEND}>
BUILD_CORE_WITH_DX12_BACKEND=$<BOOL:${BUILD_CORE_WITH_DX12_BACKEND}>
)
if(BUILD_CORE_WITH_DX11_BACKEND)
target_link_libraries(CpltCore PRIVATE dxgi.lib d3d11.lib)
endif()
if(BUILD_CORE_WITH_DX12_BACKEND)
target_link_libraries(CpltCore PRIVATE dxgi.lib d3d12.lib)
endif()
endif()
if(APPLE)
message("CpltCore: - building with Metal backend ${BUILD_CORE_WITH_METAL_BACKEND}")
target_compile_definitions(CpltCore
PRIVATE
BUILD_CORE_WITH_METAL_BACKEND=$<BOOL:${BUILD_CORE_WITH_METAL_BACKEND}>
)
endif()
if(NOT APPLE)
message("CpltCore: - building with OpenGL2 backend ${BUILD_CORE_WITH_OPENGL2_BACKEND}")
message("CpltCore: - building with OpenGL3 backend ${BUILD_CORE_WITH_OPENGL3_BACKEND}")
message("CpltCore: - building with Vulkan backend ${BUILD_CORE_WITH_VULKAN_BACKEND}")
target_compile_definitions(CpltCore
PRIVATE
BUILD_CORE_WITH_OPENGL2_BACKEND=$<BOOL:${BUILD_CORE_WITH_OPENGL2_BACKEND}>
BUILD_CORE_WITH_OPENGL3_BACKEND=$<BOOL:${BUILD_CORE_WITH_OPENGL3_BACKEND}>
BUILD_CORE_WITH_VULKAN_BACKEND=$<BOOL:${BUILD_CORE_WITH_VULKAN_BACKEND}>
)
# TODO conditionally add opengl libraries
if(BUILD_CORE_WITH_VULKAN_BACKEND)
find_package(Vulkan REQUIRED FATAL_ERROR)
target_include_directories(CpltCore PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(CpltCore PRIVATE ${Vulkan_LIBRARIES})
endif()
endif()
if(WIN32)
function(handle_gnu_style_compiler)
# No console window when targeting windows
# Supposedly the flag -mwindows would automatically make the executable use GUI subsystem
# But, when subsystem is set to GUI, linker will only search WinMain and wWinMain but not the standard main (it seems like)
# so creating GUI executable fails and the linker silently reverts to the default, CUI subsystem
target_link_options(CpltCore PRIVATE -Wl,-subsystem:windows)
target_link_options(CpltCore PRIVATE -Wl,-entry:mainCRTStartup)
endfunction()
function(handle_msvc_style_compiler)
# No console window when targeting windows
target_link_options(CpltCore PRIVATE /SUBSYSTEM:windows /ENTRY:mainCRTStartup)
endfunction()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC (MinGW)
handle_gnu_style_compiler()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
# MSVC-style argument clang (clang-cl.exe)
handle_msvc_style_compiler()
elseif(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
# GNU-style argument clang (clang.exe and clang++.exe)
handle_gnu_style_compiler()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
handle_msvc_style_compiler()
# Use updated __cplusplus macro
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
target_compile_options(CpltCore PUBLIC /Zc:__cplusplus)
endif()
endif()
if(CMAKE_UNITY_BUILD)
message("CpltCore: - using unity build")
set_target_properties(CpltCore PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_UNIQUE_ID "CPLT_UNITY_ID"
)
else()
message("CpltCore: - using regular build")
endif()
|