-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
24 changed files
with
1,116 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
set(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 | ||
${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 | ||
${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 | ||
${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 | ||
${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) | ||
|
||
add_library(rmlui_backend_SDL_GL3 INTERFACE) | ||
target_sources(rmlui_backend_SDL_GL3 INTERFACE | ||
${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) | ||
|
||
add_library(rmlui_backend_SDL_VK INTERFACE) | ||
target_sources(rmlui_backend_SDL_VK INTERFACE | ||
${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 | ||
${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) | ||
|
||
add_library(rmlui_backend_SFML_GL2 INTERFACE) | ||
target_sources(rmlui_backend_SFML_GL2 INTERFACE | ||
${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 SFML::Graphics SFML::Window SFML::System) | ||
|
||
add_library(rmlui_backend_GLFW_GL2 INTERFACE) | ||
target_sources(rmlui_backend_GLFW_GL2 INTERFACE | ||
${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 | ||
${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 | ||
${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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#[[ | ||
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. If you are consuming RmlUi as a subdirectory " | ||
"inside another CMake project, please ensure that ${friendly_name} can be 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() |
Oops, something went wrong.