This repository has been archived by the owner on May 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
158 lines (122 loc) · 4.2 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
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
cmake_minimum_required(VERSION 3.13.0)
project(igx)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
file(GLOB_RECURSE igxHpp "include/*.hpp")
file(GLOB_RECURSE igxCpp "src/*.cpp")
file(GLOB_RECURSE depsHpp "third_party/include/*.hpp")
file(GLOB_RECURSE depsCpp "third_party/src/*.cpp")
file(GLOB_RECURSE testsCpp "test/*.cpp")
add_subdirectory(igxi-tool)
# Setup test data
set(doShaderRecreate TRUE CACHE BOOL "Enable shader recompilation")
set(enableIgxTest TRUE CACHE BOOL "Enable IGX test")
file(GLOB_RECURSE shaders "res/shaders/*.comp" "res/shaders/*.vert" "res/shaders/*.frag" "res/test_shaders/*.comp" "res/test_shaders/*.vert" "res/test_shaders/*.frag")
file(GLOB_RECURSE shaderBinaries "res/shaders/*.spv")
file(GLOB_RECURSE shaderTestBinaries "res/test_shaders/*.spv")
file(GLOB_RECURSE fonts "res/fonts/*.ttf")
if(doShaderRecreate)
if("$ENV{VULKAN_SDK}" STREQUAL "")
message(FATAL_ERROR "Ignix requires the Vulkan SDK so it can compile the shaders with SPIR-V")
endif()
endif()
# Nuklear dependency
set(enableNuklearBuild FALSE CACHE BOOL "Enable Nuklear header generate")
if(enableNuklearBuild)
file(GLOB_RECURSE nuklear "third_party/Nuklear/src/*.h" "third_party/Nuklear/src/*.c")
add_library(nuklear STATIC ${nuklear})
if(WIN32)
add_custom_command(TARGET nuklear POST_BUILD COMMAND paq WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third_party/Nuklear/src)
else()
add_custom_command(TARGET nuklear POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Nuklear/src/paq.sh" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third_party/Nuklear/src)
endif()
endif()
# Link library
add_library(
igx STATIC
${igxHpp}
${igxCpp}
${depsHpp}
${depsCpp}
${shaders}
${shaderBinaries}
CMakeLists.txt
third_party/Nuklear/nuklear.h # Add the output of nuklear
)
get_target_property(IGNIS_SOURCE_DIR ignis SOURCE_DIR)
get_target_property(CORE2_SOURCE_DIR ocore SOURCE_DIR)
target_include_directories(igx PUBLIC include)
target_include_directories(igx PRIVATE third_party)
target_include_directories(igx PRIVATE third_party/include)
target_include_directories(igx PUBLIC igxi-tool/include)
target_include_directories(igx PUBLIC igxi-tool/igxi/include)
target_include_directories(igx PUBLIC ${IGNIS_SOURCE_DIR}/include)
target_include_directories(igx PUBLIC ${CORE2_SOURCE_DIR}/include)
target_link_libraries(igx PUBLIC ignis ocore igxi igxi-convert)
if(enableNuklearBuild)
target_link_libraries(igx PRIVATE nuklear)
endif()
source_group("Headers" FILES ${igxHpp})
source_group("Source" FILES ${igxCpp})
source_group("Deps headers" FILES ${depsHpp} third_party/Nuklear/nuklear.h)
source_group("Deps source" FILES ${depsCpp})
source_group("Shaders" FILES ${shaders})
source_group("Shader binaries" FILES ${shaderBinaries})
if(MSVC)
target_compile_options(igx PRIVATE /W4 /WX /MD /MP /wd26812 /wd4201 /EHsc /GR)
else()
target_compile_options(igx PRIVATE -Wall -fms-extensions -Wextra -Werror)
endif()
# Add file dependencies ; the builtin shaders and fonts
add_virtual_files(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/res/shaders
NAME
igx/shaders
FILES
${shaderBinaries}
)
add_virtual_files(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/res/fonts
NAME
igx/fonts
FILES
${fonts}
)
#
if(enableIgxTest)
add_executable(igx_test ${testsCpp})
target_link_libraries(igx_test PUBLIC igx)
add_virtual_files(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/res/test_shaders
NAME
shaders
FILES
${shaderTestBinaries}
)
configure_icon(igx_test "${CMAKE_CURRENT_SOURCE_DIR}/res/icon.ico")
configure_virtual_files(igx_test)
if(doShaderRecreate)
add_custom_command(
TARGET igx_test
PRE_BUILD COMMAND
ARGS
"${CMAKE_CURRENT_SOURCE_DIR}/res/shaders/compile"
"$<$<CONFIG:debug>:-d>"
${shaders}
)
endif()
if(MSVC)
target_compile_options(igx_test PRIVATE /W4 /WX /MD /MP /wd4201 /EHsc /GR)
else()
target_compile_options(igx_test PRIVATE -Wall -Wextra -Werror -fms-extensions)
endif()
endif()