Skip to content

Commit

Permalink
CMake modernization
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hobyst committed Jul 5, 2023
1 parent 0df1bbb commit dfde5d6
Show file tree
Hide file tree
Showing 24 changed files with 1,268 additions and 143 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
Linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

env:
BUILD_TYPE: Release
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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: |-
Expand Down
121 changes: 0 additions & 121 deletions CMake/BackendFileList.cmake

This file was deleted.

154 changes: 154 additions & 0 deletions CMake/Backends.cmake
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit dfde5d6

Please sign in to comment.