From dfde5d6c5c45f3b99c55020b6f1d42680007ed17 Mon Sep 17 00:00:00 2001 From: hobyst <48522412+hobyst@users.noreply.github.com> Date: Wed, 12 Apr 2023 12:13:59 +0200 Subject: [PATCH] CMake modernization Re-write the CMake project from scratch up to some extent using modern CMake conventions. Tested with GLFW, OpenGL 3 and rlottie. Available samples: benchmark, demo, lottie --- .github/workflows/build.yml | 40 +- CMake/BackendFileList.cmake | 121 ------ CMake/Backends.cmake | 154 ++++++++ CMake/Dependencies.cmake | 49 +++ CMake/SamplesDependencies.cmake | 162 ++++++++ CMakeLists.txt | 38 ++ CONTRIBUTING.md | 47 +++ Include/RmlUi/Core/Header.h | 2 +- Include/RmlUi/Debugger/Header.h | 2 +- Samples/CMakeLists.txt | 38 ++ Samples/basic/CMakeLists.txt | 9 + Samples/basic/benchmark/CMakeLists.txt | 5 + Samples/basic/demo/CMakeLists.txt | 5 + Samples/basic/lottie/CMakeLists.txt | 5 + Samples/shell/CMakeLists.txt | 22 ++ Source/CMakeLists.txt | 8 + Source/Core/CMakeLists.txt | 393 +++++++++++++++++++ Source/Core/Elements/CMakeLists.txt | 71 ++++ Source/Core/FontEngineDefault/CMakeLists.txt | 44 +++ Source/Core/Layout/CMakeLists.txt | 61 +++ Source/Debugger/CMakeLists.txt | 76 ++++ Source/Lottie/CMakeLists.txt | 40 ++ Source/Lua/CMakeLists.txt | 13 + Source/SVG/CMakeLists.txt | 6 + 24 files changed, 1268 insertions(+), 143 deletions(-) delete mode 100644 CMake/BackendFileList.cmake create mode 100644 CMake/Backends.cmake create mode 100644 CMake/Dependencies.cmake create mode 100644 CMake/SamplesDependencies.cmake create mode 100644 CMakeLists.txt create mode 100644 CONTRIBUTING.md create mode 100644 Samples/CMakeLists.txt create mode 100644 Samples/basic/CMakeLists.txt create mode 100644 Samples/basic/benchmark/CMakeLists.txt create mode 100644 Samples/basic/demo/CMakeLists.txt create mode 100644 Samples/basic/lottie/CMakeLists.txt create mode 100644 Samples/shell/CMakeLists.txt create mode 100644 Source/CMakeLists.txt create mode 100644 Source/Core/CMakeLists.txt create mode 100644 Source/Core/Elements/CMakeLists.txt create mode 100644 Source/Core/FontEngineDefault/CMakeLists.txt create mode 100644 Source/Core/Layout/CMakeLists.txt create mode 100644 Source/Debugger/CMakeLists.txt create mode 100644 Source/Lottie/CMakeLists.txt create mode 100644 Source/Lua/CMakeLists.txt create mode 100644 Source/SVG/CMakeLists.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edf41bb17..955ed9f9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: Linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: BUILD_TYPE: Release @@ -17,16 +17,16 @@ jobs: include: - cc: clang cxx: clang++ - cmake_options: -DENABLE_PRECOMPILED_HEADERS=OFF -DSAMPLES_BACKEND=GLFW_GL2 + cmake_options: -DRMLUI_ENABLE_PRECOMPILED_HEADERS=OFF -DRMLUI_SAMPLES_BACKEND=GLFW_GL2 - cc: clang cxx: clang++ - cmake_options: -DSAMPLES_BACKEND=SDL_VK - - cmake_options: -DBUILD_TESTING=ON -DENABLE_PRECOMPILED_HEADERS=OFF + cmake_options: -DRMLUI_SAMPLES_BACKEND=SDL_VK + - cmake_options: -DRMLUI_BUILD_TESTING=ON -DRMLUI_ENABLE_PRECOMPILED_HEADERS=OFF enable_testing: true - - cmake_options: -DNO_FONT_INTERFACE_DEFAULT=ON -DENABLE_LOTTIE_PLUGIN=ON -DSAMPLES_BACKEND=X11_GL2 - - cmake_options: -DDISABLE_RTTI_AND_EXCEPTIONS=ON -DSAMPLES_BACKEND=SDL_GL2 - - cmake_options: -DNO_THIRDPARTY_CONTAINERS=ON -DSAMPLES_BACKEND=SFML_GL2 - - cmake_options: -DSAMPLES_BACKEND=SDL_VK -DRMLUI_VK_DEBUG=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DCMAKE_BUILD_TYPE=Debug + - cmake_options: -DRMLUI_FONT_INTERFACE="" -DRMLUI_ENABLE_LOTTIE_PLUGIN=ON -DRMLUI_SAMPLES_BACKEND=X11_GL2 + - cmake_options: -DRMLUI_DISABLE_RTTI_AND_EXCEPTIONS=ON -DRMLUI_SAMPLES_BACKEND=SDL_GL2 + - cmake_options: -DRMLUI_NO_THIRDPARTY_CONTAINERS=ON -DRMLUI_SAMPLES_BACKEND=SFML_GL2 + - cmake_options: -DRMLUI_SAMPLES_BACKEND=SDL_VK -DRMLUI_VK_DEBUG=ON -DRMLUI_ENABLE_PRECOMPILED_HEADERS=OFF -DCMAKE_BUILD_TYPE=Debug steps: - uses: actions/checkout@v3 @@ -41,8 +41,8 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/Build - run: >- - cmake $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_LUA_BINDINGS=ON -DBUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON + run: |- + cmake $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DRMLUI_BUILD_LUA_BINDINGS=ON -DRMLUI_BUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON ${{ matrix.cmake_options }} - name: Build @@ -65,8 +65,8 @@ jobs: fail-fast: false matrix: include: - - cmake_options: -DSAMPLES_BACKEND=auto - - cmake_options: -DSAMPLES_BACKEND=GLFW_GL2 + - cmake_options: -DRMLUI_SAMPLES_BACKEND=auto + - cmake_options: -DRMLUI_SAMPLES_BACKEND=GLFW_GL2 steps: - uses: actions/checkout@v3 @@ -79,8 +79,8 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/Build - run: >- - cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_LUA_BINDINGS=ON -DBUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON + run: |- + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DRMLUI_BUILD_LUA_BINDINGS=ON -DRMLUI_BUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON ${{ matrix.cmake_options }} - name: Build @@ -99,9 +99,9 @@ jobs: fail-fast: false matrix: include: - - cmake_options: -DSAMPLES_BACKEND=auto -DENABLE_PRECOMPILED_HEADERS=OFF - - cmake_options: -DSAMPLES_BACKEND=Win32_VK -DRMLUI_VK_DEBUG=ON - - cmake_options: -DSAMPLES_BACKEND=SDL_VK -DBUILD_LUA_BINDINGS_FOR_LUAJIT=ON + - cmake_options: -DRMLUI_SAMPLES_BACKEND=auto -DRMLUI_ENABLE_PRECOMPILED_HEADERS=OFF + - cmake_options: -DRMLUI_SAMPLES_BACKEND=Win32_VK -DRMLUI_VK_DEBUG=ON + - cmake_options: -DRMLUI_SAMPLES_BACKEND=SDL_VK -DRMLUI_BUILD_LUA_BINDINGS_FOR_LUAJIT=ON steps: - uses: actions/checkout@v3 @@ -114,8 +114,8 @@ jobs: - name: Configure CMake working-directory: ${{github.workspace}}/Build - run: >- - cmake $env:GITHUB_WORKSPACE -A x64 -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DBUILD_LUA_BINDINGS=ON -DBUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON + run: |- + cmake $env:GITHUB_WORKSPACE -A x64 -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DRMLUI_BUILD_LUA_BINDINGS=ON -DRMLUI_BUILD_SAMPLES=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ${{ matrix.cmake_options }} @@ -146,7 +146,7 @@ jobs: run: |- source emsdk-master/emsdk_env.sh cd Build - emcmake cmake $GITHUB_WORKSPACE -DBUILD_SAMPLES=ON -DBUILD_SHARED_LIBS=OFF -DWARNINGS_AS_ERRORS=ON -DEMSCRIPTEN_EXE_FLAGS="-O1" + emcmake cmake $GITHUB_WORKSPACE -DRMLUI_BUILD_SAMPLES=ON -DBUILD_SHARED_LIBS=OFF -DWARNINGS_AS_ERRORS=ON -DRMLUI_EMSCRIPTEN_EXE_FLAGS="-O1" - name: Build run: |- diff --git a/CMake/BackendFileList.cmake b/CMake/BackendFileList.cmake deleted file mode 100644 index 50b45bb9a..000000000 --- a/CMake/BackendFileList.cmake +++ /dev/null @@ -1,121 +0,0 @@ -set(BACKEND_COMMON_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend.h -) - -set(Win32_GL2_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_Win32_GL2.cpp -) -set(Win32_GL2_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_Windows.h -) - -set(Win32_VK_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_Win32_VK.cpp -) -set(Win32_VK_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/ShadersCompiledSPV.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/vk_mem_alloc.h -) - -set(X11_GL2_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_X11.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_X11_GL2.cpp -) -set(X11_GL2_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_X11.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_Xlib.h -) - -set(SDL_GL2_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_GL2.cpp -) -set(SDL_GL2_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h -) - -set(SDL_GL3_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_GL3.cpp -) -set(SDL_GL3_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_GL3.h -) - -set(SDL_VK_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_VK.cpp -) -set(SDL_VK_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/ShadersCompiledSPV.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/vk_mem_alloc.h -) - -set(SDL_SDLrenderer_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_SDL.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_SDLrenderer.cpp -) -set(SDL_SDLrenderer_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_SDL.h -) - -set(SFML_GL2_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SFML.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SFML_GL2.cpp -) -set(SFML_GL2_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SFML.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h -) - -set(GLFW_GL2_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_GL2.cpp -) -set(GLFW_GL2_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h -) - -set(GLFW_GL3_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_GL3.cpp -) -set(GLFW_GL3_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_GL3.h -) - -set(GLFW_VK_SRC_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_VK.cpp -) -set(GLFW_VK_HDR_FILES - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h - ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h -) diff --git a/CMake/Backends.cmake b/CMake/Backends.cmake new file mode 100644 index 000000000..b9ee3c7a2 --- /dev/null +++ b/CMake/Backends.cmake @@ -0,0 +1,154 @@ +# List of available backends +list(APPEND RMLUI_SAMPLES_AVAILABLE_BACKENDS + "Win32_GL2" + "Win32_VK" + "X11_GL2" + "SDL_GL2" + "SDL_GL3" + "SDL_VK" + "SDL_SDLrenderer" + "SFML_GL2" + "GLFW_GL2" + "GLFW_GL3" + "GLFW_VK" +) + +list(APPEND RMLUI_BACKEND_COMMON_HDR_FILES + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend.h +) + +add_library(rmlui_backend_Win32_GL2 INTERFACE) +target_sources(rmlui_backend_Win32_GL2 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_Win32_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_Windows.h +) +target_link_libraries(rmlui_backend_Win32_GL2 INTERFACE OpenGL::GL) + +add_library(rmlui_backend_Win32_VK INTERFACE) +target_sources(rmlui_backend_Win32_VK INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_Win32_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_Win32.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/ShadersCompiledSPV.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/vk_mem_alloc.h +) +target_link_libraries(rmlui_backend_Win32_VK INTERFACE Vulkan::Vulkan) + +add_library(rmlui_backend_X11_GL2 INTERFACE) +target_sources(rmlui_backend_X11_GL2 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_X11.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_X11_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_X11.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_Xlib.h +) + +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# Once the minimum CMake version is CMake >= 3.14, "${X11_LIBRARIES}" should +# be substituted by "X11:X11" in addition to any of the other imported that might +# be required. More info: +# https://cmake.org/cmake/help/latest/module/FindX11.html +target_link_libraries(rmlui_backend_X11_GL2 INTERFACE OpenGL::GL ${X11_LIBRARIES}) + + +add_library(rmlui_backend_SDL_GL2 INTERFACE) +target_sources(rmlui_backend_SDL_GL2 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h +) +target_link_libraries(rmlui_backend_SDL_GL2 INTERFACE OpenGL::GL SDL::SDL GLEW::GLEW SDL::Image) + +add_library(rmlui_backend_SDL_GL3 INTERFACE) +target_sources(rmlui_backend_SDL_GL3 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_GL3.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_GL3.h +) +target_link_libraries(rmlui_backend_SDL_GL3 INTERFACE OpenGL::GL SDL::SDL SDL::Image) + +add_library(rmlui_backend_SDL_VK INTERFACE) +target_sources(rmlui_backend_SDL_VK INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/ShadersCompiledSPV.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Vulkan/vk_mem_alloc.h +) +target_link_libraries(rmlui_backend_SDL_VK INTERFACE Vulkan::Vulkan SDL::SDL) + +add_library(rmlui_backend_SDL_SDLrenderer INTERFACE) +target_sources(rmlui_backend_SDL_SDLrenderer INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_SDL.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SDL_SDLrenderer.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SDL.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_SDL.h +) +target_link_libraries(rmlui_backend_SDL_SDLrenderer INTERFACE SDL::SDL SDL::Image) + +add_library(rmlui_backend_SFML_GL2 INTERFACE) +target_sources(rmlui_backend_SFML_GL2 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SFML.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_SFML_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_SFML.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h +) +target_link_libraries(rmlui_backend_SFML_GL2 INTERFACE OpenGL::GL rmlui_SFML_combo) + +add_library(rmlui_backend_GLFW_GL2 INTERFACE) +target_sources(rmlui_backend_GLFW_GL2 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_GL2.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL2.h +) +target_link_libraries(rmlui_backend_GLFW_GL2 INTERFACE OpenGL::GL glfw) + +add_library(rmlui_backend_GLFW_GL3 INTERFACE) +target_sources(rmlui_backend_GLFW_GL3 INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_GL3.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Include_GL3.h +) +target_link_libraries(rmlui_backend_GLFW_GL3 INTERFACE OpenGL::GL glfw) + +add_library(rmlui_backend_GLFW_VK INTERFACE) +target_sources(rmlui_backend_GLFW_VK INTERFACE + ${RMLUI_BACKEND_COMMON_HDR_FILES} + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Backend_GLFW_VK.cpp + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Platform_GLFW.h + ${PROJECT_SOURCE_DIR}/Backends/RmlUi_Renderer_VK.h +) +target_link_libraries(rmlui_backend_GLFW_VK INTERFACE Vulkan::Vulkan glfw) diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake new file mode 100644 index 000000000..a7efa5699 --- /dev/null +++ b/CMake/Dependencies.cmake @@ -0,0 +1,49 @@ +#[[ +Function to print a message to the console indicating a dependency hasn't been found +Arguments: + - friendly_name: Friendly name of the target + - target_name: Name of the CMake target the project is supposed to link against +]] +function(report_not_found_dependency friendly_name target_name) + message(FATAL_ERROR + "${friendly_name} has not been found by CMake." + "\nIf you are consuming RmlUi as a subdirectory inside another CMake project, please ensure that " + "${friendly_name} can be found by CMake or at least being linked using \"${target_name}\" as its " + "target name. You can create an ALIAS target to offer an alternative name for a CMake target." + ) +endfunction() + +# Freetype +if(RMLUI_FONT_INTERFACE STREQUAL "freetype") + # Declaring Freetype as a soft dependency so that it doesn't error out if the package + # is declared by other means + find_package("Freetype") + + # Instead of relying on the Freetype_NOTFOUND variable, we check directly for the target + if(NOT TARGET Freetype::Freetype) + report_not_found_dependency("Freetype" Freetype::Freetype) + endif() + + # Warn about problematic versions of the library with MSVC + if(DEFINED FREETYPE_VERSION_STRING) + if((${FREETYPE_VERSION_STRING} VERSION_GREATER_EQUAL "2.11.0") AND (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")) + message(WARNING "Using Freetype 2.11.0 or greater with MSVC can cause issues.") + endif() + else() + if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") + message(WARNING "Using Freetype 2.11.0 or greater with MSVC can cause issues.") + endif() + endif() +endif() + +# rlottie +if(RMLUI_ENABLE_LOTTIE_PLUGIN) + # Declaring rlottie as a soft dependency so that it doesn't error out if the package + # is declared by other means + find_package("rlottie") + + # Instead of relying on the rlottie_NOTFOUND variable, we check directly for the target + if(NOT TARGET rlottie::rlottie) + report_not_found_dependency("rlottie" rlottie::rlottie) + endif() +endif() diff --git a/CMake/SamplesDependencies.cmake b/CMake/SamplesDependencies.cmake new file mode 100644 index 000000000..983560370 --- /dev/null +++ b/CMake/SamplesDependencies.cmake @@ -0,0 +1,162 @@ +#[[ +Function to print a message to the console indicating a dependency hasn't been found +Arguments: + - friendly_name: Friendly name of the target + - target_name: Name of the CMake target the project is supposed to link against +]] +function(report_not_found_dependency friendly_name target_name) + message(FATAL_ERROR + "${friendly_name} has not been found by CMake." + "\nIf you are consuming RmlUi as a subdirectory inside another CMake project, please ensure that " + "${friendly_name} can be found by CMake or at least being linked using \"${target_name}\" as its " + "target name. You can create an ALIAS target to offer an alternative name for a CMake target." + ) +endfunction() + +# --- Window/input APIs --- +# SDL +if(RMLUI_SAMPLES_BACKEND MATCHES "^SDL") + # All dependencies are searched as soft dependencies so that they won't error out if the library + # is declared by other means + find_package("SDL") + + # RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: + # In CMake 3.19 the IMPORTED target SDL::SDL is available when using the FindSDL find module. + # More info: https://cmake.org/cmake/help/latest/module/FindSDL.html + # Current code operates using a hybrid mode by detecting either the variable or the target due to the possibility + # of package managers such as Conan and vcpkg of setting up SDL in their own way but always following the + # target naming conventions of the official CMake find modules + if(NOT TARGET SDL::SDL AND NOT SDL_FOUND) + report_not_found_dependency("SDL" SDL::SDL) + endif() + + # Set up the detected SDL as the SDL::SDL INTERFACE target if it hasn't already been created + # This is done for consistent referencing across the CMake code regardless of the CMake version + if(NOT TARGET SDL::SDL) + add_library(SDL INTERFACE) + add_library(SDL::SDL ALIAS SDL) + + # Any CMake target linking against SDL::SDL will link against the SDL libraries and have + # their include directories added to their target properties + target_link_libraries(SDL INTERFACE ${SDL_LIBRARIES}) + target_include_directories(SDL INTERFACE ${SDL_INCLUDE_DIRS}) + endif() + + # SDL_GL2 backend requires GLEW + if(RMLUI_SAMPLES_BACKEND STREQUAL "SDL_GL2") + find_package(GLEW) + if(NOT TARGET GLEW::GLEW) + report_not_found_dependency("GLEW" GLEW::GLEW) + endif() + endif() + + # Check version requirement for the SDL renderer + if(RMLUI_SAMPLES_BACKEND STREQUAL "SDL_SDLrenderer" AND SDL_VERSION VERSION_LESS "2.0.20") + message(FATAL_ERROR "SDL native renderer backend (${RMLUI_SAMPLES_BACKEND}) requires SDL 2.0.20 (found ${SDL_VERSION}).") + endif() + + # List of SDL backends that require SDL_image to work with samples + list(APPEND RMLUI_SDL_BACKENDS_WITH_SDLIMAGE "SDL_GL2" "SDL_GL3" "SDL_SDLrenderer") + + # Determine if the selected SDL backend requires SDL_image + list(FIND RMLUI_SDL_BACKENDS_WITH_SDLIMAGE ${RMLUI_SAMPLES_BACKEND} index) + if(index EQUAL "-1") + # If the backend hasn't been found in the list, SDL_image isn't required + set(RMLUI_SDLIMAGE_REQUIRED "0") + else() + # If the backend has been found in the list, SDL_image is required + set(RMLUI_SDLIMAGE_REQUIRED TRUE) + endif() + # Clear scope + unset(index) + unset(RMLUI_SDL_BACKENDS_WITH_SDLIMAGE) + + # Require SDL_image if needed + if(RMLUI_SDLIMAGE_REQUIRED) + find_package("SDL_image" REQUIRED) + + # RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: + # FindSDL_image doesn't provide an imported target to check against + # Using old method of using a variable to check + if(NOT SDL_IMAGE_FOUND AND NOT TARGET SDL::Image) + report_not_found_dependency("SDL_image" SDL::Image) + endif() + + # RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: + # No official target name has been decided for SDL_image yet, but we pretend there's one + # to make the code more future-proof + # For us, its name will be SDL::Image + if(NOT TARGET SDL::Image) + add_library(SDLimage INTERFACE) + add_library(SDL::Image ALIAS SDLimage) + + # Any CMake target linking against SDL::Image will link against the SDL_image libraries + # and have their include directories added to their target properties + target_link_libraries(SDLimage INTERFACE ${SDL_IMAGE_LIBRARIES}) + target_include_directories(SDLimage INTERFACE ${SDL_IMAGE_INCLUDE_DIRS}) + endif() + endif() +endif() + +if(RMLUI_SAMPLES_BACKEND MATCHES "^GLFW") + find_package("glfw3" "3.3") + + # Instead of relying on the _NOTFOUND variable, we check directly for the target + if(NOT TARGET glfw) + report_not_found_dependency("GLFW" glfw) + endif() +endif() + +if(RMLUI_SAMPLES_BACKEND MATCHES "^SFML") + # RmlUi backends with SFML use SFML 2, which still uses its own find module as preferred method + # This find module uses the old variable-based approach + if (WIN32) + find_package(SFML 2 COMPONENTS graphics window system main) + else() + find_package(SFML 2 COMPONENTS graphics window system) + endif() + + if(NOT SFML_FOUND) + report_not_found_dependency("SFML" SFML::SFML) + endif() + + # Create our own custom INTERFACE target to marshmallow future changes to SFML >= 2.6 + # SFML::Graphics SFML::Window SFML::System + add_library(rmlui_SFML_combo INTERFACE) + + # For SFML >= 2.6, only the target_link_libraries() is needed and it should be done + # against SFML::Graphics, SFML::Window, SFML::System, and SFML::System (Windows only) + target_link_libraries(rmlui_SFML_combo INTERFACE ${SFML_LIBRARIES}) + target_include_directories(rmlurmlui_SFML_combo INTERFACE ${SFML_INCLUDE_DIR}) +endif() + +if(RMLUI_SAMPLES_BACKEND MATCHES "^X11") + find_package("X11") +endif() + +# --- Rendering APIs --- +# OpenGL +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# OpenGL handling changes in CMake 3.11, requiring to set CMake policy CMP0072 +# More info: https://cmake.org/cmake/help/latest/policy/CMP0072.html +if(RMLUI_SAMPLES_BACKEND MATCHES "GL2$") + find_package("OpenGL" "2") + if(NOT TARGET OpenGL::GL) + report_not_found_dependency("OpenGL" OpenGL::GL) + endif() +endif() + +if(RMLUI_SAMPLES_BACKEND MATCHES "GL3$") + find_package("OpenGL" "3") + if(NOT TARGET OpenGL::GL) + report_not_found_dependency("OpenGL" OpenGL::GL) + endif() +endif() + +# Vulkan +if(RMLUI_SAMPLES_BACKEND MATCHES "VK$") + find_package("Vulkan") + if(NOT TARGET Vulkan::Vulkan) + report_not_found_dependency("Vulkan" Vulkan::Vulkan) + endif() +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..f62d536ed --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,38 @@ +# Using CMake 3.10.2 as minimum to support all platforms of interest +# https://github.com/mikke89/RmlUi/issues/198#issuecomment-1246957062 +cmake_minimum_required(VERSION "3.10.2") + +# Define CMake project +project("RmlUi" + VERSION "6.0" + DESCRIPTION "C++ user interface package based on the HTML and CSS standards" + LANGUAGES "C" "CXX" +) + +# Disable compiler-specific extensions +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Declare project-specific options +# "RMLUI_" prefix is included in order to take advantage of the fact that the +# CMake GUI can group variables based on their prefix to make more clear +# which options are specific to this project +set(RMLUI_FONT_INTERFACE "freetype" CACHE STRING "Font engine to build RmlUi with. If left empty, RmlUi won't be built with any of the included font interfaces.") +option(RMLUI_ENABLE_LOTTIE_PLUGIN "Enable plugin for Lottie animations. Requires the rlottie library." OFF) +option(RMLUI_ENABLE_SVG_PLUGIN "Enable plugin for SVG images. Requires the lunasvg library." OFF) +option(RMLUI_BUILD_SAMPLES "Build samples of the library." OFF) +set(RMLUI_SAMPLES_BACKEND "GLFW_GL3" CACHE STRING "Backend to use when building the RmlUi samples. Choose one from ./CMake/BackendFileList.cmake.") + +# 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") + +# Set up external dependencies +include("CMake/Dependencies.cmake") + +# Add CMake subdirectories +add_subdirectory("Source") + +if(RMLUI_BUILD_SAMPLES) + add_subdirectory("Samples") +endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..6b7a368c8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# RmlUi contribution guidelines + +## CMake + +The RmlUi project aims to be both compiled standalone and as a subfolder inside a bigger CMake project, allowing other CMake projects to integrate the library in their build pipeline without too much hassle. For this reason, the following conventions must be followed when editing CMake code for the project: + +- **Follow the [Modern CMake](https://cliutils.gitlab.io/modern-cmake/) conventions** + +- **Go simple:** CMake already allows to do many things without reinventing the wheel. Most code often written in a CMake build script is +not necessarily related to the project itself but to covering specific compilation scenarios and to set certain flags that aren't really +necessary as a means to pre-configure the project without having to input the options at configure time via the CMake CLI. This is a bad +practice that quickly increases the complexity of the build script. Instead: + - **For flags and options related to cross-compilation scenarios**, [CMake toolchain files](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html) should be used to set such flags and options. + - **If a compiler or compiler version is being problematic** about something, use a [CMake initial cache script](https://cmake.org/cmake/help/latest/manual/cmake.1.html#options) or CMake preset and advise the user to use it. This way, the consumer will always know when the compilation settings are being diverted from the compiler's default settings. + + Although not recommended, [CMake toolchain files](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html) can be used as well as long as the [`CMAKE_SYSTEM_NAME`](https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html) variable doesn't get set in the toolchain file. + + - **For platform-specific and case-specific flags** like building shared libraries or building framework packages for iOS and macOS, this + should be specified by the consumer, not by the project itself. For this, CMake toolchain files, CMake presets and initial cache scripts can be used. + + - **To share CMake flag configurations to save consumers time** use [CMake presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html), [CMake initial cache scripts](https://cmake.org/cmake/help/latest/manual/cmake.1.html#options) and ready-to-copy CLI commands in the documentation. + +- **Assume the person building the library is a consumer:** To save trouble to consumers, the default behavior of the CMake project should be oriented towards the bare minimum needed for the library to work (tests disabled, compilation of examples disabled, additional plugins disabled...). If the consumer needs anything more, they should be the ones tweaking the behavior of the project to suit their needs via CMake options. + +- **Use quotes to declare string literals:** + If not quoted and depending on the scenario, CMake and some of its functions might read a string literal might get misunderstood as a variable reference. It also helps with readability. + +- **Avoid setting global variables at all costs:** These should be set, if necessary, by the consumer via the CLI, a CMake configure preset, a CMake initial cache script or CMake variables coming from a parent CMake project, not by the project itself. This includes, among others, the widely used `CMAKE__FLAGS`. + +- **Avoid setting compiler and/or linker flags at all costs:** + Many projects have the habit of setting + compiler flags for things like preventing certain irremediable compiler warnings from appearing + in the compiler logs and to mitigate other compiler-specific issues, often creating an unnecessary + dependency on certain compilers, increasing the complexity of build scripts and potentially + creating issues with the project consuming the library. + + Both the code and the CMake project should aim to be as toolchain-agnostic as possible and therefore avoid + any kind of compiler-specific code as much as possible. **In the event that compiler flags need to be set and used in every possible use case of the library, please do so on a target basis** using either [CMake compile features](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html) + and [`target_compile_features()`](https://cmake.org/cmake/help/latest/command/target_compile_features.html) when possible or [`target_compile_options()`](https://cmake.org/cmake/help/latest/command/target_compile_options.html). The use of such flags by the project by default needs to be noted in the documentation in order to help consumers predict and mitigate any issues that may arise when consuming the library. + + If the goal is to save time for consumers to set certain options, these should be instead reproduced in a [CMake configure preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#configure-preset), a [CMake initial cache script](https://cmake.org/cmake/help/latest/manual/cmake.1.html#options) (for CMake versions without preset support) and specified in the documentation so that the consumer is always aware of which options are being used to compile the library. + +* **Do not reference [`CMAKE_SOURCE_DIR`](https://cmake.org/cmake/help/latest/variable/CMAKE_SOURCE_DIR.html):** RmlUi aims to be consumable by other CMake projects when being included as a CMake sub-project using [`add_subdirectory()`](https://cmake.org/cmake/help/latest/command/add_subdirectory.html). In this scenario, `CMAKE_SOURCE_DIR` won't point to the top source directory of the RmlUi source, but to the top source directory of the parent CMake project consuming RmlUi. For this reason, **reference [`PROJECT_SOURCE_DIR`](https://cmake.org/cmake/help/latest/variable/PROJECT_SOURCE_DIR.html) instead**. + +- **Use [generator expressions](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html) when relevant instead of their CMake variable counterparts:** To find the folder where the executable has been built or to simply find the current build type, CMake variables like `CMAKE_BUILD_TYPE` and `CMAKE_BINARY_DIR` have been used, but this behavior is not recommended as every build system has its own conventions when it comes to folder paths and not all details are known at configure time, specially when multi-config build systems like MSBuild are used. For this reason, it is strongly advised to use CMake generator expressions whenever possible to ensure the project can be compiled regardless of the build system used. If a CMake feature you need to use doesn't work with generator expressions, try making a CMake script and [calling it at build time](https://cmake.org/cmake/help/latest/manual/cmake.1.html#run-a-script) using [`add_custom_command()`](https://cmake.org/cmake/help/latest/command/add_custom_command.html) or create an issue or discussion in the RmlUi directory. + +- **Every time the minimum CMake version is going to be raised, check for the `RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE` keyword in all CMake files (`*.cmake`, `CMakeLists.txt`):** This keyword appears in comments indicating improvements, changes or warnings in the CMake project that could be relevant once the minimum CMake version reaches a certain point. Contributors are invited to add more of these comments as they implement more code for the CMake project so that they can be later revised when the moment to increase the minimum CMake version comes. diff --git a/Include/RmlUi/Core/Header.h b/Include/RmlUi/Core/Header.h index 31516e46e..f52d82dd9 100644 --- a/Include/RmlUi/Core/Header.h +++ b/Include/RmlUi/Core/Header.h @@ -36,7 +36,7 @@ #if !defined RMLUI_STATIC_LIB #if defined RMLUI_PLATFORM_WIN32 - #if defined RmlCore_EXPORTS + #if defined RMLCORE_EXPORTS #define RMLUICORE_API __declspec(dllexport) // Note: Changing a RMLUICORE_API_INLINE method // breaks ABI compatibility!! diff --git a/Include/RmlUi/Debugger/Header.h b/Include/RmlUi/Debugger/Header.h index 09a24ffde..76cd3fcc0 100644 --- a/Include/RmlUi/Debugger/Header.h +++ b/Include/RmlUi/Debugger/Header.h @@ -33,7 +33,7 @@ #if !defined RMLUI_STATIC_LIB #ifdef RMLUI_PLATFORM_WIN32 - #ifdef RmlDebugger_EXPORTS + #ifdef RMLUIDEBUGGER_EXPORTS #define RMLUIDEBUGGER_API __declspec(dllexport) #else #define RMLUIDEBUGGER_API __declspec(dllimport) diff --git a/Samples/CMakeLists.txt b/Samples/CMakeLists.txt new file mode 100644 index 000000000..d060d51d3 --- /dev/null +++ b/Samples/CMakeLists.txt @@ -0,0 +1,38 @@ +# Check the font interface configuration +if(RMLUI_FONT_INTERFACE STREQUAL "") + # If RmlUi is being built with no font interface, then samples cannot be built + message(FATAL_ERROR "Building samples has been enabled, but no font interface has been selected.") +endif() + +# Declare dependencies for samples +include("${PROJECT_SOURCE_DIR}/CMake/SamplesDependencies.cmake") + +# Add information about the available backends specified in CMake/Backends.cmake +include("${PROJECT_SOURCE_DIR}/CMake/Backends.cmake") + +# Check if the specified backend is available +list(FIND RMLUI_SAMPLES_AVAILABLE_BACKENDS ${RMLUI_SAMPLES_BACKEND} backend_index) +if(backend_index EQUAL "-1") + # If the backend identifier isn't found in the list, return error + message(FATAL_ERROR "The RmlUi backend ID specified in RMLUI_SAMPLES_BACKEND is not valid.") +endif() + +# Negotiate Vulkan debugging for Vulkan-based backends +if(RMLUI_SAMPLES_BACKEND MATCHES "VK$") + option(RMLUI_VK_DEBUG "Enable debugging mode for Vulkan renderer." OFF) + mark_as_advanced(RMLUI_VK_DEBUG) + if(RMLUI_VK_DEBUG) + # Add compile definition for Vulkan debugging + target_compile_definitions(${RMLUI_SAMPLES_BACKEND} INTERFACE "RMLUI_VK_DEBUG") + endif() +endif() + +# Change the runtime output directory of all target declared in this scope +# This is needed so that the shell library can find the samples asset files +# when running them from a CMake binary directory +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +# Add shell library for the samples +add_subdirectory("shell") + +add_subdirectory("basic") diff --git a/Samples/basic/CMakeLists.txt b/Samples/basic/CMakeLists.txt new file mode 100644 index 000000000..a092e451c --- /dev/null +++ b/Samples/basic/CMakeLists.txt @@ -0,0 +1,9 @@ +# Add CMake subdirectories of samples +add_subdirectory("benchmark") +add_subdirectory("demo") + +if(RMLUI_ENABLE_LOTTIE_PLUGIN) + add_subdirectory("lottie") +else() + message(NOTICE "Lottie sample disabled due to RMLUI_ENABLE_LOTTIE_PLUGIN=OFF") +endif() diff --git a/Samples/basic/benchmark/CMakeLists.txt b/Samples/basic/benchmark/CMakeLists.txt new file mode 100644 index 000000000..e1ec7a912 --- /dev/null +++ b/Samples/basic/benchmark/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(rmlui_samples_benchmark WIN32 + src/main.cpp +) + +target_link_libraries(rmlui_samples_benchmark PRIVATE rmlui_samples_shell) diff --git a/Samples/basic/demo/CMakeLists.txt b/Samples/basic/demo/CMakeLists.txt new file mode 100644 index 000000000..e9cf7ded5 --- /dev/null +++ b/Samples/basic/demo/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(rmlui_samples_demo WIN32 + src/main.cpp +) + +target_link_libraries(rmlui_samples_demo PRIVATE rmlui_samples_shell) diff --git a/Samples/basic/lottie/CMakeLists.txt b/Samples/basic/lottie/CMakeLists.txt new file mode 100644 index 000000000..5d92f101c --- /dev/null +++ b/Samples/basic/lottie/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(rmlui_samples_lottie WIN32 + src/main.cpp +) + +target_link_libraries(rmlui_samples_lottie PRIVATE rmlui_samples_shell) diff --git a/Samples/shell/CMakeLists.txt b/Samples/shell/CMakeLists.txt new file mode 100644 index 000000000..90c6aeb63 --- /dev/null +++ b/Samples/shell/CMakeLists.txt @@ -0,0 +1,22 @@ +# Quoting the source file paths isn't necessary because add_library() doesn't read +# CMake variables, just strings +add_library(rmlui_samples_shell STATIC + src/PlatformExtensions.cpp + src/RendererExtensions.cpp + src/Shell.cpp + src/ShellFileInterface.cpp +) + +# Add backend +target_link_libraries(rmlui_samples_shell PRIVATE rmlui_backend_${RMLUI_SAMPLES_BACKEND}) + +# Add include directories +target_include_directories(rmlui_samples_shell PUBLIC "include" "${PROJECT_SOURCE_DIR}/Backends") + +# Link against required libraries from Windows +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + # Required to use the functions from the shlwapi.h header + target_link_libraries(rmlui_samples_shell PRIVATE Shlwapi) +endif() + +target_link_libraries(rmlui_samples_shell PUBLIC RmlUi::RmlUi RmlUi::Debugger) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt new file mode 100644 index 000000000..86de312e5 --- /dev/null +++ b/Source/CMakeLists.txt @@ -0,0 +1,8 @@ +# Add plugin directories +add_subdirectory("Lottie") + +# Add main RmlUi directory +add_subdirectory("Core") + +# Add RmlUi debugger directory +add_subdirectory("Debugger") diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt new file mode 100644 index 000000000..bc8b34d53 --- /dev/null +++ b/Source/Core/CMakeLists.txt @@ -0,0 +1,393 @@ +# Declare core RmlUi library +# Not explicitly setting library type so that it can be chosen by consumer +# using BUILD_SHARED_LIBS +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because add_library() doesn't read +# CMake variables, just strings +add_library(rmlui_core + BaseXMLParser.cpp + Box.cpp + Clock.cpp + Clock.h + ComputedValues.cpp + ComputeProperty.cpp + ComputeProperty.h + Context.cpp + ContextInstancer.cpp + ContextInstancerDefault.cpp + ContextInstancerDefault.h + ConvolutionFilter.cpp + Core.cpp + DataController.cpp + DataControllerDefault.cpp + DataControllerDefault.h + DataController.h + DataExpression.cpp + DataExpression.h + DataModel.cpp + DataModel.h + DataModelHandle.cpp + DataTypeRegister.cpp + DataVariable.cpp + DataView.cpp + DataViewDefault.cpp + DataViewDefault.h + DataView.h + Decorator.cpp + DecoratorGradient.cpp + DecoratorGradient.h + DecoratorInstancer.cpp + DecoratorNinePatch.cpp + DecoratorNinePatch.h + DecoratorTiledBox.cpp + DecoratorTiledBox.h + DecoratorTiledBoxInstancer.cpp + DecoratorTiledBoxInstancer.h + DecoratorTiled.cpp + DecoratorTiled.h + DecoratorTiledHorizontal.cpp + DecoratorTiledHorizontal.h + DecoratorTiledHorizontalInstancer.cpp + DecoratorTiledHorizontalInstancer.h + DecoratorTiledImage.cpp + DecoratorTiledImage.h + DecoratorTiledImageInstancer.cpp + DecoratorTiledImageInstancer.h + DecoratorTiledInstancer.cpp + DecoratorTiledInstancer.h + DecoratorTiledVertical.cpp + DecoratorTiledVertical.h + DecoratorTiledVerticalInstancer.cpp + DecoratorTiledVerticalInstancer.h + DocumentHeader.cpp + DocumentHeader.h + ElementAnimation.cpp + ElementAnimation.h + ElementBackgroundBorder.cpp + ElementBackgroundBorder.h + Element.cpp + ElementDecoration.cpp + ElementDecoration.h + ElementDefinition.cpp + ElementDefinition.h + ElementDocument.cpp + ElementHandle.cpp + ElementHandle.h + ElementInstancer.cpp + ElementScroll.cpp + ElementStyle.cpp + ElementStyle.h + ElementText.cpp + ElementUtilities.cpp + Event.cpp + EventDispatcher.cpp + EventDispatcher.h + EventInstancer.cpp + EventInstancerDefault.cpp + EventInstancerDefault.h + EventListenerInstancer.cpp + EventSpecification.cpp + EventSpecification.h + Factory.cpp + FileInterface.cpp + FileInterfaceDefault.cpp + FileInterfaceDefault.h + FontEffectBlur.cpp + FontEffectBlur.h + FontEffect.cpp + FontEffectGlow.cpp + FontEffectGlow.h + FontEffectInstancer.cpp + FontEffectOutline.cpp + FontEffectOutline.h + FontEffectShadow.cpp + FontEffectShadow.h + FontEngineInterface.cpp + GeometryBackgroundBorder.cpp + GeometryBackgroundBorder.h + Geometry.cpp + GeometryDatabase.cpp + GeometryDatabase.h + GeometryUtilities.cpp + IdNameMap.h + Log.cpp + Math.cpp + Memory.cpp + Memory.h + ObserverPtr.cpp + Plugin.cpp + PluginRegistry.cpp + PluginRegistry.h + Pool.h + precompiled.h + Profiling.cpp + PropertiesIterator.h + PropertiesIteratorView.cpp + Property.cpp + PropertyDefinition.cpp + PropertyDictionary.cpp + PropertyParserAnimation.cpp + PropertyParserAnimation.h + PropertyParserColour.cpp + PropertyParserColour.h + PropertyParserDecorator.cpp + PropertyParserDecorator.h + PropertyParserFontEffect.cpp + PropertyParserFontEffect.h + PropertyParserKeyword.cpp + PropertyParserKeyword.h + PropertyParserNumber.cpp + PropertyParserNumber.h + PropertyParserRatio.cpp + PropertyParserRatio.h + PropertyParserString.cpp + PropertyParserString.h + PropertyParserTransform.cpp + PropertyParserTransform.h + PropertyShorthandDefinition.h + PropertySpecification.cpp + RenderInterface.cpp + ScrollController.cpp + ScrollController.h + Spritesheet.cpp + Stream.cpp + StreamFile.cpp + StreamFile.h + StreamMemory.cpp + StringUtilities.cpp + StyleSheetContainer.cpp + StyleSheet.cpp + StyleSheetFactory.cpp + StyleSheetFactory.h + StyleSheetNode.cpp + StyleSheetNode.h + StyleSheetParser.cpp + StyleSheetParser.h + StyleSheetSelector.cpp + StyleSheetSelector.h + StyleSheetSpecification.cpp + SystemInterface.cpp + TemplateCache.cpp + TemplateCache.h + Template.cpp + Template.h + Texture.cpp + TextureDatabase.cpp + TextureDatabase.h + TextureLayout.cpp + TextureLayout.h + TextureLayoutRectangle.cpp + TextureLayoutRectangle.h + TextureLayoutRow.cpp + TextureLayoutRow.h + TextureLayoutTexture.cpp + TextureLayoutTexture.h + TextureResource.cpp + TextureResource.h + Transform.cpp + TransformPrimitive.cpp + TransformState.cpp + TransformState.h + TransformUtilities.cpp + TransformUtilities.h + Tween.cpp + TypeConverter.cpp + URL.cpp + Variant.cpp + WidgetScroll.cpp + WidgetScroll.h + XMLNodeHandlerBody.cpp + XMLNodeHandlerBody.h + XMLNodeHandler.cpp + XMLNodeHandlerDefault.cpp + XMLNodeHandlerDefault.h + XMLNodeHandlerHead.cpp + XMLNodeHandlerHead.h + XMLNodeHandlerTemplate.cpp + XMLNodeHandlerTemplate.h + XMLParser.cpp + XMLParseTools.cpp + XMLParseTools.h +) + +# Set C++14 as requirement +target_compile_features(rmlui_core PUBLIC "cxx_std_14") + +# Add public include directories +target_include_directories(rmlui_core PUBLIC "${PROJECT_SOURCE_DIR}/Include") + +# Add public headers as files in the project (it's not necessary but convenient for IDE integration) +# Setting them as PRIVATE so that it's addition doesn't propagate, it won't affect availability since +# the entire include directory has already been declared as public +target_sources(rmlui_core PRIVATE + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Config/Config.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Animation.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/BaseXMLParser.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Box.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Colour.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ComputedValues.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Containers/itlib/flat_map.hpp + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Containers/itlib/flat_set.hpp + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Containers/LICENSE.txt + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Containers/robin_hood.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Context.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ContextInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ConvolutionFilter.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Core.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataModelHandle.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataStructHandle.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypeRegister.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataTypes.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DataVariable.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Debug.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Decorator.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/DecoratorInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Dictionary.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Element.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Element.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementDocument.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Input.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Log.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Math.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Matrix4.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Matrix4.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/NumericValue.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ObserverPtr.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Platform.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Plugin.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Profiling.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertiesIteratorView.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Property.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyDefinition.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyDictionary.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyIdSet.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyParser.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertySpecification.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Rectangle.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementScroll.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementText.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementUtilities.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Event.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/EventInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/EventListener.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/EventListenerInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Factory.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FileInterface.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FontEffect.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FontEffectInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FontEngineInterface.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FontGlyph.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/FontMetrics.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Geometry.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/GeometryUtilities.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Header.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ScriptInterface.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ScrollTypes.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Spritesheet.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Stream.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StreamMemory.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StringUtilities.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheet.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetContainer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetSpecification.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetTypes.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleTypes.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/SystemInterface.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Texture.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Traits.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Transform.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/TransformPrimitive.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Tween.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/TypeConverter.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/TypeConverter.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Types.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Unit.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/URL.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Utilities.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Variant.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Variant.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector2.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector2.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector3.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector3.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector4.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vector4.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Vertex.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/XMLNodeHandler.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/XMLParser.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementForm.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControl.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlInput.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlSelect.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlTextArea.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementProgress.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementTabSet.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ID.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/RenderInterface.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core.h +) + +# Add alias for the library so that a namespaced name can be used in the rest +# of the project to link against it +add_library(RmlUi::RmlUi ALIAS rmlui_core) + +# Set additional target properties +set_target_properties(rmlui_core PROPERTIES + # Add export name so that it can be exported with a namespaced name instead + # of using the name we actually used to declare the target + EXPORT_NAME "RmlUi::RmlUi" +) + +# Add the RmlUi element sources +add_subdirectory("Elements") +target_link_libraries(rmlui_core PRIVATE rmlui_core_elements) + +# Add the RmlUi layout sources +add_subdirectory("Layout") +target_link_libraries(rmlui_core PRIVATE rmlui_core_layout) + +# Avoid problems with MSVC's __dllspec() in static builds +get_target_property(rmlui_core_TYPE rmlui_core "TYPE") +if(rmlui_core_TYPE STREQUAL "STATIC_LIBRARY") + # If RmlUi is being compiled as a static library, notify code to disable usage of __dllspec() + # Since public headers also detect it, it needs to be a public definition + target_compile_definitions(rmlui_core PUBLIC "RMLUI_STATIC_LIB") +elseif(rmlui_core_TYPE STREQUAL "SHARED_LIBRARY") + # If RmlUi is being compiled as a shared library, notify code to export functions using __dllspec() + # For applications consuming the library, the headers will automatically use dllimport + # Platform and compiler handling is already done by code via pre-processor macros + target_compile_definitions(rmlui_core PRIVATE "RMLCORE_EXPORTS") +endif() + +# Negotiate usage of the default font engine +# When any new font engine is added, it must be added here with an else if statement before the else case +if(RMLUI_FONT_INTERFACE STREQUAL "freetype") + # Link against the default font engine + # Adding the subdirectory inside the conditional block so that compilation doesn't + # fail when CMake tries to build all targets, effectively hiding the CMake target from + # the build system if the default font interface is disabled + add_subdirectory("FontEngineDefault") + target_link_libraries(rmlui_core PRIVATE rmlui_core_fontenginedefault) +else() + # Pass information to code via compile definition + target_compile_definitions(rmlui_core PRIVATE "RMLUI_NO_FONT_INTERFACE_DEFAULT") +endif() + +# Negotiate usage of the Lottie plugin +if(RMLUI_ENABLE_LOTTIE_PLUGIN) + # Link against the Lottie plugin + target_link_libraries(rmlui_core PRIVATE rmlui_lottie) +endif() diff --git a/Source/Core/Elements/CMakeLists.txt b/Source/Core/Elements/CMakeLists.txt new file mode 100644 index 000000000..d24cca47a --- /dev/null +++ b/Source/Core/Elements/CMakeLists.txt @@ -0,0 +1,71 @@ +# Declare library +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because list() doesn't read +# CMake variables, just strings +add_library(rmlui_core_elements INTERFACE) + +# Set C++14 as requirement +target_compile_features(rmlui_core_elements INTERFACE "cxx_std_14") + +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# Using absolute paths to prevent improper interpretation of relative paths +# Relative paths can be used once the minimum CMake version is greater or +# equal than CMake 3.13 +target_sources(rmlui_core_elements INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/ElementFormControl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementFormControlInput.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementFormControlSelect.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementFormControlTextArea.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementForm.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementImage.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementImage.h + ${CMAKE_CURRENT_SOURCE_DIR}/ElementLabel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementLabel.h + ${CMAKE_CURRENT_SOURCE_DIR}/ElementProgress.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementTabSet.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementTextSelection.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementTextSelection.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeButton.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeButton.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeCheckbox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeCheckbox.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputType.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputType.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeRadio.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeRadio.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeRange.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeRange.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeSubmit.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeSubmit.h + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeText.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InputTypeText.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetDropDown.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetDropDown.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetSlider.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetSlider.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInput.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInput.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputMultiLine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputMultiLine.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputSingleLine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputSingleLine.h + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputSingleLinePassword.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/WidgetTextInputSingleLinePassword.h + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerSelect.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerSelect.h + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerTabSet.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerTabSet.h + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerTextArea.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/XMLNodeHandlerTextArea.h +) diff --git a/Source/Core/FontEngineDefault/CMakeLists.txt b/Source/Core/FontEngineDefault/CMakeLists.txt new file mode 100644 index 000000000..4d6ff4fba --- /dev/null +++ b/Source/Core/FontEngineDefault/CMakeLists.txt @@ -0,0 +1,44 @@ +# Declare library +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because list() doesn't read +# CMake variables, just strings +add_library(rmlui_core_fontenginedefault INTERFACE) + +# Set C++14 as requirement +target_compile_features(rmlui_core_fontenginedefault INTERFACE "cxx_std_14") + +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# Using absolute paths to prevent improper interpretation of relative paths +# Relative paths can be used once the minimum CMake version is greater or +# equal than CMake 3.13 +target_sources(rmlui_core_fontenginedefault INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/FontEngineInterfaceDefault.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontEngineInterfaceDefault.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontFace.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontFace.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontFaceHandleDefault.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontFaceHandleDefault.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontFaceLayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontFaceLayer.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontFamily.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontFamily.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontProvider.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FontProvider.h + ${CMAKE_CURRENT_SOURCE_DIR}/FontTypes.h + ${CMAKE_CURRENT_SOURCE_DIR}/FreeTypeInterface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FreeTypeInterface.h +) + +# Link library against Freetype +target_link_libraries(rmlui_core_fontenginedefault INTERFACE Freetype::Freetype) diff --git a/Source/Core/Layout/CMakeLists.txt b/Source/Core/Layout/CMakeLists.txt new file mode 100644 index 000000000..3283318ca --- /dev/null +++ b/Source/Core/Layout/CMakeLists.txt @@ -0,0 +1,61 @@ +# Declare library +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because list() doesn't read +# CMake variables, just strings +add_library(rmlui_core_layout INTERFACE) + +# Set C++14 as requirement +target_compile_features(rmlui_core_layout INTERFACE "cxx_std_14") + +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# Using absolute paths to prevent improper interpretation of relative paths +# Relative paths can be used once the minimum CMake version is greater or +# equal than CMake 3.13 +target_sources(rmlui_core_layout INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/BlockContainer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/BlockContainer.h + ${CMAKE_CURRENT_SOURCE_DIR}/BlockFormattingContext.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/BlockFormattingContext.h + ${CMAKE_CURRENT_SOURCE_DIR}/ContainerBox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ContainerBox.h + ${CMAKE_CURRENT_SOURCE_DIR}/FlexFormattingContext.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FlexFormattingContext.h + ${CMAKE_CURRENT_SOURCE_DIR}/FloatedBoxSpace.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FloatedBoxSpace.h + ${CMAKE_CURRENT_SOURCE_DIR}/FormattingContext.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FormattingContext.h + ${CMAKE_CURRENT_SOURCE_DIR}/InlineBox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InlineBox.h + ${CMAKE_CURRENT_SOURCE_DIR}/InlineContainer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InlineContainer.h + ${CMAKE_CURRENT_SOURCE_DIR}/InlineLevelBox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InlineLevelBox.h + ${CMAKE_CURRENT_SOURCE_DIR}/InlineTypes.h + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutBox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutBox.h + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutDetails.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutDetails.h + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutEngine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutEngine.h + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutPools.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LayoutPools.h + ${CMAKE_CURRENT_SOURCE_DIR}/LineBox.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LineBox.h + ${CMAKE_CURRENT_SOURCE_DIR}/ReplacedFormattingContext.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ReplacedFormattingContext.h + ${CMAKE_CURRENT_SOURCE_DIR}/TableFormattingContext.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TableFormattingContext.h + ${CMAKE_CURRENT_SOURCE_DIR}/TableFormattingDetails.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TableFormattingDetails.h +) diff --git a/Source/Debugger/CMakeLists.txt b/Source/Debugger/CMakeLists.txt new file mode 100644 index 000000000..2225cee6c --- /dev/null +++ b/Source/Debugger/CMakeLists.txt @@ -0,0 +1,76 @@ +# Declare core RmlUi debugger +# Not explicitly setting library type so that it can be chosen by consumer +# using BUILD_SHARED_LIBS +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because add_library() doesn't read +# CMake variables, just strings +add_library(rmlui_debugger + BeaconSource.h + CommonSource.h + Debugger.cpp + DebuggerPlugin.cpp + DebuggerPlugin.h + DebuggerSystemInterface.cpp + DebuggerSystemInterface.h + ElementContextHook.cpp + ElementContextHook.h + ElementInfo.cpp + ElementInfo.h + ElementLog.cpp + ElementLog.h + FontSource.h + Geometry.cpp + Geometry.h + InfoSource.h + LogSource.h + MenuSource.h +) + +# Set C++14 as requirement +target_compile_features(rmlui_debugger PUBLIC "cxx_std_14") + +# Add public include directories +target_include_directories(rmlui_debugger PUBLIC "${PROJECT_SOURCE_DIR}/Include") + +# Add public headers as files in the project (it's not necessary but convenient for IDE integration) +# Setting them as PRIVATE so that it's addition doesn't propagate, it won't affect availability since +# the entire include directory has already been declared as public +target_sources(rmlui_debugger PRIVATE + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Debugger/Debugger.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Debugger/Header.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Debugger.h +) + +# Link against RmlUi +target_link_libraries(rmlui_debugger PUBLIC RmlUi::RmlUi) + +# Add alias for the library so that a namespaced name can be used in the rest +# of the project to link against it +add_library(RmlUi::Debugger ALIAS rmlui_debugger) + +# Avoid problems with MSVC's __dllspec() in static builds +get_target_property(rmlui_debugger_TYPE rmlui_debugger "TYPE") +if(rmlui_debugger_TYPE STREQUAL "SHARED_LIBRARY") + # If RmlUi debugger is being compiled as a shared library, notify code to export functions using __dllspec() + # For applications consuming the library, the headers will automatically use dllimport + # Platform and compiler handling is already done by code via pre-processor macros + target_compile_definitions(rmlui_debugger PRIVATE "RMLUIDEBUGGER_EXPORTS") +endif() + +# Set additional target properties +set_target_properties(rmlui_debugger PROPERTIES + # Add export name so that it can be exported with a namespaced name instead + # of using the name we actually used to declare the target + EXPORT_NAME "RmlUi::Debugger" +) diff --git a/Source/Lottie/CMakeLists.txt b/Source/Lottie/CMakeLists.txt new file mode 100644 index 000000000..f6f0d5f21 --- /dev/null +++ b/Source/Lottie/CMakeLists.txt @@ -0,0 +1,40 @@ +# Declare library +# +# Although not necessary, header files are also included to improve IntelliSense +# capabilities on IDEs and language servers +# +# Tip: On UNIX systems you can run this on the current source folder to get the +# entire list of files in the folder copied on the files.txt file: +# +# ls *.cpp *.h > files.txt +# +# After running it, you can copy the text in that file and paste it here as a list +# of source files +# +# Quoting the source file paths isn't necessary because list() doesn't read +# CMake variables, just strings +add_library(rmlui_lottie INTERFACE) + +# Set C++14 as requirement +target_compile_features(rmlui_lottie INTERFACE "cxx_std_14") + +# RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE: +# Using absolute paths to prevent improper interpretation of relative paths +# Relative paths can be used once the minimum CMake version is greater or +# equal than CMake 3.13 +target_sources(rmlui_lottie INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/ElementLottie.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LottiePlugin.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/LottiePlugin.h +) + +# Add public headers as files in the project (it's not necessary but convenient for IDE integration) +target_sources(rmlui_lottie INTERFACE + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lottie/ElementLottie.h +) + +# Link library against rlottie +target_link_libraries(rmlui_lottie INTERFACE rlottie::rlottie) + +# Notify both private and public sources about the usage of the plugin +target_compile_definitions(rmlui_lottie INTERFACE "RMLUI_ENABLE_LOTTIE_PLUGIN") diff --git a/Source/Lua/CMakeLists.txt b/Source/Lua/CMakeLists.txt new file mode 100644 index 000000000..c940579f9 --- /dev/null +++ b/Source/Lua/CMakeLists.txt @@ -0,0 +1,13 @@ +# Placeholder CMake file + +# Add public headers as files in the project (it's not necessary but convenient for IDE integration) +target_sources(rmlui_lua INTERFACE + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Header.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/IncludeLua.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Interpreter.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Lua.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/LuaType.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/LuaType.inl + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Utilities.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua.h +) diff --git a/Source/SVG/CMakeLists.txt b/Source/SVG/CMakeLists.txt new file mode 100644 index 000000000..0afc4203f --- /dev/null +++ b/Source/SVG/CMakeLists.txt @@ -0,0 +1,6 @@ +# Placeholder CMake file + +# Add public headers as files in the project (it's not necessary but convenient for IDE integration) +target_sources(rmlui_svg INTERFACE + ${PROJECT_SOURCE_DIR}/Include/RmlUi/SVG/ElementSVG.h +)