|
|
@@ -1,1153 +1,213 @@
|
|
|
-#===================================
|
|
|
-# Build script for RmlUi ===========
|
|
|
-#===================================
|
|
|
-
|
|
|
-cmake_minimum_required(VERSION 3.5)
|
|
|
-
|
|
|
-if(APPLE)
|
|
|
- # This has to be before most other options so CMake properly handles the
|
|
|
- # compiler variables, it MUST bebefore the project() definition
|
|
|
- if(IOS_PLATFORM)
|
|
|
- set(CMAKE_TOOLCHAIN_FILE CMake/Platform/iOS.cmake)
|
|
|
- endif(IOS_PLATFORM)
|
|
|
-
|
|
|
- option(BUILD_UNIVERSAL_BINARIES "Build universal binaries for all architectures supported" ON)
|
|
|
- if (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
|
|
|
- if(IOS)
|
|
|
- # set the architecture for iOS
|
|
|
- if (${IOS_PLATFORM} STREQUAL "OS")
|
|
|
- set (IOS_ARCH armv6 armv7 armv7s arm64)
|
|
|
- set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
|
|
|
- else (${IOS_PLATFORM} STREQUAL "OS")
|
|
|
- set (IOS_ARCH x86_64)
|
|
|
- set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS Simulator")
|
|
|
- endif (${IOS_PLATFORM} STREQUAL "OS")
|
|
|
-
|
|
|
- else(IOS)
|
|
|
- # set the architectures for OS X
|
|
|
- set (OSXI_ARCH x86_64)
|
|
|
- set (CMAKE_OSX_ARCHITECTURES ${OSXI_ARCH} CACHE STRING "Build architecture for OS X universal binaries")
|
|
|
- endif(IOS)
|
|
|
- endif (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
|
|
|
-endif(APPLE)
|
|
|
-
|
|
|
-if(COMMAND cmake_policy)
|
|
|
- cmake_policy(SET CMP0015 NEW)
|
|
|
-endif(COMMAND cmake_policy)
|
|
|
-
|
|
|
-# Enable the use of MACOSX_RPATH by default for CMake v3.0+; this effectively
|
|
|
-# allows plug 'n' play functionality, so to speak -- the resulting shared
|
|
|
-# library files can simply be copied over into the end-user's application
|
|
|
-# bundle or framework bundle. No mucking around with install_name_tool.
|
|
|
-#
|
|
|
-# See also:
|
|
|
-# cmake --help-policy cmp0042
|
|
|
-# http://www.kitware.com/blog/home/post/510
|
|
|
-if(POLICY CMP0042)
|
|
|
- cmake_policy(SET CMP0042 NEW)
|
|
|
-endif(POLICY CMP0042)
|
|
|
-if (POLICY CMP0072)
|
|
|
- cmake_policy (SET CMP0072 NEW)
|
|
|
-endif(POLICY CMP0072)
|
|
|
-if(POLICY CMP0074)
|
|
|
- cmake_policy(SET CMP0074 NEW)
|
|
|
-endif(POLICY CMP0074)
|
|
|
-if(POLICY CMP0092)
|
|
|
- cmake_policy(SET CMP0092 NEW)
|
|
|
-endif(POLICY CMP0092)
|
|
|
-
|
|
|
-project(RmlUi LANGUAGES C CXX VERSION 6.0)
|
|
|
-
|
|
|
-set(RMLUI_VERSION_RELEASE false)
|
|
|
-
|
|
|
-if(RMLUI_VERSION_RELEASE)
|
|
|
- set(RMLUI_VERSION_SUFFIX "")
|
|
|
-else()
|
|
|
- set(RMLUI_VERSION_SUFFIX "-dev")
|
|
|
-endif()
|
|
|
-
|
|
|
-set(RMLUI_VERSION_SHORT ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${RMLUI_VERSION_SUFFIX})
|
|
|
+# Using CMake 3.10 as minimum to support all platforms of interest
|
|
|
+# https://github.com/mikke89/RmlUi/issues/198#issuecomment-1246957062
|
|
|
+cmake_minimum_required(VERSION 3.10...3.27)
|
|
|
+
|
|
|
+project("RmlUi"
|
|
|
+ VERSION "6.0"
|
|
|
+ DESCRIPTION "C++ user interface library based on the HTML and CSS standards"
|
|
|
+ LANGUAGES "C" "CXX"
|
|
|
+)
|
|
|
|
|
|
-list(APPEND CORE_PRIVATE_DEFS RMLUI_VERSION="${RMLUI_VERSION_SHORT}")
|
|
|
+set(RMLUI_VERSION_RELEASE FALSE)
|
|
|
|
|
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
|
- option(BUILD_TESTING "" OFF)
|
|
|
- include(CTest)
|
|
|
-
|
|
|
- if(BUILD_TESTING)
|
|
|
- set(RMLUI_TESTS_ENABLED ON)
|
|
|
- set(VISUAL_TESTS_RML_DIRECTORIES "" CACHE PATH "Specify additional directories containing *.rml test documents for VisualTests. Separate multiple directories by comma.")
|
|
|
- set(VISUAL_TESTS_COMPARE_DIRECTORY "" CACHE PATH "Set the input directory for screenshot comparison performed by VisualTests.")
|
|
|
- set(VISUAL_TESTS_CAPTURE_DIRECTORY "" CACHE PATH "Set the output directory for screenshots generated by VisualTests.")
|
|
|
- endif()
|
|
|
+ set(RMLUI_IS_ROOT_PROJECT TRUE)
|
|
|
endif()
|
|
|
|
|
|
-# paths
|
|
|
-include(GNUInstallDirs)
|
|
|
-
|
|
|
-# Search in the 'cmake' directory for additional CMake modules.
|
|
|
-list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake;${PROJECT_SOURCE_DIR}/CMake/Modules)
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Environment tests ================
|
|
|
-#===================================
|
|
|
+# Add lists of available options for those that support it
|
|
|
+include("CMake/OptionsLists.cmake")
|
|
|
|
|
|
-include(TestForANSIForScope)
|
|
|
-include(TestForANSIStreamHeaders)
|
|
|
-include(TestForSTDNamespace)
|
|
|
+option(BUILD_SHARED_LIBS "CMake standard option. Choose whether to build shared RmlUi libraries." ON)
|
|
|
|
|
|
-#===================================
|
|
|
-# Provide hints as to where depends=
|
|
|
-# might be found =
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{FREETYPE_DIR})
|
|
|
- set(ENV{FREETYPE_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{LUA_DIR})
|
|
|
- set(ENV{LUA_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{SDL2DIR})
|
|
|
- set(ENV{SDL2DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{SDL2_IMAGE_DIR})
|
|
|
- set(ENV{SDL2_IMAGE_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{SFML_ROOT})
|
|
|
- set(ENV{SFML_ROOT} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
+# Declare project-specific options. Naming conventions:
|
|
|
+# - Use "RMLUI_" prefix to make all options specific to this project easily identifiable, and avoid colliding with any parent project variables.
|
|
|
+# - Do not include negations (such as "not" and "disable"), to avoid situations with double negation.
|
|
|
+# - Do not include a verb prefix (such as "enable" and "build"), as these are often superfluous.
|
|
|
+option(RMLUI_SAMPLES "Build samples of the library." OFF)
|
|
|
+set(RMLUI_BACKEND "auto" CACHE STRING "Backend to use when building the RmlUi samples. Choose one from ./CMake/OptionsLists.cmake.")
|
|
|
+set_property(CACHE RMLUI_BACKEND PROPERTY STRINGS ${RMLUI_BACKEND_OPTIONS})
|
|
|
+if(NOT RMLUI_BACKEND IN_LIST RMLUI_BACKEND_OPTIONS)
|
|
|
+ message(FATAL_ERROR "The RmlUi backend '${RMLUI_BACKEND}' specified in RMLUI_BACKEND is not valid. Available options: ${RMLUI_BACKEND_OPTIONS}")
|
|
|
endif()
|
|
|
|
|
|
-if(NOT DEFINED ENV{TRACY_DIR})
|
|
|
- set(ENV{TRACY_DIR} "${PROJECT_SOURCE_DIR}/Dependencies")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{RLOTTIE_DIR})
|
|
|
- set(ENV{RLOTTIE_DIR} "${PROJECT_SOURCE_DIR}/Dependencies/rlottie")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT DEFINED ENV{LUNASVG_DIR})
|
|
|
- set(ENV{LUNASVG_DIR} "${PROJECT_SOURCE_DIR}/Dependencies/lunasvg")
|
|
|
-endif()
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Plaform specific global hacks ====
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(APPLE)
|
|
|
- # Disables naked builtins from AssertMacros.h which
|
|
|
- # This prevents naming collisions such as those from the check()
|
|
|
- # function macro with LuaType::check
|
|
|
- add_definitions(-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0)
|
|
|
-endif(APPLE)
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Build options ====================
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(NOT CMAKE_BUILD_TYPE)
|
|
|
- set(CMAKE_BUILD_TYPE Release CACHE STRING
|
|
|
- "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
|
- FORCE)
|
|
|
+set(RMLUI_FONT_ENGINE "freetype" CACHE STRING "Font engine to build RmlUi with. If set to \"none\", RmlUi won't build with any of the included font engines and some samples might be disabled.")
|
|
|
+set_property(CACHE RMLUI_FONT_ENGINE PROPERTY STRINGS ${RMLUI_FONT_ENGINE_OPTIONS})
|
|
|
+if(NOT RMLUI_FONT_ENGINE IN_LIST RMLUI_FONT_ENGINE_OPTIONS)
|
|
|
+ message(FATAL_ERROR "The RmlUi font engine '${RMLUI_FONT_ENGINE}' specified in RMLUI_FONT_ENGINE is not valid. Available options: ${RMLUI_FONT_ENGINE_OPTIONS}")
|
|
|
endif()
|
|
|
-
|
|
|
-if(NOT IOS)
|
|
|
- option(BUILD_SHARED_LIBS "Build shared (dynamic) libraries" ON)
|
|
|
-endif(NOT IOS)
|
|
|
-
|
|
|
-option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
|
|
|
-
|
|
|
-if (BUILD_LUA_BINDINGS)
|
|
|
- option(BUILD_LUA_BINDINGS_FOR_LUAJIT "Build Lua bindings using luajit" OFF)
|
|
|
- option(RMLUI_LUA_AS_CXX "Lua library was compiled with a C++ compiler" OFF)
|
|
|
-endif()
|
|
|
-
|
|
|
-if(APPLE)
|
|
|
- option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
|
|
|
-endif()
|
|
|
-
|
|
|
-option(BUILD_SAMPLES "Build samples" OFF)
|
|
|
-option(ENABLE_HARFBUZZ "Enable HarfBuzz for text-shaping sample. Requires the HarfBuzz library." OFF)
|
|
|
-
|
|
|
-set(SAMPLES_BACKEND "auto" CACHE STRING "Backend platform and renderer used for the samples.")
|
|
|
-set_property(CACHE SAMPLES_BACKEND PROPERTY STRINGS auto Win32_GL2 Win32_VK X11_GL2 SDL_GL2 SDL_GL3 SDL_VK SDL_SDLrenderer SFML_GL2 GLFW_GL2 GLFW_GL3 GLFW_VK BackwardCompatible_GLFW_GL2 BackwardCompatible_GLFW_GL3)
|
|
|
-
|
|
|
-if(SAMPLES_BACKEND STREQUAL "auto")
|
|
|
- if(EMSCRIPTEN)
|
|
|
- set(SAMPLES_BACKEND SDL_GL3)
|
|
|
- elseif(WIN32)
|
|
|
- set(SAMPLES_BACKEND Win32_GL2)
|
|
|
- elseif(APPLE)
|
|
|
- set(SAMPLES_BACKEND SDL_SDLrenderer)
|
|
|
- else()
|
|
|
- set(SAMPLES_BACKEND X11_GL2)
|
|
|
- endif()
|
|
|
+if(RMLUI_FONT_ENGINE STREQUAL "none")
|
|
|
+ set(RMLUI_FONT_ENGINE_ENABLED FALSE)
|
|
|
+else()
|
|
|
+ set(RMLUI_FONT_ENGINE_ENABLED TRUE)
|
|
|
endif()
|
|
|
|
|
|
-option(MATRIX_ROW_MAJOR "Use row-major matrices. Column-major matrices are used by default." OFF)
|
|
|
-
|
|
|
-if(APPLE)
|
|
|
- if(IOS)
|
|
|
- if(BUILD_SHARED_LIBS)
|
|
|
- message(FATAL_ERROR "BUILD_SHARED_LIBS must be OFF for iOS builds. iOS does not support shared libraries.")
|
|
|
- endif(BUILD_SHARED_LIBS)
|
|
|
- endif(IOS)
|
|
|
-
|
|
|
- if(BUILD_FRAMEWORK)
|
|
|
- if(NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
|
|
- message(FATAL_ERROR "You should use Xcode generator with BUILD_FRAMEWORK enabled")
|
|
|
- endif()
|
|
|
- if(NOT BUILD_SHARED_LIBS)
|
|
|
- message(FATAL_ERROR "BUILD_SHARED_LIBS must be ON with BUILD_FRAMEWORK enabled")
|
|
|
+if(RMLUI_IS_ROOT_PROJECT)
|
|
|
+ option(BUILD_TESTING "CMake standard option. Enable RmlUi testing projects." OFF)
|
|
|
+ if(BUILD_TESTING)
|
|
|
+ enable_testing()
|
|
|
+ set(RMLUI_TESTS ON)
|
|
|
+ set(RMLUI_VISUAL_TESTS_RML_DIRECTORIES "" CACHE PATH "Specify additional directories containing *.rml test documents for VisualTests. Separate multiple directories by comma.")
|
|
|
+ set(RMLUI_VISUAL_TESTS_COMPARE_DIRECTORY "" CACHE PATH "Set the input directory for screenshot comparison performed by VisualTests.")
|
|
|
+ set(RMLUI_VISUAL_TESTS_CAPTURE_DIRECTORY "" CACHE PATH "Set the output directory for screenshots generated by VisualTests.")
|
|
|
+ if(WIN32 AND BUILD_SHARED_LIBS AND NOT CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS)
|
|
|
+ message(FATAL_ERROR "The RmlUi testing framework cannot be built when using shared libraries with default visibility on Windows. "
|
|
|
+ "Please disable either BUILD_SHARED_LIBS or BUILD_TESTING.")
|
|
|
endif()
|
|
|
endif()
|
|
|
-else(APPLE)
|
|
|
- if(BUILD_FRAMEWORK)
|
|
|
- message(FATAL_ERROR "BUILD_FRAMEWORK is only supported on Mac OS X with the Xcode generator")
|
|
|
- endif()
|
|
|
-endif(APPLE)
|
|
|
-
|
|
|
-option(NO_FONT_INTERFACE_DEFAULT "Do not include the default font engine in the build. Allows building without the FreeType dependency, but a custom font engine must be created and set." OFF)
|
|
|
-if(NO_FONT_INTERFACE_DEFAULT)
|
|
|
- list(APPEND CORE_PRIVATE_DEFS RMLUI_NO_FONT_INTERFACE_DEFAULT)
|
|
|
-endif()
|
|
|
-
|
|
|
-if(WIN32 AND BUILD_SHARED_LIBS AND BUILD_TESTING)
|
|
|
- message(FATAL_ERROR "-- The RmlUi testing framework cannot be built when using shared libraries on Windows. Please disable either BUILD_SHARED_LIBS or BUILD_TESTING.")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(EMSCRIPTEN AND BUILD_SHARED_LIBS)
|
|
|
- message(FATAL_ERROR "-- Dynamic libraries not supported when using Emscripten. Please disable BUILD_SHARED_LIBS.")
|
|
|
-endif()
|
|
|
-
|
|
|
-if(NOT BUILD_SHARED_LIBS)
|
|
|
- list(APPEND CORE_PUBLIC_DEFS -DRMLUI_STATIC_LIB)
|
|
|
- message("-- Building static libraries. Make sure to #define RMLUI_STATIC_LIB before including RmlUi in your project.")
|
|
|
endif()
|
|
|
|
|
|
-option(NO_THIRDPARTY_CONTAINERS "Only use standard library containers." OFF)
|
|
|
-if( NO_THIRDPARTY_CONTAINERS )
|
|
|
- list(APPEND CORE_PUBLIC_DEFS -DRMLUI_NO_THIRDPARTY_CONTAINERS)
|
|
|
- message("-- No third-party containers will be used: Make sure to #define RMLUI_NO_THIRDPARTY_CONTAINERS before including RmlUi in your project.")
|
|
|
-endif()
|
|
|
-
|
|
|
-option(CUSTOM_CONFIGURATION "Customize RmlUi configuration files for overriding the default configuration and types." OFF)
|
|
|
-
|
|
|
-set(CUSTOM_CONFIGURATION_FILE "" CACHE STRING "Custom configuration file to be included in place of <RmlUi/Config/Config.h>.")
|
|
|
-if( CUSTOM_CONFIGURATION AND CUSTOM_CONFIGURATION_FILE )
|
|
|
- list(APPEND CORE_PUBLIC_DEFS -DRMLUI_CUSTOM_CONFIGURATION_FILE="${CUSTOM_CONFIGURATION_FILE}")
|
|
|
- message("-- Including ${CUSTOM_CONFIGURATION_FILE} instead of <RmlUi/Config/Config.h>")
|
|
|
-endif ()
|
|
|
-
|
|
|
-set(CUSTOM_INCLUDE_DIRS "" CACHE STRING "Extra include directories (use with CUSTOM_CONFIGURATION_FILE).")
|
|
|
-if( CUSTOM_CONFIGURATION AND CUSTOM_INCLUDE_DIRS )
|
|
|
- include_directories(${CUSTOM_INCLUDE_DIRS})
|
|
|
-endif ()
|
|
|
-
|
|
|
-set(CUSTOM_LINK_LIBRARIES "" CACHE STRING "Extra link libraries (use with CUSTOM_CONFIGURATION_FILE).")
|
|
|
-
|
|
|
-if( CUSTOM_CONFIGURATION )
|
|
|
- mark_as_advanced( CLEAR CUSTOM_CONFIGURATION_FILE CUSTOM_INCLUDE_DIRS CUSTOM_LINK_LIBRARIES )
|
|
|
-else()
|
|
|
- mark_as_advanced( FORCE CUSTOM_CONFIGURATION_FILE CUSTOM_INCLUDE_DIRS CUSTOM_LINK_LIBRARIES )
|
|
|
-
|
|
|
- if( CUSTOM_CONFIGURATION_FILE OR CUSTOM_INCLUDE_DIRS OR CUSTOM_LINK_LIBRARIES )
|
|
|
- message("-- CUSTOM_CONFIGURATION disabled, but custom configuration variables are set. They will have no effect.")
|
|
|
+option(RMLUI_LUA_BINDINGS "Build Lua bindings." OFF)
|
|
|
+if(RMLUI_LUA_BINDINGS)
|
|
|
+ set(RMLUI_LUA_BINDINGS_LIBRARY "lua" CACHE STRING "Choose which library to use for lua bindings when enabled.")
|
|
|
+ set_property(CACHE RMLUI_LUA_BINDINGS_LIBRARY PROPERTY STRINGS ${RMLUI_LUA_BINDINGS_LIBRARY_OPTIONS})
|
|
|
+ if(NOT RMLUI_LUA_BINDINGS_LIBRARY IN_LIST RMLUI_LUA_BINDINGS_LIBRARY_OPTIONS)
|
|
|
+ message(FATAL_ERROR "The RmlUi Lua binding library '${RMLUI_LUA_BINDINGS_LIBRARY}' specified in RMLUI_LUA_BINDINGS_LIBRARY is not valid. Available options: ${RMLUI_LUA_BINDINGS_LIBRARY_OPTIONS}")
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
|
-function(EnableConfigurationType name enable)
|
|
|
- if(enable)
|
|
|
- list(APPEND CMAKE_CONFIGURATION_TYPES "${name}")
|
|
|
- list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
|
|
|
- else()
|
|
|
- list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "${name}")
|
|
|
- endif()
|
|
|
- set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "List of configurations to enable" FORCE)
|
|
|
-endfunction()
|
|
|
+option(RMLUI_LOTTIE_PLUGIN "Enable plugin for Lottie animations. Requires the rlottie library." OFF)
|
|
|
+option(RMLUI_SVG_PLUGIN "Enable plugin for SVG images. Requires the lunasvg library." OFF)
|
|
|
|
|
|
-option(RMLUI_TRACY_PROFILING "Enable profiling with Tracy. Source files can be placed in Dependencies/tracy." OFF)
|
|
|
-if( RMLUI_TRACY_PROFILING )
|
|
|
- option(RMLUI_TRACY_MEMORY_PROFILING "Overload global operator new/delete to track memory allocations in Tracy." ON)
|
|
|
+option(RMLUI_HARFBUZZ_SAMPLE "Enable harfbuzz text shaping sample. Requires the harfbuzz library." OFF)
|
|
|
|
|
|
- if( CMAKE_CONFIGURATION_TYPES )
|
|
|
- option(RMLUI_TRACY_CONFIGURATION "Enable a separate Tracy configuration type for multi-config generators such as Visual Studio, otherwise enable Tracy in all configurations." ON)
|
|
|
+option(RMLUI_THIRDPARTY_CONTAINERS "Enable integrated third-party containers for improved performance, rather than their standard library counterparts." ON)
|
|
|
|
|
|
- if( RMLUI_TRACY_CONFIGURATION )
|
|
|
- EnableConfigurationType(Tracy ON)
|
|
|
- list(APPEND CMAKE_MAP_IMPORTED_CONFIG_TRACY Release)
|
|
|
- set(CMAKE_C_FLAGS_TRACY "${CMAKE_C_FLAGS_RELEASE}")
|
|
|
- set(CMAKE_CXX_FLAGS_TRACY "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
|
- set(CMAKE_EXE_LINKER_FLAGS_TRACY "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
|
|
- set(CMAKE_SHARED_LINKER_FLAGS_TRACY "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
|
|
- else()
|
|
|
- EnableConfigurationType(Tracy OFF)
|
|
|
- endif()
|
|
|
- endif()
|
|
|
+option(RMLUI_MATRIX_ROW_MAJOR "Use row-major matrices. Column-major matrices are used by default." OFF)
|
|
|
|
|
|
- if(NOT TARGET Tracy::TracyClient)
|
|
|
- find_package(Tracy QUIET)
|
|
|
- endif()
|
|
|
+option(RMLUI_CUSTOM_RTTI "Build RmlUi with a custom implementation of run-time type information (RTTI). When enabled, all usage of language RTTI features such as dynamic_cast will be disabled." OFF)
|
|
|
|
|
|
- if(NOT TARGET Tracy::TracyClient)
|
|
|
- message("Trying to add Tracy from subdirectory 'Dependencies/tracy'.")
|
|
|
- add_subdirectory("Dependencies/tracy")
|
|
|
- endif()
|
|
|
+option(RMLUI_PRECOMPILED_HEADERS "Enable precompiled headers for RmlUi." ON)
|
|
|
|
|
|
- if(NOT TARGET Tracy::TracyClient)
|
|
|
- message(FATAL_ERROR "Tracy client not found. Either (a) make sure target Tracy::TracyClient is available from parent project,"
|
|
|
- "(b) Tracy can be found as a config package, or (c) Tracy source files are located in 'Dependencies/Tracy'.")
|
|
|
- endif()
|
|
|
+option(RMLUI_COMPILER_OPTIONS "Enable recommended compiler-specific options for the project, such as for supported warning level, standards conformance, and multiprocess builds. Turn off for full control over compiler flags." ON)
|
|
|
|
|
|
- if( CMAKE_CONFIGURATION_TYPES AND RMLUI_TRACY_CONFIGURATION )
|
|
|
- message("-- Tracy profiling enabled in configuration 'Tracy'.")
|
|
|
- set(RMLUI_TRACY_CONDITION "$<CONFIG:Tracy>")
|
|
|
- else()
|
|
|
- message("-- Tracy profiling enabled.")
|
|
|
- set(RMLUI_TRACY_CONDITION "1")
|
|
|
- endif()
|
|
|
+option(RMLUI_WARNINGS_AS_ERRORS "Treat compiler warnings as errors." OFF)
|
|
|
+mark_as_advanced(RMLUI_WARNINGS_AS_ERRORS)
|
|
|
|
|
|
- list(APPEND CORE_PUBLIC_LINK_LIBS "$<${RMLUI_TRACY_CONDITION}:Tracy::TracyClient>")
|
|
|
- list(APPEND CORE_PUBLIC_DEFS "$<${RMLUI_TRACY_CONDITION}:RMLUI_TRACY_PROFILING>")
|
|
|
- if(RMLUI_TRACY_MEMORY_PROFILING)
|
|
|
- list(APPEND CORE_PRIVATE_DEFS "$<${RMLUI_TRACY_CONDITION}:RMLUI_TRACY_MEMORY_PROFILING>")
|
|
|
- endif()
|
|
|
-elseif( CMAKE_CONFIGURATION_TYPES )
|
|
|
- EnableConfigurationType(Tracy OFF)
|
|
|
-endif()
|
|
|
-
|
|
|
-option(ENABLE_LOTTIE_PLUGIN "Enable plugin for Lottie animations. Requires the rlottie library." OFF)
|
|
|
-option(ENABLE_SVG_PLUGIN "Enable plugin for SVG images. Requires the lunasvg library." OFF)
|
|
|
-
|
|
|
-option(DISABLE_RTTI_AND_EXCEPTIONS "Build with rtti and exceptions disabled." OFF)
|
|
|
-if(DISABLE_RTTI_AND_EXCEPTIONS)
|
|
|
- list(APPEND CORE_PUBLIC_DEFS -DRMLUI_USE_CUSTOM_RTTI)
|
|
|
- message("-- C++ RTTI and exceptions will be disabled: Make sure to #define RMLUI_USE_CUSTOM_RTTI before including RmlUi in your project.")
|
|
|
+option(RMLUI_TRACY_PROFILING "Enable profiling with Tracy. Source files can optionally be placed in `Dependencies/tracy`." OFF)
|
|
|
+if(RMLUI_TRACY_PROFILING)
|
|
|
+ option(RMLUI_TRACY_MEMORY_PROFILING "Overload global operator new/delete to track memory allocations in Tracy." ON)
|
|
|
endif()
|
|
|
-
|
|
|
-option(ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" ON)
|
|
|
-set(PRECOMPILED_HEADERS_ENABLED OFF)
|
|
|
-if (ENABLE_PRECOMPILED_HEADERS AND (CMAKE_VERSION VERSION_LESS 3.16.0))
|
|
|
- message("-- Could not enable precompiled headers. Need CMake version 3.16.0 or greater.")
|
|
|
-elseif (ENABLE_PRECOMPILED_HEADERS)
|
|
|
- set(PRECOMPILED_HEADERS_ENABLED ON)
|
|
|
+if(RMLUI_TRACY_PROFILING AND CMAKE_CONFIGURATION_TYPES)
|
|
|
+ option(RMLUI_TRACY_CONFIGURATION "Enable a separate Tracy configuration type for multi-config generators such as Visual Studio, otherwise enable Tracy in all configurations." ON)
|
|
|
endif()
|
|
|
|
|
|
-option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors." OFF)
|
|
|
-mark_as_advanced(WARNINGS_AS_ERRORS)
|
|
|
-
|
|
|
-macro(add_common_target_options NAME)
|
|
|
- # C++ language version
|
|
|
- if(CMAKE_VERSION VERSION_LESS 3.8.0)
|
|
|
- set_target_properties(${NAME} PROPERTIES
|
|
|
- CXX_STANDARD 14
|
|
|
- CXX_STANDARD_REQUIRED YES
|
|
|
- )
|
|
|
- else()
|
|
|
- target_compile_features(${NAME} PUBLIC cxx_std_14)
|
|
|
- endif()
|
|
|
- set_target_properties(${NAME} PROPERTIES CXX_EXTENSIONS OFF)
|
|
|
-
|
|
|
- # Compiler warnings
|
|
|
- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
- target_compile_options(${NAME} PRIVATE -Wall -pedantic -Wextra)
|
|
|
-
|
|
|
- if(WARNINGS_AS_ERRORS)
|
|
|
- target_compile_options(${NAME} PRIVATE -Werror)
|
|
|
- endif()
|
|
|
- elseif(MSVC)
|
|
|
- target_compile_options(${NAME} PRIVATE /MP /W4 /w44062 /permissive-)
|
|
|
- target_compile_definitions(${NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
|
-
|
|
|
- if(WARNINGS_AS_ERRORS)
|
|
|
- target_compile_options(${NAME} PRIVATE /WX)
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-endmacro()
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Setup paths ======================
|
|
|
-#===================================
|
|
|
-
|
|
|
-include_directories(
|
|
|
- ${PROJECT_SOURCE_DIR}/Include
|
|
|
-)
|
|
|
-
|
|
|
-# Include list of source files
|
|
|
-include(FileList)
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Find dependencies ================
|
|
|
-#===================================
|
|
|
-
|
|
|
-# FreeType
|
|
|
-if(NOT NO_FONT_INTERFACE_DEFAULT)
|
|
|
- if(EMSCRIPTEN)
|
|
|
- set(EMSCRIPTEN_FLAGS "${EMSCRIPTEN_FLAGS} -sUSE_FREETYPE=1")
|
|
|
- else()
|
|
|
- find_package(Freetype REQUIRED)
|
|
|
- if(MSVC AND FREETYPE_VERSION_STRING STREQUAL "2.11.0")
|
|
|
- message(WARNING "You are using FreeType version 2.11.0 which introduced an issue that causes a crash on startup on some of the samples. Please avoid this version specifically.")
|
|
|
- endif()
|
|
|
-
|
|
|
- list(APPEND CORE_LINK_LIBS ${FREETYPE_LIBRARIES})
|
|
|
- list(APPEND CORE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
|
|
|
+option(RMLUI_CUSTOM_CONFIGURATION "Customize the RmlUi configuration file to override the default configuration and types." OFF)
|
|
|
+set(RMLUI_CUSTOM_CONFIGURATION_FILE "" CACHE STRING "Custom configuration file to be included in place of <RmlUi/Config/Config.h>.")
|
|
|
+set(RMLUI_CUSTOM_INCLUDE_DIRS "" CACHE STRING "Extra include directories (use with RMLUI_CUSTOM_CONFIGURATION_FILE).")
|
|
|
+set(RMLUI_CUSTOM_LINK_LIBRARIES "" CACHE STRING "Extra link libraries (use with RMLUI_CUSTOM_CONFIGURATION_FILE).")
|
|
|
+if(RMLUI_CUSTOM_CONFIGURATION)
|
|
|
+ mark_as_advanced(CLEAR RMLUI_CUSTOM_CONFIGURATION_FILE RMLUI_CUSTOM_INCLUDE_DIRS RMLUI_CUSTOM_LINK_LIBRARIES)
|
|
|
+else()
|
|
|
+ mark_as_advanced(FORCE RMLUI_CUSTOM_CONFIGURATION_FILE RMLUI_CUSTOM_INCLUDE_DIRS RMLUI_CUSTOM_LINK_LIBRARIES)
|
|
|
+ if(RMLUI_CUSTOM_CONFIGURATION_FILE OR RMLUI_CUSTOM_INCLUDE_DIRS OR RMLUI_CUSTOM_LINK_LIBRARIES)
|
|
|
+ message(STATUS "RMLUI_CUSTOM_CONFIGURATION is disabled, but custom configuration variables are set. They will have no effect.")
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
|
-# HarfBuzz
|
|
|
-if (ENABLE_HARFBUZZ)
|
|
|
- if(NO_FONT_INTERFACE_DEFAULT)
|
|
|
- message(FATAL_ERROR "The HarfBuzz sample requires the default (FreeType) font engine to be enabled. Please disable either NO_FONT_INTERFACE_DEFAULT or ENABLE_HARFBUZZ.")
|
|
|
- endif()
|
|
|
- if(WIN32 AND BUILD_SHARED_LIBS)
|
|
|
- message(FATAL_ERROR "-- The HarfBuzz sample cannot be built when using shared libraries on Windows. Please disable either BUILD_SHARED_LIBS or ENABLE_HARFBUZZ.")
|
|
|
- endif()
|
|
|
+set(RMLUI_INSTALL_TARGETS_DIR "" CACHE STRING "Override the install directory for the generated CMake targets.")
|
|
|
+mark_as_advanced(RMLUI_INSTALL_TARGETS_DIR)
|
|
|
+option(RMLUI_INSTALL_LICENSES_AND_BUILD_INFO "Install license files and build info intended for the github actions workflow." OFF)
|
|
|
+mark_as_advanced(RMLUI_INSTALL_LICENSES_AND_BUILD_INFO)
|
|
|
|
|
|
- find_package(HarfBuzz REQUIRED)
|
|
|
-endif()
|
|
|
+# Add custom CMake modules path for external dependencies
|
|
|
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules")
|
|
|
+list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Dependencies")
|
|
|
|
|
|
-# Lua
|
|
|
-if(BUILD_LUA_BINDINGS)
|
|
|
- if(BUILD_LUA_BINDINGS_FOR_LUAJIT)
|
|
|
- find_package(LuaJIT REQUIRED)
|
|
|
- list(APPEND LUA_BINDINGS_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIR})
|
|
|
- list(APPEND LUA_BINDINGS_LINK_LIBS ${LUAJIT_LIBRARY})
|
|
|
- else()
|
|
|
- find_package(Lua REQUIRED)
|
|
|
- list(APPEND LUA_BINDINGS_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
|
|
|
- list(APPEND LUA_BINDINGS_LINK_LIBS ${LUA_LIBRARIES})
|
|
|
- endif()
|
|
|
- if(RMLUI_LUA_AS_CXX)
|
|
|
- list(APPEND LUA_BINDINGS_PUBLIC_DEFS -DRMLUI_LUA_COMPILED_AS_CXX)
|
|
|
- endif()
|
|
|
+include(GNUInstallDirs)
|
|
|
+if(NOT RMLUI_INSTALL_TARGETS_DIR)
|
|
|
+ set(RMLUI_INSTALL_TARGETS_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/RmlUi")
|
|
|
endif()
|
|
|
|
|
|
-# rlottie
|
|
|
-if( ENABLE_LOTTIE_PLUGIN AND TARGET rlottie::rlottie )
|
|
|
- list(APPEND CORE_LINK_LIBS rlottie::rlottie)
|
|
|
- list(APPEND CORE_INCLUDE_DIRS rlottie::rlottie)
|
|
|
-elseif( ENABLE_LOTTIE_PLUGIN )
|
|
|
- # Try to find the rlottie library.
|
|
|
- if(NOT DEFINED rlottie_DIR)
|
|
|
- set(rlottie_DIR $ENV{RLOTTIE_DIR})
|
|
|
- endif()
|
|
|
-
|
|
|
- list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/rlottie/build)
|
|
|
- find_package(rlottie CONFIG)
|
|
|
- find_path(rlottie_INCLUDE_DIR rlottie.h HINTS ${rlottie_DIR} $ENV{rlottie_DIR} PATH_SUFFIXES inc rlottie/inc ../inc)
|
|
|
+include("CMake/Utilities.cmake")
|
|
|
+include("CMake/Dependencies.cmake")
|
|
|
|
|
|
- if(rlottie_FOUND AND rlottie_INCLUDE_DIR)
|
|
|
- message("-- Can Lottie plugin be added to RmlCore - yes - rlottie library found")
|
|
|
+include("CMake/RuntimeUtilities.cmake")
|
|
|
+setup_runtime_output_directory()
|
|
|
+setup_runtime_dependency_set_arg()
|
|
|
|
|
|
- list(APPEND CORE_LINK_LIBS rlottie::rlottie)
|
|
|
- list(APPEND CORE_INCLUDE_DIRS ${rlottie_INCLUDE_DIR})
|
|
|
- list(APPEND CORE_PRIVATE_DEFS RMLUI_ENABLE_LOTTIE_PLUGIN)
|
|
|
+add_subdirectory("Source")
|
|
|
|
|
|
- list(APPEND Core_HDR_FILES ${Lottie_HDR_FILES})
|
|
|
- list(APPEND Core_PUB_HDR_FILES ${Lottie_PUB_HDR_FILES})
|
|
|
- list(APPEND Core_SRC_FILES ${Lottie_SRC_FILES})
|
|
|
- else()
|
|
|
- if(rlottie_FOUND)
|
|
|
- message(FATAL_ERROR "-- Can Lottie plugin be added to RmlCore - no - rlottie library found - rlottie include directory not found")
|
|
|
- elseif(rlottie_INCLUDE_DIR)
|
|
|
- message(FATAL_ERROR "-- Can Lottie plugin be added to RmlCore - no - rlottie library not found - rlottie include directory found at ${rlottie_INCLUDE_DIR}")
|
|
|
- else()
|
|
|
- message(FATAL_ERROR "-- Can Lottie plugin be added to RmlCore - no - rlottie not found")
|
|
|
- endif()
|
|
|
- endif()
|
|
|
+if(RMLUI_SAMPLES OR RMLUI_TESTS)
|
|
|
+ set(RMLUI_SHELL ON)
|
|
|
endif()
|
|
|
|
|
|
-# lunasvg
|
|
|
-if( ENABLE_SVG_PLUGIN )
|
|
|
- if(NOT DEFINED LUNASVG_DIR)
|
|
|
- set(LUNASVG_DIR $ENV{LUNASVG_DIR})
|
|
|
- endif()
|
|
|
-
|
|
|
- message("-- Can SVG plugin be enabled - looking for lunasvg library")
|
|
|
-
|
|
|
- find_package(lunasvg REQUIRED)
|
|
|
-
|
|
|
- list(APPEND CORE_LINK_LIBS ${LUNASVG_LIBRARIES})
|
|
|
- list(APPEND CORE_INCLUDE_DIRS ${LUNASVG_INCLUDE_DIR})
|
|
|
- list(APPEND CORE_PRIVATE_DEFS RMLUI_ENABLE_SVG_PLUGIN)
|
|
|
-
|
|
|
- list(APPEND Core_HDR_FILES ${SVG_HDR_FILES})
|
|
|
- list(APPEND Core_PUB_HDR_FILES ${SVG_PUB_HDR_FILES})
|
|
|
- list(APPEND Core_SRC_FILES ${SVG_SRC_FILES})
|
|
|
-
|
|
|
- message("-- Can SVG plugin be enabled - yes - lunasvg library found")
|
|
|
+if(RMLUI_SHELL)
|
|
|
+ include("CMake/BackendAutoSelection.cmake")
|
|
|
+ include("CMake/DependenciesForBackends.cmake")
|
|
|
+ add_subdirectory("Backends")
|
|
|
endif()
|
|
|
|
|
|
+add_subdirectory("Samples")
|
|
|
|
|
|
-if(NOT BUILD_FRAMEWORK)
|
|
|
-#===================================
|
|
|
-# Build libraries ==================
|
|
|
-#===================================
|
|
|
-
|
|
|
-set(LIBRARIES Core Debugger)
|
|
|
-
|
|
|
-foreach(library ${LIBRARIES})
|
|
|
- set(NAME Rml${library})
|
|
|
-
|
|
|
- add_library(${NAME}
|
|
|
- ${${library}_HDR_FILES}
|
|
|
- ${${library}_PUB_HDR_FILES}
|
|
|
- ${MASTER_${library}_PUB_HDR_FILES}
|
|
|
- ${${library}_SRC_FILES}
|
|
|
- )
|
|
|
- add_library(RmlUi::${library} ALIAS ${NAME})
|
|
|
-
|
|
|
- set_target_properties(${NAME} PROPERTIES
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
- SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
- )
|
|
|
-
|
|
|
- add_common_target_options(${NAME})
|
|
|
-
|
|
|
- install(TARGETS ${NAME}
|
|
|
- EXPORT RmlUiTargets
|
|
|
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
- )
|
|
|
-
|
|
|
- set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
|
|
|
-endforeach(library)
|
|
|
-
|
|
|
-if( CUSTOM_CONFIGURATION )
|
|
|
- foreach(library ${CUSTOM_LINK_LIBRARIES})
|
|
|
- install(TARGETS ${library}
|
|
|
- EXPORT RmlUiTargets
|
|
|
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
- )
|
|
|
- set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${library})
|
|
|
- endforeach(library ${CUSTOM_LINK_LIBRARIES})
|
|
|
+if(RMLUI_TESTS)
|
|
|
+ add_subdirectory("Tests")
|
|
|
endif()
|
|
|
|
|
|
-if( MATRIX_ROW_MAJOR )
|
|
|
- list(APPEND CORE_PUBLIC_DEFS -DRMLUI_MATRIX_ROW_MAJOR)
|
|
|
-endif ()
|
|
|
-if( CUSTOM_CONFIGURATION AND CUSTOM_LINK_LIBRARIES )
|
|
|
- target_link_libraries(RmlCore PUBLIC ${CUSTOM_LINK_LIBRARIES})
|
|
|
-endif ()
|
|
|
-
|
|
|
-if (PRECOMPILED_HEADERS_ENABLED)
|
|
|
- target_precompile_headers(RmlCore PRIVATE ${PROJECT_SOURCE_DIR}/Source/Core/precompiled.h)
|
|
|
+# Add an interface library to include all sub-libraries.
|
|
|
+# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE:
|
|
|
+# From CMake 3.13 we can place target_link_libraries in the same source as each sub-library is declared, see CMP0079.
|
|
|
+add_library(rmlui INTERFACE)
|
|
|
+add_library(RmlUi::RmlUi ALIAS rmlui)
|
|
|
+target_link_libraries(rmlui INTERFACE rmlui_core rmlui_debugger)
|
|
|
+if(RMLUI_LUA_BINDINGS)
|
|
|
+ target_link_libraries(rmlui INTERFACE rmlui_lua)
|
|
|
endif()
|
|
|
+set_target_properties(rmlui PROPERTIES EXPORT_NAME "RmlUi")
|
|
|
+install(TARGETS rmlui EXPORT RmlUiTargets)
|
|
|
|
|
|
-
|
|
|
-else(NOT BUILD_FRAMEWORK)
|
|
|
- #===================================
|
|
|
- # Build combined Framework =========
|
|
|
- #===================================
|
|
|
-
|
|
|
- set(NAME RmlUi)
|
|
|
-
|
|
|
- set(MASTER_PUB_HDR_FILES
|
|
|
- ${MASTER_Core_PUB_HDR_FILES}
|
|
|
- ${MASTER_Debugger_PUB_HDR_FILES}
|
|
|
- )
|
|
|
-
|
|
|
- add_library(${NAME}
|
|
|
- ${Core_HDR_FILES}
|
|
|
- ${MASTER_Core_PUB_HDR_FILES}
|
|
|
- ${Core_PUB_HDR_FILES}
|
|
|
- ${Core_SRC_FILES}
|
|
|
- ${Debugger_HDR_FILES}
|
|
|
- ${MASTER_Debugger_PUB_HDR_FILES}
|
|
|
- ${Debugger_PUB_HDR_FILES}
|
|
|
- ${Debugger_SRC_FILES}
|
|
|
- )
|
|
|
-
|
|
|
- set_target_properties(${NAME} PROPERTIES
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
- SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
- )
|
|
|
-
|
|
|
- set_property(SOURCE ${MASTER_PUB_HDR_FILES}
|
|
|
- PROPERTY MACOSX_PACKAGE_LOCATION Headers
|
|
|
- )
|
|
|
- set_property(SOURCE ${Core_PUB_HDR_FILES}
|
|
|
- PROPERTY MACOSX_PACKAGE_LOCATION Headers/Core
|
|
|
- )
|
|
|
- set_property(SOURCE ${Debugger_PUB_HDR_FILES}
|
|
|
- PROPERTY MACOSX_PACKAGE_LOCATION Headers/Debugger
|
|
|
- )
|
|
|
- set_target_properties(${NAME} PROPERTIES
|
|
|
- FRAMEWORK TRUE
|
|
|
- FRAMEWORK_VERSION ${PROJECT_VERSION}
|
|
|
- MACOSX_FRAMEWORK_IDENTIFIER com.rmlui.${NAME}
|
|
|
- MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${RMLUI_VERSION_SHORT}
|
|
|
- MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
|
|
|
- XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
|
|
- PUBLIC_HEADER ${MASTER_PUB_HDR_FILES}
|
|
|
- )
|
|
|
-
|
|
|
- install(TARGETS ${NAME}
|
|
|
- EXPORT RmlUiTargets
|
|
|
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
- FRAMEWORK DESTINATION Library/Frameworks
|
|
|
- )
|
|
|
-
|
|
|
- set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
|
|
|
-endif(NOT BUILD_FRAMEWORK)
|
|
|
-
|
|
|
-
|
|
|
-# Build Lua bindings
|
|
|
-if(BUILD_LUA_BINDINGS)
|
|
|
- set(NAME RmlLua)
|
|
|
-
|
|
|
- add_library(${NAME} ${Lua_SRC_FILES}
|
|
|
- ${Lua_HDR_FILES}
|
|
|
- ${Lua_PUB_HDR_FILES}
|
|
|
- )
|
|
|
-
|
|
|
- set_target_properties(${NAME} PROPERTIES
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
- SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
- )
|
|
|
-
|
|
|
- add_common_target_options(${NAME})
|
|
|
-
|
|
|
- install(TARGETS ${NAME}
|
|
|
- EXPORT RmlUiTargets
|
|
|
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
+if(RMLUI_IS_ROOT_PROJECT)
|
|
|
+ # Skip installing any targets when RmlUi is included using `add_subdirectory`. Otherwise, if any of RmlUi's linked
|
|
|
+ # dependencies are not exported, then this results in errors about the dependency not being in any export set.
|
|
|
+ install(EXPORT RmlUiTargets
|
|
|
+ DESTINATION "${RMLUI_INSTALL_TARGETS_DIR}"
|
|
|
+ NAMESPACE RmlUi::
|
|
|
+ FILE RmlUiTargets.cmake
|
|
|
)
|
|
|
-
|
|
|
- set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME})
|
|
|
-endif()
|
|
|
-
|
|
|
-if(DISABLE_RTTI_AND_EXCEPTIONS)
|
|
|
- if( CMAKE_COMPILER_IS_GNUCXX )
|
|
|
- add_definitions( -fno-rtti -fno-exceptions )
|
|
|
- elseif( MSVC )
|
|
|
- add_definitions( -D_HAS_EXCEPTIONS=0 /GR- )
|
|
|
- if(CMAKE_CXX_FLAGS MATCHES "/EHsc ")
|
|
|
- string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
- message(STATUS "CMAKE_CXX_FLAGS matches /EHsc before end of string replaced...")
|
|
|
- endif()
|
|
|
-
|
|
|
- if(CMAKE_CXX_FLAGS MATCHES "/EHsc$")
|
|
|
- string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
- message(STATUS "CMAKE_CXX_FLAGS matches /EHsc at end of string replaced...")
|
|
|
- endif()
|
|
|
- else()
|
|
|
- message(STATUS "Could not create build configuration without rtti and exceptions...")
|
|
|
- endif()
|
|
|
-endif()
|
|
|
-
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Link libraries ===================
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(NOT BUILD_FRAMEWORK)
|
|
|
- target_include_directories(RmlCore PRIVATE ${CORE_INCLUDE_DIRS})
|
|
|
- target_include_directories(RmlCore INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include> $<INSTALL_INTERFACE:include>)
|
|
|
- target_link_libraries(RmlCore PRIVATE ${CORE_LINK_LIBS})
|
|
|
- target_link_libraries(RmlCore PUBLIC ${CORE_PUBLIC_LINK_LIBS})
|
|
|
- target_link_libraries(RmlDebugger RmlCore)
|
|
|
- target_compile_definitions(RmlCore PRIVATE ${CORE_PRIVATE_DEFS})
|
|
|
- target_compile_definitions(RmlCore PUBLIC ${CORE_PUBLIC_DEFS})
|
|
|
-else()
|
|
|
- target_include_directories(RmlUi PRIVATE ${CORE_INCLUDE_DIRS})
|
|
|
- target_link_libraries(RmlUi PRIVATE ${CORE_LINK_LIBS})
|
|
|
- target_link_libraries(RmlUi PUBLIC ${CORE_PUBLIC_LINK_LIBS})
|
|
|
- target_compile_definitions(RmlUi PRIVATE ${CORE_PRIVATE_DEFS})
|
|
|
- target_compile_definitions(RmlUi PUBLIC ${CORE_PUBLIC_DEFS})
|
|
|
endif()
|
|
|
|
|
|
-if(BUILD_LUA_BINDINGS)
|
|
|
- if(NOT BUILD_FRAMEWORK)
|
|
|
- target_link_libraries(RmlLua RmlCore ${LUA_BINDINGS_LINK_LIBS})
|
|
|
- target_include_directories(RmlLua PUBLIC ${LUA_BINDINGS_INCLUDE_DIRS})
|
|
|
- target_compile_definitions(RmlLua PUBLIC ${LUA_BINDINGS_PUBLIC_DEFS})
|
|
|
- else()
|
|
|
- target_link_libraries(RmlUi ${LUA_BINDINGS_LINK_LIBS})
|
|
|
- target_include_directories(RmlUi PUBLIC ${LUA_BINDINGS_INCLUDE_DIRS})
|
|
|
- target_compile_definitions(RmlUi PUBLIC ${LUA_BINDINGS_PUBLIC_DEFS})
|
|
|
- endif()
|
|
|
-endif()
|
|
|
-
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Build samples ====================
|
|
|
-#===================================
|
|
|
-
|
|
|
-function(resource VAR SOURCE_PATH DESTINATION PATTERN)
|
|
|
- file(GLOB_RECURSE _LIST CONFIGURE_DEPENDS ${SOURCE_PATH}/${PATTERN})
|
|
|
- foreach (RESOURCE ${_LIST})
|
|
|
- get_filename_component(_PARENT ${RESOURCE} DIRECTORY)
|
|
|
- if (${_PARENT} STREQUAL ${SOURCE_PATH})
|
|
|
- set(_DESTINATION ${DESTINATION})
|
|
|
- else ()
|
|
|
- file(RELATIVE_PATH _DESTINATION ${SOURCE_PATH} ${_PARENT})
|
|
|
- set(_DESTINATION ${DESTINATION}/${_DESTINATION})
|
|
|
- endif ()
|
|
|
- set_property(SOURCE ${RESOURCE} PROPERTY MACOSX_PACKAGE_LOCATION ${_DESTINATION})
|
|
|
- endforeach (RESOURCE)
|
|
|
- set(${VAR} ${_LIST} PARENT_SCOPE)
|
|
|
-endfunction()
|
|
|
-
|
|
|
-# Build and link the samples
|
|
|
-macro(bl_sample NAME SAMPLE_SUB_DIR)
|
|
|
- if (WIN32)
|
|
|
- add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
|
|
|
- elseif(APPLE)
|
|
|
- resource(ASSETS ${SAMPLES_DIR}/assets Resources/assets *)
|
|
|
- resource(DATA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/data Resources/${SAMPLE_SUB_DIR}/data *)
|
|
|
- resource(LUA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/lua Resources/${SAMPLE_SUB_DIR}/lua *)
|
|
|
-
|
|
|
- set(RESOURCE_FILES ${ASSETS} ${DATA} ${LUA})
|
|
|
-
|
|
|
- add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} ${RESOURCE_FILES})
|
|
|
-
|
|
|
- # The first rpath is to the proper location where the framework/library SHOULD be, the second is to the location actually seen
|
|
|
- # in the build environment
|
|
|
- if(BUILD_FRAMEWORK)
|
|
|
- set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../Frameworks")
|
|
|
- else()
|
|
|
- set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../lib")
|
|
|
- endif()
|
|
|
- else()
|
|
|
- add_executable(${NAME} ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
|
|
|
- endif()
|
|
|
-
|
|
|
- add_common_target_options(${NAME})
|
|
|
-
|
|
|
- target_link_libraries(${NAME} ${ARGN})
|
|
|
-endmacro()
|
|
|
-
|
|
|
-# Build shell
|
|
|
-if(BUILD_SAMPLES OR BUILD_TESTING)
|
|
|
- message("-- Adding shell with '${SAMPLES_BACKEND}' backend.")
|
|
|
-
|
|
|
- include(SampleFileList)
|
|
|
- include(BackendFileList)
|
|
|
-
|
|
|
- if(NOT BUILD_FRAMEWORK)
|
|
|
- set(sample_LIBRARIES
|
|
|
- shell
|
|
|
- RmlCore
|
|
|
- RmlDebugger
|
|
|
- )
|
|
|
- else()
|
|
|
- set(sample_LIBRARIES
|
|
|
- shell
|
|
|
- RmlUi
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- set(SAMPLES_DIR ${PROJECT_SOURCE_DIR}/Samples CACHE PATH "Path to samples directory.")
|
|
|
- if(WIN32)
|
|
|
- mark_as_advanced(SAMPLES_DIR)
|
|
|
- endif()
|
|
|
-
|
|
|
-
|
|
|
- set(BACKEND_SRC_FILES "${${SAMPLES_BACKEND}_SRC_FILES}")
|
|
|
- set(BACKEND_HDR_FILES "${${SAMPLES_BACKEND}_HDR_FILES}")
|
|
|
-
|
|
|
- if("${BACKEND_SRC_FILES}" STREQUAL "" OR "${BACKEND_HDR_FILES}" STREQUAL "")
|
|
|
- message(FATAL_ERROR "Unknown samples backend '${SAMPLES_BACKEND}'.")
|
|
|
- endif()
|
|
|
+install(DIRECTORY
|
|
|
+ "${CMAKE_CURRENT_SOURCE_DIR}/Include/RmlUi"
|
|
|
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
+)
|
|
|
|
|
|
- list(APPEND shell_SRC_FILES ${BACKEND_SRC_FILES})
|
|
|
- list(APPEND shell_HDR_FILES ${BACKEND_HDR_FILES} ${BACKEND_COMMON_HDR_FILES})
|
|
|
+include(CMakePackageConfigHelpers)
|
|
|
|
|
|
- add_library(shell STATIC ${shell_SRC_FILES} ${shell_HDR_FILES})
|
|
|
+configure_file(
|
|
|
+ "${CMAKE_CURRENT_SOURCE_DIR}/CMake/RmlUiConfig.cmake.in"
|
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake"
|
|
|
+ @ONLY
|
|
|
+)
|
|
|
+# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE:
|
|
|
+# From CMake 3.11 use compatibility mode `SameMinorVersion`.
|
|
|
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake"
|
|
|
+ COMPATIBILITY ExactVersion
|
|
|
+)
|
|
|
+install(FILES
|
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake"
|
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake"
|
|
|
+ "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Dependencies.cmake"
|
|
|
+ DESTINATION
|
|
|
+ "${RMLUI_INSTALL_TARGETS_DIR}"
|
|
|
+)
|
|
|
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules"
|
|
|
+ DESTINATION "${RMLUI_INSTALL_TARGETS_DIR}"
|
|
|
+)
|
|
|
|
|
|
- target_include_directories(shell PUBLIC
|
|
|
- ${PROJECT_SOURCE_DIR}/Backends
|
|
|
- ${PROJECT_SOURCE_DIR}/Samples/shell/include
|
|
|
+if(RMLUI_IS_ROOT_PROJECT)
|
|
|
+ # Export build targets if RmlUi is the top-level project.
|
|
|
+ export(EXPORT RmlUiTargets
|
|
|
+ NAMESPACE RmlUi::
|
|
|
+ FILE RmlUiTargets.cmake
|
|
|
)
|
|
|
-
|
|
|
- add_common_target_options(shell)
|
|
|
- target_link_libraries(shell PUBLIC RmlCore RmlDebugger)
|
|
|
-
|
|
|
- # Add OS dependencies.
|
|
|
- if (WIN32)
|
|
|
- target_link_libraries(shell PRIVATE shlwapi imm32)
|
|
|
- elseif(APPLE)
|
|
|
- target_link_libraries(shell PRIVATE "-framework Cocoa")
|
|
|
- elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
|
|
|
- find_package(X11)
|
|
|
- if (X11_FOUND)
|
|
|
- message("-- Found X11 library.")
|
|
|
- target_link_libraries(shell PRIVATE ${X11_LIBRARIES})
|
|
|
- # Platform_X11 uses Xkb if possible instead of XGetKeyboardMapping for performance.
|
|
|
- if(X11_Xkb_FOUND)
|
|
|
- FIND_PACKAGE_MESSAGE(X11 "Found X11 KBlib: ${X11_X11_LIB}" "[${X11_X11_LIB}][${X11_XkbINCLUDE_DIR}]")
|
|
|
- target_compile_definitions(shell PRIVATE HAS_X11XKBLIB)
|
|
|
- endif()
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- # Add platform dependencies.
|
|
|
- if(SAMPLES_BACKEND MATCHES "^X11")
|
|
|
- if(NOT X11_FOUND)
|
|
|
- message(FATAL_ERROR "X11 not found or not supported on this platform, select a different sample backend.")
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND MATCHES "^SDL")
|
|
|
- message("-- Looking for SDL2 library for samples backend.")
|
|
|
- if(EMSCRIPTEN)
|
|
|
- set(EMSCRIPTEN_FLAGS "${EMSCRIPTEN_FLAGS} -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='[tga]'")
|
|
|
- else()
|
|
|
- find_package(SDL2 REQUIRED)
|
|
|
-
|
|
|
- if(NOT SDL2_FOUND)
|
|
|
- message(FATAL_ERROR "SDL2 not found")
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND STREQUAL "SDL_GL2")
|
|
|
- find_package(GLEW REQUIRED)
|
|
|
- if(NOT GLEW_FOUND)
|
|
|
- message(FATAL_ERROR "GLEW not found")
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- # Check version requirement for the SDL renderer.
|
|
|
- if(SAMPLES_BACKEND STREQUAL "SDL_SDLrenderer" AND "${SDL2_VERSION}" VERSION_LESS "2.0.20")
|
|
|
- message(FATAL_ERROR "SDL2 native renderer backend (${SAMPLES_BACKEND}) requires SDL 2.0.20 (found ${SDL2_VERSION}).")
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND STREQUAL "SDL_GL2" OR SAMPLES_BACKEND STREQUAL "SDL_GL3" OR SAMPLES_BACKEND STREQUAL "SDL_SDLrenderer")
|
|
|
- find_package(SDL2_image REQUIRED)
|
|
|
- if(NOT SDL2_IMAGE_FOUND)
|
|
|
- message(FATAL_ERROR "SDL2_image not found")
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- target_include_directories(shell PRIVATE ${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
|
|
|
- target_link_libraries(shell PRIVATE ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${GLEW_LIBRARIES})
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND MATCHES "^SFML")
|
|
|
- message("-- Looking for SFML 2.x library for samples backend.")
|
|
|
- if (WIN32)
|
|
|
- find_package(SFML 2 REQUIRED COMPONENTS graphics window system main)
|
|
|
- else()
|
|
|
- find_package(SFML 2 REQUIRED COMPONENTS graphics window system)
|
|
|
- endif()
|
|
|
- target_include_directories(shell PRIVATE ${SFML_INCLUDE_DIR})
|
|
|
- target_link_libraries(shell PRIVATE ${SFML_LIBRARIES})
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND MATCHES "GLFW")
|
|
|
- message("-- Looking for GLFW3 library for samples backend.")
|
|
|
- find_package(glfw3 3.3 CONFIG REQUIRED)
|
|
|
- target_link_libraries(shell PRIVATE glfw)
|
|
|
- message("-- Found GLFW version ${glfw3_VERSION}.")
|
|
|
- endif()
|
|
|
-
|
|
|
- # Add renderer dependencies.
|
|
|
- if(SAMPLES_BACKEND MATCHES "GL2$")
|
|
|
- message("-- Adding OpenGL 2 renderer backend.")
|
|
|
- find_package(OpenGL REQUIRED)
|
|
|
- target_include_directories(shell PRIVATE ${OPENGL_INCLUDE_DIR})
|
|
|
- target_link_libraries(shell PRIVATE ${OPENGL_LIBRARIES})
|
|
|
- target_compile_definitions(shell PRIVATE RMLUI_RENDERER_GL2)
|
|
|
- if(APPLE)
|
|
|
- target_compile_definitions(shell PRIVATE GL_SILENCE_DEPRECATION)
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND MATCHES "VK$")
|
|
|
- message("-- Using Vulkan renderer backend.")
|
|
|
-
|
|
|
- option(RMLUI_VK_DEBUG "Enable debugging mode for Vulkan renderer." OFF)
|
|
|
- mark_as_advanced(RMLUI_VK_DEBUG)
|
|
|
- if(RMLUI_VK_DEBUG)
|
|
|
- target_compile_definitions(shell PRIVATE RMLUI_VK_DEBUG)
|
|
|
- endif()
|
|
|
-
|
|
|
- target_link_libraries(shell PRIVATE ${CMAKE_DL_LIBS})
|
|
|
- endif()
|
|
|
-
|
|
|
- if(SAMPLES_BACKEND MATCHES "GL3$")
|
|
|
- message("-- Adding OpenGL 3 renderer backend.")
|
|
|
- if(EMSCRIPTEN)
|
|
|
- set(EMSCRIPTEN_EXE_FLAGS "${EMSCRIPTEN_EXE_FLAGS} -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2")
|
|
|
- else()
|
|
|
- find_package(OpenGL REQUIRED)
|
|
|
- target_include_directories(shell PRIVATE ${OPENGL_INCLUDE_DIR})
|
|
|
- target_link_libraries(shell PRIVATE ${OPENGL_LIBRARIES} ${CMAKE_DL_LIBS})
|
|
|
- target_compile_definitions(shell PRIVATE RMLUI_RENDERER_GL3)
|
|
|
- if(APPLE)
|
|
|
- target_compile_definitions(shell PRIVATE GL_SILENCE_DEPRECATION)
|
|
|
- endif()
|
|
|
- endif()
|
|
|
- endif()
|
|
|
-endif()
|
|
|
-
|
|
|
-
|
|
|
-if(BUILD_SAMPLES)
|
|
|
- set(samples treeview customlog drag loaddocument transform bitmapfont animation benchmark demo databinding effects)
|
|
|
- set(tutorials template drag)
|
|
|
-
|
|
|
- if(ENABLE_LOTTIE_PLUGIN)
|
|
|
- list(APPEND samples "lottie")
|
|
|
- endif()
|
|
|
- if(ENABLE_SVG_PLUGIN)
|
|
|
- list(APPEND samples "svg")
|
|
|
- endif()
|
|
|
- if(ENABLE_HARFBUZZ)
|
|
|
- list(APPEND samples "harfbuzzshaping")
|
|
|
- endif()
|
|
|
-
|
|
|
- # Build and install the basic samples
|
|
|
- foreach(sample ${samples})
|
|
|
- bl_sample(${sample} basic/${sample} ${sample_LIBRARIES} )
|
|
|
-
|
|
|
- # The samples always set this as their current working directory
|
|
|
- install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/${sample})
|
|
|
- install(TARGETS ${sample}
|
|
|
- RUNTIME DESTINATION ${SAMPLES_DIR}/${sample}
|
|
|
- BUNDLE DESTINATION ${SAMPLES_DIR})
|
|
|
- endforeach()
|
|
|
-
|
|
|
- # Build and install the tutorials
|
|
|
- foreach(tutorial ${tutorials})
|
|
|
- set(tutorial_fullname tutorial_${tutorial})
|
|
|
- bl_sample(${tutorial_fullname} tutorial/${tutorial} ${sample_LIBRARIES})
|
|
|
-
|
|
|
- # The tutorials always set this as their current working directory
|
|
|
- install(DIRECTORY DESTINATION ${SAMPLES_DIR}/tutorial/${tutorial})
|
|
|
- install(TARGETS ${tutorial_fullname}
|
|
|
- RUNTIME DESTINATION ${SAMPLES_DIR}/${tutorial}
|
|
|
- BUNDLE DESTINATION ${SAMPLES_DIR})
|
|
|
- endforeach()
|
|
|
-
|
|
|
- # Build and install invaders sample
|
|
|
- bl_sample(invaders invaders ${sample_LIBRARIES})
|
|
|
- install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
|
|
|
- install(TARGETS invaders
|
|
|
- RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
|
|
|
- BUNDLE DESTINATION ${SAMPLES_DIR})
|
|
|
-
|
|
|
- if(BUILD_LUA_BINDINGS)
|
|
|
- bl_sample(luainvaders luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
|
|
|
- install(DIRECTORY DESTINATION ${SAMPLES_DIR}/luainvaders)
|
|
|
- install(TARGETS luainvaders
|
|
|
- RUNTIME DESTINATION ${SAMPLES_DIR}/luainvaders
|
|
|
- BUNDLE DESTINATION ${SAMPLES_DIR})
|
|
|
- endif()
|
|
|
-
|
|
|
- # Attach harfbuzz sample dependencies to samples
|
|
|
- if (ENABLE_HARFBUZZ)
|
|
|
- target_include_directories(harfbuzzshaping PRIVATE ${FREETYPE_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/Source/Core)
|
|
|
- target_link_libraries(harfbuzzshaping harfbuzz::harfbuzz)
|
|
|
- endif()
|
|
|
-
|
|
|
- # Add assets to emscripten binaries
|
|
|
- if(EMSCRIPTEN)
|
|
|
- message("-- Preloading emscripten sample assets")
|
|
|
-
|
|
|
- set(COMMON_ASSET_FOLDER "Samples/assets/")
|
|
|
- set(EMSCRIPTEN_EXE_FLAGS "${EMSCRIPTEN_EXE_FLAGS} --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/${COMMON_ASSET_FOLDER}@/${COMMON_ASSET_FOLDER}")
|
|
|
- file(GLOB COMMON_ASSET_FILES "${COMMON_ASSET_FOLDER}*")
|
|
|
-
|
|
|
- foreach(sample ${samples})
|
|
|
- set(SAMPLE_DATA_FOLDER "Samples/basic/${sample}/data/")
|
|
|
- set(ABS_SAMPLE_DATA_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_DATA_FOLDER}")
|
|
|
- if(EXISTS ${ABS_SAMPLE_DATA_FOLDER})
|
|
|
- target_link_libraries(${sample} "--preload-file ${ABS_SAMPLE_DATA_FOLDER}@/${SAMPLE_DATA_FOLDER}")
|
|
|
- endif()
|
|
|
- file(GLOB SAMPLE_DATA_FILES "${SAMPLE_DATA_FOLDER}*")
|
|
|
- set_target_properties(${sample} PROPERTIES LINK_DEPENDS "${COMMON_ASSET_FILES};${SAMPLE_DATA_FILES}")
|
|
|
- endforeach()
|
|
|
-
|
|
|
- foreach(tutorial ${tutorials})
|
|
|
- set(TUTORIAL_DATA_FOLDER "Samples/tutorial/${tutorial}/data/")
|
|
|
- set(ABS_TUTORIAL_DATA_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/${TUTORIAL_DATA_FOLDER}")
|
|
|
- if(EXISTS ${ABS_TUTORIAL_DATA_FOLDER})
|
|
|
- target_link_libraries("tutorial_${tutorial}" "--preload-file ${ABS_TUTORIAL_DATA_FOLDER}@/${TUTORIAL_DATA_FOLDER}")
|
|
|
- endif()
|
|
|
- file(GLOB TUTORIAL_DATA_FILES "${TUTORIAL_DATA_FOLDER}*")
|
|
|
- set_target_properties(${sample} PROPERTIES LINK_DEPENDS "${COMMON_ASSET_FILES};${TUTORIAL_DATA_FILES}")
|
|
|
- endforeach()
|
|
|
-
|
|
|
- set(INVADERS_DATA_FOLDER "Samples/invaders/data/")
|
|
|
- target_link_libraries(invaders "-sALLOW_MEMORY_GROWTH --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/${INVADERS_DATA_FOLDER}@/${INVADERS_DATA_FOLDER}")
|
|
|
- file(GLOB INVADERS_DATA_FILES "${INVADERS_DATA_FOLDER}*")
|
|
|
- set_target_properties(invaders PROPERTIES LINK_DEPENDS "${COMMON_ASSET_FILES};${INVADERS_DATA_FILES}")
|
|
|
- endif()
|
|
|
-endif()
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Source grouping for IDEs =========
|
|
|
-#===================================
|
|
|
-
|
|
|
-source_group("Core\\Layout" REGULAR_EXPRESSION "/Core/Layout/")
|
|
|
-source_group("Core\\Elements" REGULAR_EXPRESSION "/Core/Elements/")
|
|
|
-source_group("Core\\FontEngineDefault" REGULAR_EXPRESSION "/Core/FontEngineDefault/")
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Add global options ===============
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(EMSCRIPTEN)
|
|
|
- # Enables Asyncify which we only need since the backend doesn't control the main loop. This enables us to yield to the browser during the backend call to
|
|
|
- # Backend::ProcessEvents(). Asyncify results in larger and slower code, users are instead encouraged to use 'emscripten_set_main_loop()' and family.
|
|
|
- set(EMSCRIPTEN_EXE_FLAGS "${EMSCRIPTEN_EXE_FLAGS} -sASYNCIFY")
|
|
|
-
|
|
|
- message(STATUS "Compiling for Emscripten.\n\t- Flags:${EMSCRIPTEN_FLAGS}\n\t- ExeFlags:${EMSCRIPTEN_EXE_FLAGS}")
|
|
|
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMSCRIPTEN_FLAGS}")
|
|
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMSCRIPTEN_FLAGS}")
|
|
|
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_FLAGS} ${EMSCRIPTEN_EXE_FLAGS}")
|
|
|
- set(CMAKE_EXECUTABLE_SUFFIX .html)
|
|
|
-endif()
|
|
|
-
|
|
|
-#===================================
|
|
|
-# Add tests ========================
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(RMLUI_TESTS_ENABLED)
|
|
|
- add_subdirectory(Tests)
|
|
|
endif()
|
|
|
|
|
|
-#===================================
|
|
|
-# Installation =====================
|
|
|
-#===================================
|
|
|
-
|
|
|
-if(BUILD_LUA_BINDINGS)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/RmlUi
|
|
|
- DESTINATION include
|
|
|
- )
|
|
|
-else()
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Include/RmlUi
|
|
|
- DESTINATION include
|
|
|
- PATTERN "Lua" EXCLUDE
|
|
|
- )
|
|
|
+include("CMake/PackageUtilities.cmake")
|
|
|
+if(RMLUI_INSTALL_LICENSES_AND_BUILD_INFO)
|
|
|
+ install_licenses()
|
|
|
+ install_build_info()
|
|
|
endif()
|
|
|
-
|
|
|
-if(BUILD_SAMPLES)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/assets
|
|
|
- DESTINATION ${SAMPLES_DIR}
|
|
|
- )
|
|
|
-
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/template/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/tutorial/template
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/tutorial/drag/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/tutorial/drag
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/animation/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/animation
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/benchmark/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/benchmark
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/bitmapfont/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/bitmapfont
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/databinding/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/databinding
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/demo/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/demo
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/effects/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/effects
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/transform/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/transform
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/treeview/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/treeview
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/drag/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/drag
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/invaders/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/invaders
|
|
|
- )
|
|
|
-
|
|
|
- if (ENABLE_HARFBUZZ AND HARFBUZZ_FOUND)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/harfbuzzshaping/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/harfbuzzshaping
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- if(TARGET lottie)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/lottie/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/lottie
|
|
|
- )
|
|
|
- endif()
|
|
|
- if(TARGET svg)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/basic/svg/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/basic/svg
|
|
|
- )
|
|
|
- endif()
|
|
|
-
|
|
|
- if(BUILD_LUA_BINDINGS)
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/luainvaders/data
|
|
|
- DESTINATION ${SAMPLES_DIR}/luainvaders
|
|
|
- )
|
|
|
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/Samples/luainvaders/lua
|
|
|
- DESTINATION ${SAMPLES_DIR}/luainvaders
|
|
|
- )
|
|
|
- endif()
|
|
|
+if(RMLUI_INSTALL_DEPENDENCIES_DIR)
|
|
|
+ install_vcpkg_dependencies()
|
|
|
endif()
|
|
|
|
|
|
-#===================================
|
|
|
-# Generate Config.cmake files ======
|
|
|
-#===================================
|
|
|
-
|
|
|
-# Try to include helper module
|
|
|
-include(CMakePackageConfigHelpers OPTIONAL RESULT_VARIABLE PkgHelpers_AVAILABLE)
|
|
|
-
|
|
|
-# guard against older versions of cmake which do not provide it
|
|
|
-if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
|
|
-if(PkgHelpers_AVAILABLE)
|
|
|
- set (INCLUDE_INSTALL_DIR "include")
|
|
|
- set (LIB_INSTALL_DIR "lib")
|
|
|
- set (INCLUDE_DIR "${PROJECT_SOURCE_DIR}/Include")
|
|
|
-
|
|
|
- # generate configuration for install tree
|
|
|
- configure_package_config_file(${PROJECT_SOURCE_DIR}/CMake/RmlUiConfig.cmake.install.in
|
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake
|
|
|
- INSTALL_DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake
|
|
|
- PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
|
|
|
- write_basic_package_version_file(
|
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
- COMPATIBILITY SameMajorVersion )
|
|
|
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfig.cmake
|
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/install/RmlUiConfigVersion.cmake
|
|
|
- DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake )
|
|
|
- install(EXPORT RmlUiTargets
|
|
|
- DESTINATION ${LIB_INSTALL_DIR}/RmlUi/cmake)
|
|
|
-
|
|
|
- # generate configuration for build tree
|
|
|
- configure_package_config_file(${PROJECT_SOURCE_DIR}/CMake/RmlUiConfig.cmake.build.in
|
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/RmlUiConfig.cmake
|
|
|
- INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
- PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR)
|
|
|
- if(NOT ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
|
|
- export(TARGETS ${RMLUI_EXPORTED_TARGETS}
|
|
|
- FILE "${CMAKE_CURRENT_BINARY_DIR}/RmlUiTargets.cmake")
|
|
|
- endif()
|
|
|
- write_basic_package_version_file(
|
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/RmlUiConfigVersion.cmake
|
|
|
- VERSION ${PROJECT_VERSION}
|
|
|
- COMPATIBILITY SameMajorVersion )
|
|
|
- set(RmlUi_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "The directory containing a CMake configuration file for RmlUi.")
|
|
|
-else()
|
|
|
- message("If you wish to use find_package(RmlUi) in your own project to find RmlUi library"
|
|
|
- " please update cmake to version which provides CMakePackageConfighelpers module"
|
|
|
- " or write generators for RmlUiConfig.cmake by yourself.")
|
|
|
-endif()
|
|
|
-endif()
|
|
|
+install_runtime_dependencies()
|