@@ -36,6 +36,7 @@ lxgui_set_option(LXGUI_BUILD_RAPIDYAML TRUE BOOL "Build the rapidyaml dependency
36
36
lxgui_set_option (LXGUI_ENABLE_XML_PARSER TRUE BOOL "Enable the XML layout parser (if false, XML layout files cannot be read)" )
37
37
lxgui_set_option (LXGUI_ENABLE_YAML_PARSER TRUE BOOL "Enable the YAML layout parser (if false, YAML layout files cannot be read)" )
38
38
lxgui_set_option (LXGUI_TEST_IMPLEMENTATION "SFML" STRING "Which implementation to test (SFML/SDL/OPENGL_SFML/OPENGL_SDL)" )
39
+ lxgui_set_option (LXGUI_DEV FALSE BOOL "Enable compiler options for development (warnings etc), not recommended for release" )
39
40
40
41
# project name
41
42
project (lxgui LANGUAGES CXX VERSION 2.0 )
@@ -48,36 +49,10 @@ project(lxgui LANGUAGES CXX VERSION 2.0)
48
49
if (CMAKE_SYSTEM_NAME MATCHES "Emscripten" )
49
50
set (LXGUI_COMPILER_EMSCRIPTEN TRUE )
50
51
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
51
- execute_process (COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion
52
- OUTPUT_VARIABLE GCC_VERSION )
53
-
54
- string (REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION} )
55
- list (GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR )
56
- list (GET GCC_VERSION_COMPONENTS 1 GCC_MINOR )
57
- set (GCC_VERSION ${GCC_MAJOR} .${GCC_MINOR} )
58
-
59
- if (GCC_VERSION VERSION_LESS 8.0 )
60
- message (ERROR ": lxgui requires advanced features from the C++17 norm that are only available with gcc 8 or higher (your version: ${GCC_VERSION} ). Please upgrade your compiler." )
61
- endif ()
62
-
63
52
set (LXGUI_COMPILER_GCC TRUE )
64
53
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
65
- if (MSVC_VERSION VERSION_LESS 1910 )
66
- message (ERROR ": lxgui requires advanced features from the C++17 norm that are only available with MSVC 2017 or higher (version 1910, your version: ${MSVC_VERSION} ). Please upgrade your compiler." )
67
- endif ()
68
-
69
54
set (LXGUI_COMPILER_MSVC TRUE )
70
55
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
71
- if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
72
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11 )
73
- message (ERROR ": lxgui requires advanced features from the C++17 norm that are only available with Xcode 11 or higher (your version: ${CMAKE_CXX_COMPILER_VERSION} ). Please upgrade your compiler." )
74
- endif ()
75
- else ()
76
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7 )
77
- message (ERROR ": lxgui requires advanced features from the C++17 norm that are only available with clang 7 or higher (your version: ${CMAKE_CXX_COMPILER_VERSION} ). Please upgrade your compiler." )
78
- endif ()
79
- endif ()
80
-
81
56
set (LXGUI_COMPILER_CLANG TRUE )
82
57
else ()
83
58
message (WARNING "Warning: your compiler has not been setup by the CMake script, do not expect it to work" )
@@ -165,11 +140,22 @@ endif()
165
140
##############################################################################
166
141
167
142
# find dependencies
168
- set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/" ${CMAKE_MODULE_PATH} )
169
-
170
143
find_package (Lua REQUIRED )
144
+ find_package (sol2 REQUIRED )
145
+ find_package (utf8cpp REQUIRED )
146
+ find_package (oup REQUIRED )
147
+ find_package (fmt REQUIRED )
148
+ find_package (magic_enum REQUIRED )
149
+
171
150
find_package (Freetype )
172
151
152
+ if (LXGUI_ENABLE_XML_PARSER )
153
+ find_package (pugixml REQUIRED )
154
+ endif ()
155
+ if (LXGUI_ENABLE_YAML_PARSER )
156
+ find_package (ryml REQUIRED )
157
+ endif ()
158
+
173
159
if (NOT LXGUI_COMPILER_EMSCRIPTEN )
174
160
find_package (PNG )
175
161
find_package (ZLIB )
@@ -181,58 +167,13 @@ if(NOT LXGUI_COMPILER_EMSCRIPTEN)
181
167
find_package (SDL2_ttf )
182
168
endif ()
183
169
170
+ # configure
184
171
if (LUA_VERSION_STRING VERSION_GREATER_EQUAL 5.1 AND LUA_VERSION_STRING VERSION_LESS 5.2 )
185
172
set (LXGUI_LUA51 TRUE )
186
173
endif ()
187
174
188
- # add the subdirectories for dependencies
189
- add_subdirectory (extern/utfcpp )
190
-
191
- add_subdirectory (extern/observable_unique_ptr )
192
-
193
- set (MAGIC_ENUM_OPT_INSTALL 1 )
194
- add_subdirectory (extern/magic_enum )
195
-
196
- if (LXGUI_BUILD_FMT )
197
- set (FMT_INSTALL TRUE )
198
- add_subdirectory (extern/fmt )
199
- else ()
200
- find_package (fmt REQUIRED )
201
- endif ()
202
-
203
- if (LXGUI_ENABLE_XML_PARSER )
204
- if (LXGUI_BUILD_PUGIXML )
205
- add_subdirectory (extern/pugixml )
206
- else ()
207
- find_package (pugixml )
208
- if (NOT TARGET pugixml::pugixml )
209
- message (ERROR ": the XML parser requires pugixml, which is missing. XML parsing will be disabled." )
210
- set (LXGUI_ENABLE_XML_PARSER FALSE )
211
- endif ()
212
- endif ()
213
- endif ()
214
-
215
- if (LXGUI_ENABLE_YAML_PARSER )
216
- if (LXGUI_BUILD_RAPIDYAML )
217
- add_subdirectory (extern/rapidyaml )
218
- else ()
219
- find_package (ryml )
220
- if (NOT TARGET ryml::ryml )
221
- message (ERROR ": the YAML parser requires rapidyaml, which is missing. YAML parsing will be disabled." )
222
- set (LXGUI_ENABLE_YAML_PARSER FALSE )
223
- endif ()
224
- endif ()
225
- endif ()
226
-
227
175
set (SOL_ALL_SAFETIES_ON TRUE )
228
176
set (SOL_PRINT_ERRORS FALSE )
229
- if (LXGUI_BUILD_SOL2 )
230
- set (SOL2_BUILD_LUA FALSE CACHE BOOL "" )
231
- set (SOL2_ENABLE_INSTALL TRUE )
232
- add_subdirectory (extern/sol2 )
233
- else ()
234
- find_package (sol2 REQUIRED )
235
- endif ()
236
177
237
178
##############################################################################
238
179
# Main library
@@ -320,13 +261,14 @@ add_library(lxgui::lxgui ALIAS lxgui)
320
261
target_compile_features (lxgui PUBLIC cxx_std_17 )
321
262
322
263
# compilation options
323
- lxgui_set_warning_level (lxgui )
264
+ if (LXGUI_DEV )
265
+ lxgui_set_warning_level (lxgui )
266
+ endif ()
324
267
target_include_directories (lxgui PUBLIC
325
268
$< BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include>
326
269
$< INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX} /include> )
327
270
328
271
# needed dependencies
329
- target_link_libraries (lxgui PUBLIC Lua::Lua )
330
272
target_link_libraries (lxgui PUBLIC sol2::sol2 )
331
273
target_link_libraries (lxgui PUBLIC fmt::fmt )
332
274
target_link_libraries (lxgui PUBLIC oup::oup )
@@ -361,7 +303,7 @@ file(GLOB files ${PROJECT_SOURCE_DIR}/include/lxgui/*.hpp)
361
303
install (FILES ${files} DESTINATION ${CMAKE_INSTALL_PREFIX} /include/lxgui )
362
304
install (FILES "${PROJECT_BINARY_DIR} /lxgui/lxgui.hpp" DESTINATION ${CMAKE_INSTALL_PREFIX} /include/lxgui )
363
305
364
- set (LXGUI_INSTALL_TARGETS lxgui utf8cpp )
306
+ set (LXGUI_INSTALL_TARGETS lxgui )
365
307
366
308
##############################################################################
367
309
# Back-ends
@@ -371,46 +313,39 @@ if(LXGUI_BUILD_GUI_GL_IMPL)
371
313
if ((OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND ) OR LXGUI_COMPILER_EMSCRIPTEN )
372
314
add_subdirectory (impl/gui/gl )
373
315
else ()
374
- message (ERROR ": the OpenGL implementation of the GUI requires OpenGL, GLEW, freetype, libpng and zlib" )
375
- set (LXGUI_BUILD_GUI_GL_IMPL FALSE )
316
+ message (SEND_ERROR ": the OpenGL implementation of the GUI requires OpenGL, GLEW, freetype, libpng and zlib" )
376
317
endif ()
377
318
endif ()
378
319
if (LXGUI_BUILD_GUI_SFML_IMPL )
379
320
if (LXGUI_COMPILER_EMSCRIPTEN )
380
- message (ERROR ": the SFML implementation of the GUI is not supported with Emscripten" )
381
- set (LXGUI_BUILD_GUI_SFML_IMPL FALSE )
321
+ message (SEND_ERROR ": the SFML implementation of the GUI is not supported with Emscripten" )
382
322
elseif (SFML_FOUND )
383
323
add_subdirectory (impl/gui/sfml )
384
324
else ()
385
- message (ERROR ": the SFML implementation of the GUI requires the SFML library" )
386
- set (LXGUI_BUILD_GUI_SFML_IMPL FALSE )
325
+ message (SEND_ERROR ": the SFML implementation of the GUI requires the SFML library" )
387
326
endif ()
388
327
endif ()
389
328
if (LXGUI_BUILD_INPUT_SFML_IMPL )
390
329
if (LXGUI_COMPILER_EMSCRIPTEN )
391
- message (ERROR ": the SFML implementation of the input is not supported with Emscripten" )
392
- set (LXGUI_BUILD_INPUT_SFML_IMPL FALSE )
330
+ message (SEND_ERROR ": the SFML implementation of the input is not supported with Emscripten" )
393
331
elseif (SFML_FOUND )
394
332
add_subdirectory (impl/input/sfml )
395
333
else ()
396
- message (ERROR ": the SFML implementation of the input requires the SFML library" )
397
- set (LXGUI_BUILD_INPUT_SFML_IMPL FALSE )
334
+ message (SEND_ERROR ": the SFML implementation of the input requires the SFML library" )
398
335
endif ()
399
336
endif ()
400
337
if (LXGUI_BUILD_GUI_SDL_IMPL )
401
- if ((SDL2_FOUND AND SDL2_TTF_FOUND AND SDL2_IMAGE_FOUND ) OR LXGUI_COMPILER_EMSCRIPTEN )
338
+ if ((SDL2_FOUND AND SDL2_ttf_FOUND AND SDL2_image_FOUND ) OR LXGUI_COMPILER_EMSCRIPTEN )
402
339
add_subdirectory (impl/gui/sdl )
403
340
else ()
404
- message (ERROR ": the SDL implementation of the GUI requires the SDL2, SDL2_ttf, and SDL2_image libraries" )
405
- set (LXGUI_BUILD_GUI_SDL_IMPL FALSE )
341
+ message (SEND_ERROR ": the SDL implementation of the GUI requires the SDL2, SDL2_ttf, and SDL2_image libraries" )
406
342
endif ()
407
343
endif ()
408
344
if (LXGUI_BUILD_INPUT_SDL_IMPL )
409
345
if (SDL2_FOUND OR LXGUI_COMPILER_EMSCRIPTEN )
410
346
add_subdirectory (impl/input/sdl )
411
347
else ()
412
- message (ERROR ": the SDL implementation of the input requires the SDL library" )
413
- set (LXGUI_BUILD_INPUT_SDL_IMPL FALSE )
348
+ message (SEND_ERROR ": the SDL implementation of the input requires the SDL library" )
414
349
endif ()
415
350
endif ()
416
351
@@ -474,9 +409,6 @@ write_basic_package_version_file(
474
409
install (FILES
475
410
"${PROJECT_BINARY_DIR} /lxgui-config.cmake"
476
411
"${PROJECT_BINARY_DIR} /lxgui-config-version.cmake"
477
- "${PROJECT_SOURCE_DIR} /cmake/FindLua.cmake"
478
- "${PROJECT_SOURCE_DIR} /cmake/FindSDL2_image.cmake"
479
- "${PROJECT_SOURCE_DIR} /cmake/FindSDL2_ttf.cmake"
480
412
DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/lxgui COMPONENT Development )
481
413
482
414
##############################################################################
@@ -485,34 +417,35 @@ install(FILES
485
417
486
418
if (LXGUI_BUILD_TEST )
487
419
if (LXGUI_COMPILER_EMSCRIPTEN AND NOT (LXGUI_TEST_IMPLEMENTATION STREQUAL "SDL" OR LXGUI_TEST_IMPLEMENTATION STREQUAL "OPENGL_SDL" ))
488
- message (WARNING "Warning : the test program only supports SDL or OPENGL_SDL when compiled with Emscripten" )
420
+ message (WARNING ": the test program only supports SDL or OPENGL_SDL when compiled with Emscripten" )
489
421
set (LXGUI_TEST_IMPLEMENTATION "SDL" )
490
422
endif ()
423
+
491
424
if (LXGUI_TEST_IMPLEMENTATION STREQUAL "OPENGL_SFML" )
492
425
if (OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND AND SFML_FOUND )
493
426
add_subdirectory (test )
494
427
else ()
495
- message (ERROR ": the test program requires OpenGL, GLEW, freetype, libpng, zlib and SFML." )
428
+ message (SEND_ERROR ": the test program requires OpenGL, GLEW, freetype, libpng, zlib and SFML." )
496
429
endif ()
497
430
elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "OPENGL_SDL" )
498
431
if ((OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND AND SDL2_FOUND ) OR LXGUI_COMPILER_EMSCRIPTEN )
499
432
add_subdirectory (test )
500
433
else ()
501
- message (ERROR ": the test program requires OpenGL, GLEW, freetype, libpng, zlib and SDL." )
434
+ message (SEND_ERROR ": the test program requires OpenGL, GLEW, freetype, libpng, zlib and SDL." )
502
435
endif ()
503
436
elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "SDL" )
504
437
if ((SDL2_FOUND AND SDL2_TTF_FOUND AND SDL2_IMAGE_FOUND ) OR LXGUI_COMPILER_EMSCRIPTEN )
505
438
add_subdirectory (test )
506
439
else ()
507
- message (ERROR ": the test program requires SDL2, SDL2_ttf, and SDL2_image." )
440
+ message (SEND_ERROR ": the test program requires SDL2, SDL2_ttf, and SDL2_image." )
508
441
endif ()
509
442
elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "SFML" )
510
443
if (SFML_FOUND )
511
444
add_subdirectory (test )
512
445
else ()
513
- message (ERROR ": the test program requires SFML." )
446
+ message (SEND_ERROR ": the test program requires SFML." )
514
447
endif ()
515
448
else ()
516
- message (ERROR ": unknown implementation ${LXGUI_TEST_IMPLEMENTATION} " )
449
+ message (SEND_ERROR ": unknown implementation ${LXGUI_TEST_IMPLEMENTATION} " )
517
450
endif ()
518
451
endif ()
0 commit comments