diff --git a/.gitmodules b/.gitmodules index 209d9b8874..487725bfbf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,3 +27,6 @@ [submodule "rts/lib/entt"] path = rts/lib/entt url = https://github.com/skypjack/entt +[submodule "rts/lib/RmlUi"] + path = rts/lib/RmlUi + url = https://github.com/mikke89/RmlUi.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6459eda087..81f2336482 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,9 @@ else() set(JAVA_COMPILE_FLAG_CONDITIONAL "-g:lines,source") endif() +# By default, the libraries that don't explicily specify SHARED/STATIC are build statically. +# See https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html +option(BUILD_SHARED_LIBS "Build shared (dynamic) libraries" OFF) # Tell windows to pass arguments around in @response files # (32k arg limit workaround) diff --git a/rts/System/SpringApp.cpp b/rts/System/SpringApp.cpp index 7a152d9641..df98e6bef9 100644 --- a/rts/System/SpringApp.cpp +++ b/rts/System/SpringApp.cpp @@ -6,6 +6,9 @@ #include #include +// Include before other headers that define a bunch of macros that break stuff. +#include + #include #include @@ -216,6 +219,17 @@ SpringApp::~SpringApp() spring_clock::PopTickRate(); } +class DummyRmlUiSpringSystemInterface : public Rml::SystemInterface { +public: + double GetElapsedTime() override { + return 0.0; + } + +private: + std::chrono::steady_clock::time_point start; +}; + +static DummyRmlUiSpringSystemInterface dummyRmlUiSpringSystemInterface; /** * @brief Initializes the SpringApp instance @@ -241,6 +255,9 @@ bool SpringApp::Init() Watchdog::Install(); Watchdog::RegisterThread(WDT_MAIN, true); + // A dummy call to basic RmlUi function to verify that all is linking correctly. + Rml::SetSystemInterface(&dummyRmlUiSpringSystemInterface); + // Create Window if (!InitWindow(("Spring " + SpringVersion::GetSync()).c_str())) { SDL_Quit(); diff --git a/rts/builds/headless/CMakeLists.txt b/rts/builds/headless/CMakeLists.txt index 92f012931b..d54c10e443 100644 --- a/rts/builds/headless/CMakeLists.txt +++ b/rts/builds/headless/CMakeLists.txt @@ -27,6 +27,7 @@ list(APPEND engineHeadlessLibraries ${engineCommonLibraries}) list(APPEND engineHeadlessLibraries no-sound) list(APPEND engineHeadlessLibraries engineSim) list(APPEND engineHeadlessLibraries pr-downloader) +list(APPEND engineHeadlessLibraries RmlCore) include_directories(${ENGINE_SRC_ROOT_DIR}/lib/assimp/include) include_directories(${ENGINE_SRC_ROOT_DIR}/lib/asio/include) diff --git a/rts/builds/legacy/CMakeLists.txt b/rts/builds/legacy/CMakeLists.txt index b2a8c1a65c..c190d0380d 100644 --- a/rts/builds/legacy/CMakeLists.txt +++ b/rts/builds/legacy/CMakeLists.txt @@ -36,6 +36,7 @@ if (FONTCONFIG_FOUND) endif (PREFER_STATIC_LIBS) endif (FONTCONFIG_FOUND) +# !!! If you change freetype resolution here, change it also in rts/lib find_freetype_hack() # hack to find different named freetype.dll find_package_static(Freetype REQUIRED) foreach(f ${FREETYPE_INCLUDE_DIRS}) @@ -64,6 +65,7 @@ list(APPEND engineLibraries ${engineCommonLibraries}) list(APPEND engineLibraries ${SPRING_SIM_LIBRARIES}) list(APPEND engineLibraries engineSim) list(APPEND engineLibraries pr-downloader) +list(APPEND engineLibraries RmlCore) ### Assemble external incude dirs list(APPEND engineIncludes ${OPENAL_INCLUDE_DIR}) diff --git a/rts/lib/CMakeLists.txt b/rts/lib/CMakeLists.txt index e64914ace7..3eb7137c52 100644 --- a/rts/lib/CMakeLists.txt +++ b/rts/lib/CMakeLists.txt @@ -85,3 +85,20 @@ option(TRACY_ON_DEMAND "Enable tracy profiling" ON) option(TRACY_PROFILE_MEMORY "Profile memory allocations" OFF) add_subdirectory(tracy) + +# TODO(p2004): Enabling tracy for RmlUi is at the momemnt broken and waits for +# resolution upstream https://github.com/mikke89/RmlUi/issues/516. +# if (TRACY_ENABLE) +# set(ENABLE_TRACY_PROFILING ON CACHE BOOL "Enable RmlUi tracy profiling") +# # Place the include directories for tracy in TRACY_INCLUDE_DIR as that's +# # what RmlUi expects to be set in their FindTracy.cmake +# get_target_property(TRACY_INCLUDE_DIR TracyClient INCLUDE_DIRECTORIES) +# endif() + +# We resolve freetype here to make sure RmlUi find_package picks the same +# correct version as picked by the engine. +# !!! If you change freetype resolution here, change it also in rts/builds/legacy +find_freetype_hack() # hack to find different named freetype.dll +find_package_static(Freetype REQUIRED) + +add_subdirectory(RmlUi) diff --git a/rts/lib/RmlUi b/rts/lib/RmlUi new file mode 160000 index 0000000000..a602da2440 --- /dev/null +++ b/rts/lib/RmlUi @@ -0,0 +1 @@ +Subproject commit a602da244048f99fa1730194c8479b377227f7c6