Tue, 06 Jul 2021 10:22:49 +0300
* Image/Bitmap rotate
1573 | 1 | cmake_minimum_required(VERSION 3.5) |
2 | cmake_policy(VERSION 3.5) | |
814 | 3 | |
4 | project(Gorgon) | |
983 | 5 | add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Tools/ShaderEmbedder") |
6 | ||
814 | 7 | set(GORGON_MAJOR_VERSION 4) |
8 | set(GORGON_MINOR_VERSION 0) | |
9 | set(GORGON_PATCH_VERSION 0) | |
10 | set(GORGON_VERSION_ALPHA 1) | |
11 | set(GORGON_VERSION ${GORGON_MAJOR_VERSION}.${GORGON_MINOR_VERSION}.${GORGON_PATCH_VERSION}) | |
12 | ||
13 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Lib) | |
14 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Lib) | |
15 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Bin) | |
16 | set(CMAKE_TESTING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Testing) | |
17 | set(CMAKE_DOCUMENT_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Docs) | |
18 | set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/Bin) | |
19 | set(PROJECT_PACKAGE_DIR ${CMAKE_CURRENT_LIST_DIR}/Package) | |
20 | ||
1573 | 21 | set(gorgon_external_options "" NONE BUILTIN SYSTEM) |
22 | ||
814 | 23 | #### SETTINGS #### |
24 | ||
25 | option(OPENGL "Use OpenGL as underlying GL. Should be ON for now." ON) | |
199 | 26 | |
814 | 27 | option(AUDIO "Enable audio." ON) |
28 | ||
29 | option(GORGON_FAST_ANY "Make any to work fast by removing empty checks. This will only apply to release mode." OFF) | |
30 | ||
31 | option(SCRIPTING "Enable scripting module." ON) | |
32 | ||
1282 | 33 | option(GSCRIPT_GENERATOR "Create scripting resources." OFF) |
34 | ||
814 | 35 | option(NO_LOGGING "Disables logger globally. If set, unit tests for logging will fail." OFF) |
36 | ||
37 | option(TESTMODE "Enable test mode." OFF) | |
38 | ||
39 | option(DOCUMENTATION_GRAPHS "Enable graphs in documentation." OFF) | |
40 | ||
1010 | 41 | option(TESTS "Enable compiling of test applications." OFF) |
814 | 42 | |
1581 | 43 | if(WIN32) |
44 | set(FLAC BUILTIN CACHE STRING "Enable FLAC decoding and streaming.") | |
45 | else() | |
46 | set(FLAC SYSTEM CACHE STRING "Enable FLAC decoding and streaming.") | |
47 | endif() | |
48 | if(NOT FLAC IN_LIST gorgon_external_options) | |
49 | message(FATAL_ERROR "FLAC should be set to one of ${gorgon_external_options}") | |
50 | endif() | |
51 | set_property(CACHE FLAC PROPERTY STRINGS ${gorgon_external_options}) | |
52 | ||
870 | 53 | |
1010 | 54 | option(UI "Enable UI subsystem." ON) |
55 | ||
1573 | 56 | if(WIN32) |
57 | set(FREETYPE BUILTIN CACHE STRING "Enable FreeType font support") | |
58 | else() | |
59 | set(FREETYPE SYSTEM CACHE STRING "Enable FreeType font support") | |
60 | endif() | |
61 | if("${FREETYPE}" STREQUAL "ON") #upgrading old options | |
62 | set(FREETYPE SYSTEM CACHE STRING "Enable FreeType font support" FORCE) | |
63 | endif() | |
64 | if(NOT FREETYPE IN_LIST gorgon_external_options) | |
65 | message(FATAL_ERROR "FREETYPE should be set to one of ${gorgon_external_options}") | |
66 | endif() | |
67 | set_property(CACHE FREETYPE PROPERTY STRINGS ${gorgon_external_options}) | |
1129 | 68 | |
1582 | 69 | if(WIN32) |
1656
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
70 | set(VORBIS BUILTIN CACHE STRING "Enable Vorbis audio support") |
1582 | 71 | else() |
1656
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
72 | set(VORBIS SYSTEM CACHE STRING "Enable Vorbis audio support") |
1582 | 73 | endif() |
74 | if(NOT VORBIS IN_LIST gorgon_external_options) | |
75 | message(FATAL_ERROR "VORBIS should be set to one of ${gorgon_external_options}") | |
76 | endif() | |
77 | set_property(CACHE VORBIS PROPERTY STRINGS ${gorgon_external_options}) | |
78 | ||
1656
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
79 | if(WIN32) |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
80 | set(FONTCONFIG NONE CACHE STRING "Enable Font config support") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
81 | else() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
82 | set(FONTCONFIG SYSTEM CACHE STRING "Enable Font config support") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
83 | endif() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
84 | if("${FONTCONFIG}" STREQUAL "ON") #upgrading old options |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
85 | set(FONTCONFIG SYSTEM CACHE STRING "Enable FreeType font support" FORCE) |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
86 | endif() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
87 | if(NOT FONTCONFIG IN_LIST gorgon_external_options) |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
88 | message(FATAL_ERROR "FONTCONFIG should be set to one of ${gorgon_external_options}") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
89 | endif() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
90 | set_property(CACHE FONTCONFIG PROPERTY STRINGS ${gorgon_external_options}) |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
91 | |
1123 | 92 | OPTION(FORCE_32_BIT "Force 32 bit compilation" OFF) |
93 | ||
814 | 94 | set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") |
95 | ||
96 | set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") | |
97 | ||
821 | 98 | set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") |
814 | 99 | |
100 | ###################### | |
199 | 101 | |
1282 | 102 | if(GSCRIPT_GENERATOR) |
103 | add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Tools/GscriptGenerator") | |
104 | endif() | |
105 | ||
1149 | 106 | set(ADDITIONAL_CLIENT_FLAGS ) |
107 | ||
1123 | 108 | if(NOT(${FORCE_32_BIT})) |
109 | set(FIND_LIBRARY_USE_LIB64_PATHS ON) | |
110 | if(NOT WIN32) | |
111 | list(INSERT 0 CMAKE_SYSTEM_LIBRARY_PATH /usr/lib64) | |
112 | endif() | |
113 | endif() | |
114 | ||
416 | 115 | |
815 | 116 | if(AUDIO AND (NOT AUDIOLIB OR AUDIOLIB STREQUAL "")) |
814 | 117 | if(WIN32) |
853
c1c0902254ae
* Audio playback for simple controllers on PulseAudio
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
839
diff
changeset
|
118 | set(AUDIOLIB WASAPI) |
814 | 119 | else() |
120 | set(AUDIOLIB PULSE) | |
121 | endif() | |
122 | endif() | |
539 | 123 | |
839 | 124 | if(AUDIO) |
125 | add_definitions("-DAUDIO") | |
853
c1c0902254ae
* Audio playback for simple controllers on PulseAudio
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
839
diff
changeset
|
126 | add_definitions("-DAUDIO_${AUDIOLIB}") |
1149 | 127 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DAUDIO") |
128 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DAUDIO_${AUDIOLIB}") | |
839 | 129 | endif() |
130 | ||
1581 | 131 | if(FREETYPE STREQUAL "SYSTEM" OR FREETYPE STREQUAL "BUILTIN") |
132 | add_definitions("-DFREETYPE_SUPPORT") | |
133 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DFREETYPE_SUPPORT") | |
134 | endif() | |
135 | ||
136 | if(FLAC STREQUAL "SYSTEM" OR FLAC STREQUAL "BUILTIN") | |
137 | add_definitions("-DFLAC_SUPPORT") | |
138 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DFLAC_SUPPORT") | |
1129 | 139 | endif() |
140 | ||
1582 | 141 | if(VORBIS STREQUAL "SYSTEM" OR VORBIS STREQUAL "BUILTIN") |
142 | add_definitions("-DVORBIS_SUPPORT") | |
143 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DVORBIS_SUPPORT") | |
144 | endif() | |
145 | ||
1656
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
146 | if(FONTCONFIG STREQUAL "SYSTEM" OR FONTCONFIG STREQUAL "BUILTIN") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
147 | add_definitions("-DFONTCONFIG_SUPPORT") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
148 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DFONTCONFIG_SUPPORT") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
149 | endif() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
150 | |
839 | 151 | if(SCRIPTING) |
152 | add_definitions("-DSCRIPTING") | |
1149 | 153 | string(APPEND ADDITIONAL_CLIENT_FLAGS " -DSCRIPTING") |
839 | 154 | endif() |
155 | ||
1135 | 156 | if(OPENGL) |
157 | set(OpenGL_GL_PREFERENCE "LEGACY") | |
158 | endif() | |
159 | ||
814 | 160 | if(DOCUMENTATION_GRAPHS) |
161 | set(DOXYGRAPH YES) | |
162 | else() | |
163 | set(DOXYGRAPH NO) | |
164 | endif() | |
752 | 165 | |
814 | 166 | if(TESTMODE) |
167 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST") | |
168 | endif() | |
169 | ||
170 | if(NO_LOGGING) | |
171 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_LOGGING") | |
172 | endif() | |
173 | ||
174 | if(GORGON_FAST_ANY) | |
175 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DGORGON_FAST_ANY") | |
176 | endif() | |
808
94ef6d47c4fd
* Skeleton for PulseAudio
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
177 | |
814 | 178 | if(OPENGL) |
179 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENGL") | |
180 | endif() | |
752 | 181 | |
1387 | 182 | if(UI) |
183 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_UI") | |
184 | endif() | |
185 | ||
814 | 186 | if(UNIX) |
187 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX -Werror=return-type") | |
188 | else() | |
189 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") | |
190 | endif() | |
810 | 191 | |
1387 | 192 | |
814 | 193 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLM_SWIZZLE -DGLM_FORCE_RADIANS") |
416 | 194 | |
814 | 195 | # Make relative paths absolute (needed later on) |
196 | foreach(p LIB BIN INCLUDE CMAKE) | |
197 | set(var INSTALL_${p}_DIR) | |
198 | if(NOT IS_ABSOLUTE "${${var}}") | |
199 | set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") | |
200 | endif() | |
201 | endforeach() | |
469
204f261413ae
* An empty GL module marking separation for GL related function from Graphics module
cemkalyoncu
parents:
450
diff
changeset
|
202 | |
814 | 203 | include(Scripts/Compiler.cmake) |
431 | 204 | |
814 | 205 | include(Scripts/Macros.cmake) |
415
001cd0eb15db
* CMake scripts does not need to specify paths anymore
cemkalyoncu
parents:
414
diff
changeset
|
206 | |
814 | 207 | set(DebugLibs "") |
208 | set(OptimizedLibs "") | |
795
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
793
diff
changeset
|
209 | |
764
7c71952bd75b
Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
752
diff
changeset
|
210 | StartSource(Source/Gorgon) |
414 | 211 | |
1634 | 212 | |
1010 | 213 | if(TESTS) |
814 | 214 | include(Scripts/Testing.cmake) |
215 | endif() | |
216 | ||
217 | include(Scripts/Doxygen.cmake) | |
218 | ||
219 | add_library(Gorgon STATIC ${All}) | |
416 | 220 | |
1362 | 221 | if(MSVC) |
222 | target_compile_options(Gorgon PRIVATE "/MP") | |
223 | endif() | |
224 | ||
1005 | 225 | set_property(TARGET Gorgon PROPERTY CXX_STANDARD 14) |
226 | ||
1319 | 227 | #if(WIN32) |
1165 | 228 | set_target_properties(Gorgon PROPERTIES |
229 | DEBUG_OUTPUT_NAME Gorgon_d | |
230 | RELWITHDEBINFO_OUTPUT_NAME Gorgon_rd | |
231 | MINSIZEREL_OUTPUT_NAME Gorgon_min | |
232 | ) | |
1319 | 233 | #endif() |
1165 | 234 | |
983 | 235 | if(NOT ${deps} STREQUAL "") |
236 | add_dependencies(Gorgon ${deps}) | |
237 | endif() | |
238 | ||
239 | ||
814 | 240 | include_directories(Source/External) |
241 | include_directories(Source) | |
242 | ||
243 | target_link_libraries(Gorgon ${Libs}) | |
244 | ||
245 | if(NOT DebugLibs STREQUAL "") | |
246 | target_link_libraries(Gorgon debug ${DebugLibs}) | |
247 | endif() | |
448 | 248 | |
814 | 249 | if(NOT OptimizedLibs STREQUAL "") |
250 | target_link_libraries(Gorgon optimized ${OptimizedLibs}) | |
251 | endif() | |
252 | ||
870 | 253 | |
254 | install(TARGETS Gorgon | |
255 | EXPORT GorgonTargets | |
256 | ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" | |
257 | PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/Gorgon" | |
258 | ) | |
259 | ||
260 | ||
814 | 261 | export(TARGETS Gorgon FILE "${PROJECT_PACKAGE_DIR}/GorgonTargets.cmake") |
262 | export(PACKAGE Gorgon) | |
263 | ||
1581 | 264 | if(FLAC STREQUAL "BUILTIN") |
870 | 265 | add_subdirectory(Source/External/flac) |
266 | ||
267 | include_directories(Source/External/flac/include) | |
268 | ||
269 | add_definitions("-DFLAC__NO_DLL") | |
270 | ||
271 | target_link_libraries(Gorgon flac) | |
272 | endif() | |
1581 | 273 | |
1573 | 274 | if(FREETYPE STREQUAL "BUILTIN") |
275 | add_subdirectory(Source/External/freetype) | |
276 | ||
277 | include_directories(Source/External/freetype/include) | |
1634 | 278 | set(FREETYPE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/Source/External/freetype/include) |
1573 | 279 | |
280 | target_link_libraries(Gorgon freetype) | |
281 | endif() | |
870 | 282 | |
1582 | 283 | if(VORBIS STREQUAL "BUILTIN") |
284 | add_subdirectory(Source/External/vorbis) | |
285 | ||
286 | include_directories(Source/External/vorbis/include) | |
287 | ||
288 | target_link_libraries(Gorgon vorbis) | |
1583 | 289 | |
290 | add_subdirectory(Source/External/ogg) | |
291 | ||
292 | include_directories(Source/External/ogg/include) | |
1582 | 293 | endif() |
294 | ||
1656
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
295 | if(FONTCONFIG STREQUAL "BUILTIN") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
296 | message(FATAL_ERROR "Built-in fontconfig is not supported yet.") |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
297 | endif() |
ce2a730bc7aa
* Listing fonts installed in the operating system
cemkalyoncu
parents:
1634
diff
changeset
|
298 | |
1050 | 299 | if(WIN32) |
300 | add_definitions("-DDWM") | |
301 | else() | |
302 | add_definitions("-DX11") | |
303 | endif() | |
304 | ||
814 | 305 | file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" |
306 | "${INSTALL_INCLUDE_DIR}") | |
307 | ||
308 | set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Source") | |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
792
diff
changeset
|
309 | |
814 | 310 | configure_file(Scripts/GorgonConfig.cmake.in |
311 | "${PROJECT_PACKAGE_DIR}/GorgonConfig.cmake" @ONLY) | |
312 | ||
830
dc937409ad24
* Partial design document
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
821
diff
changeset
|
313 | set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Source") |
814 | 314 | configure_file(Scripts/GorgonConfig.cmake.in |
315 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/GorgonConfig.cmake" @ONLY) | |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
792
diff
changeset
|
316 | |
814 | 317 | configure_file(Scripts/GorgonConfigVersion.cmake.in |
318 | "${PROJECT_PACKAGE_DIR}/GorgonConfigVersion.cmake" @ONLY) | |
319 | ||
320 | install(FILES | |
321 | "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/GorgonConfig.cmake" | |
322 | "${PROJECT_PACKAGE_DIR}/GorgonConfigVersion.cmake" | |
323 | DESTINATION "${INSTALL_CMAKE_DIR}" | |
324 | ) | |
325 | ||
326 | install(EXPORT GorgonTargets DESTINATION "${INSTALL_CMAKE_DIR}") |