@@ -36,6 +36,7 @@ lxgui_set_option(LXGUI_BUILD_RAPIDYAML TRUE BOOL "Build the rapidyaml dependency
3636lxgui_set_option(LXGUI_ENABLE_XML_PARSER TRUE BOOL "Enable the XML layout parser (if false, XML layout files cannot be read)" )
3737lxgui_set_option(LXGUI_ENABLE_YAML_PARSER TRUE BOOL "Enable the YAML layout parser (if false, YAML layout files cannot be read)" )
3838lxgui_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" )
3940
4041# project name
4142project (lxgui LANGUAGES CXX VERSION 2.0)
@@ -48,36 +49,10 @@ project(lxgui LANGUAGES CXX VERSION 2.0)
4849if (CMAKE_SYSTEM_NAME MATCHES "Emscripten" )
4950 set (LXGUI_COMPILER_EMSCRIPTEN TRUE )
5051elseif (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-
6352 set (LXGUI_COMPILER_GCC TRUE )
6453elseif (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-
6954 set (LXGUI_COMPILER_MSVC TRUE )
7055elseif (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-
8156 set (LXGUI_COMPILER_CLANG TRUE )
8257else ()
8358 message (WARNING "Warning: your compiler has not been setup by the CMake script, do not expect it to work" )
@@ -165,11 +140,22 @@ endif()
165140##############################################################################
166141
167142# find dependencies
168- set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake/" ${CMAKE_MODULE_PATH} )
169-
170143find_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+
171150find_package (Freetype)
172151
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+
173159if (NOT LXGUI_COMPILER_EMSCRIPTEN)
174160 find_package (PNG)
175161 find_package (ZLIB)
@@ -181,58 +167,13 @@ if(NOT LXGUI_COMPILER_EMSCRIPTEN)
181167 find_package (SDL2_ttf)
182168endif ()
183169
170+ # configure
184171if (LUA_VERSION_STRING VERSION_GREATER_EQUAL 5.1 AND LUA_VERSION_STRING VERSION_LESS 5.2)
185172 set (LXGUI_LUA51 TRUE )
186173endif ()
187174
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-
227175set (SOL_ALL_SAFETIES_ON TRUE )
228176set (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 ()
236177
237178##############################################################################
238179# Main library
@@ -320,13 +261,14 @@ add_library(lxgui::lxgui ALIAS lxgui)
320261target_compile_features (lxgui PUBLIC cxx_std_17)
321262
322263# compilation options
323- lxgui_set_warning_level(lxgui)
264+ if (LXGUI_DEV)
265+ lxgui_set_warning_level(lxgui)
266+ endif ()
324267target_include_directories (lxgui PUBLIC
325268 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >
326269 $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX} /include >)
327270
328271# needed dependencies
329- target_link_libraries (lxgui PUBLIC Lua::Lua)
330272target_link_libraries (lxgui PUBLIC sol2::sol2)
331273target_link_libraries (lxgui PUBLIC fmt::fmt)
332274target_link_libraries (lxgui PUBLIC oup::oup)
@@ -361,7 +303,7 @@ file(GLOB files ${PROJECT_SOURCE_DIR}/include/lxgui/*.hpp)
361303install (FILES ${files} DESTINATION ${CMAKE_INSTALL_PREFIX} /include /lxgui)
362304install (FILES "${PROJECT_BINARY_DIR} /lxgui/lxgui.hpp" DESTINATION ${CMAKE_INSTALL_PREFIX} /include /lxgui)
363305
364- set (LXGUI_INSTALL_TARGETS lxgui utf8cpp )
306+ set (LXGUI_INSTALL_TARGETS lxgui)
365307
366308##############################################################################
367309# Back-ends
@@ -371,46 +313,39 @@ if(LXGUI_BUILD_GUI_GL_IMPL)
371313 if ((OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND) OR LXGUI_COMPILER_EMSCRIPTEN)
372314 add_subdirectory (impl/gui/gl)
373315 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" )
376317 endif ()
377318endif ()
378319if (LXGUI_BUILD_GUI_SFML_IMPL)
379320 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" )
382322 elseif (SFML_FOUND)
383323 add_subdirectory (impl/gui/sfml)
384324 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" )
387326 endif ()
388327endif ()
389328if (LXGUI_BUILD_INPUT_SFML_IMPL)
390329 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" )
393331 elseif (SFML_FOUND)
394332 add_subdirectory (impl/input /sfml)
395333 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" )
398335 endif ()
399336endif ()
400337if (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)
402339 add_subdirectory (impl/gui/sdl)
403340 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" )
406342 endif ()
407343endif ()
408344if (LXGUI_BUILD_INPUT_SDL_IMPL)
409345 if (SDL2_FOUND OR LXGUI_COMPILER_EMSCRIPTEN)
410346 add_subdirectory (impl/input /sdl)
411347 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" )
414349 endif ()
415350endif ()
416351
@@ -474,9 +409,6 @@ write_basic_package_version_file(
474409install (FILES
475410 "${PROJECT_BINARY_DIR} /lxgui-config.cmake"
476411 "${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"
480412 DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/lxgui COMPONENT Development)
481413
482414##############################################################################
@@ -485,34 +417,35 @@ install(FILES
485417
486418if (LXGUI_BUILD_TEST)
487419 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" )
489421 set (LXGUI_TEST_IMPLEMENTATION "SDL" )
490422 endif ()
423+
491424 if (LXGUI_TEST_IMPLEMENTATION STREQUAL "OPENGL_SFML" )
492425 if (OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND AND SFML_FOUND)
493426 add_subdirectory (test )
494427 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." )
496429 endif ()
497430 elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "OPENGL_SDL" )
498431 if ((OPENGL_FOUND AND GLEW_FOUND AND FREETYPE_FOUND AND PNG_FOUND AND ZLIB_FOUND AND SDL2_FOUND) OR LXGUI_COMPILER_EMSCRIPTEN)
499432 add_subdirectory (test )
500433 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." )
502435 endif ()
503436 elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "SDL" )
504437 if ((SDL2_FOUND AND SDL2_TTF_FOUND AND SDL2_IMAGE_FOUND) OR LXGUI_COMPILER_EMSCRIPTEN)
505438 add_subdirectory (test )
506439 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." )
508441 endif ()
509442 elseif (LXGUI_TEST_IMPLEMENTATION STREQUAL "SFML" )
510443 if (SFML_FOUND)
511444 add_subdirectory (test )
512445 else ()
513- message (ERROR ": the test program requires SFML." )
446+ message (SEND_ERROR ": the test program requires SFML." )
514447 endif ()
515448 else ()
516- message (ERROR ": unknown implementation ${LXGUI_TEST_IMPLEMENTATION} " )
449+ message (SEND_ERROR ": unknown implementation ${LXGUI_TEST_IMPLEMENTATION} " )
517450 endif ()
518451endif ()
0 commit comments