Unbundles fmt, re2, expected, libplum dependencies. patch by Lilah Tascheter and bdunahu . diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 46c0c26e1..dcebb5326 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -20,13 +20,13 @@ endif() add_subdirectory(launchinfo EXCLUDE_FROM_ALL) set_property(TARGET launchinfo PROPERTY FOLDER "3rdparty") -SET(FMT_INSTALL OFF CACHE BOOL "Generate the install target" FORCE) -SET(FMT_SYSTEM_HEADERS ON CACHE BOOL "Expose headers with marking them as system." FORCE) -add_subdirectory(fmt EXCLUDE_FROM_ALL) -set_property(TARGET fmt PROPERTY FOLDER "3rdparty") -# Define a custom inline namespace for the fmt used by WZ, to prevent ODR violations if static linking to any libraries that themselves embed (a different version of) fmt -target_compile_definitions(fmt PUBLIC "FMT_BEGIN_NAMESPACE=namespace fmt { inline namespace v12_wz2100 {") -target_compile_definitions(fmt PUBLIC "FMT_END_NAMESPACE=}}") +pkg_check_modules(FMT REQUIRED fmt) +add_library(fmt UNKNOWN IMPORTED) +set_target_properties(fmt PROPERTIES + IMPORTED_LOCATION ${FMT_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${FMT_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES ${FMT_LINK_LIBRARIES} +) # inih library @@ -44,15 +44,13 @@ target_compile_definitions(inih PRIVATE ) # re2 -SET(RE2_BUILD_TESTING OFF CACHE BOOL "enable testing for RE2" FORCE) -add_subdirectory(re2 EXCLUDE_FROM_ALL) -target_include_directories(re2 PUBLIC - $ +pkg_check_modules(RE2 REQUIRED re2) +add_library(re2 UNKNOWN IMPORTED) +set_target_properties(re2 PROPERTIES + IMPORTED_LOCATION ${RE2_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${RE2_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES ${RE2_LINK_LIBRARIES} ) -set_property(TARGET re2 PROPERTY FOLDER "3rdparty") -set_property(TARGET re2 PROPERTY XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS NO) # -Wmissing-field-initializers -set_property(TARGET re2 PROPERTY XCODE_ATTRIBUTE_GCC_WARN_SHADOW NO) # -Wshadow -set_property(TARGET re2 PROPERTY XCODE_ATTRIBUTE_WARNING_CFLAGS "-Wno-missing-field-initializers -Wno-shadow") add_subdirectory(EmbeddedJSONSignature EXCLUDE_FROM_ALL) set_property(TARGET EmbeddedJSONSignature PROPERTY FOLDER "3rdparty") @@ -268,35 +266,6 @@ if (WZ_PROFILING_NVTX) endif () -set(PLUM_NO_EXAMPLE ON CACHE BOOL "Disable example build" FORCE) -add_subdirectory(libplum EXCLUDE_FROM_ALL) -set_target_properties(plum plum-static PROPERTIES FOLDER "3rdparty") -if(NOT MSVC) - set(_supported_libplum_c_compiler_flags "") - - # -Wshadow - check_compiler_flags_output("-Werror -Wno-shadow -Wno-error=cpp" COMPILER_TYPE C OUTPUT_FLAGS "-Wno-shadow" OUTPUT_VARIABLE _supported_libplum_c_compiler_flags APPEND) - - if (NOT _supported_libplum_c_compiler_flags STREQUAL "") - string(REPLACE " " ";" _supported_libplum_c_compiler_flags "${_supported_libplum_c_compiler_flags}") - target_compile_options(plum PRIVATE ${_supported_libplum_c_compiler_flags}) - target_compile_options(plum-static PRIVATE ${_supported_libplum_c_compiler_flags}) - endif() -endif() - -set(EXPECTED_BUILD_TESTS OFF) -add_subdirectory(expected EXCLUDE_FROM_ALL) -# There isn't any release note or established CMake policy about this behavior, -# but looks like prior to CMake 3.19 only a handful of `INTERFACE_*` properties -# were allowed for INTERFACE libraries (which is our case). This restriction -# seems to be lifted in CMake 3.19 and later. -# -# See https://discourse.cmake.org/t/how-to-find-current-interface-library-property-whitelist/4784/2 -# for some clarification about this. -if (CMAKE_VERSION VERSION_GREATER "3.18") - set_target_properties(expected PROPERTIES FOLDER "3rdparty") -endif() - set(_default_enable_gns_network_backend_value ON) if(CMAKE_SYSTEM_NAME MATCHES "Emscripten") set(_default_enable_gns_network_backend_value OFF) diff --git a/lib/ivis_opengl/CMakeLists.txt b/lib/ivis_opengl/CMakeLists.txt index fd2d62a2c..72e9c7544 100644 --- a/lib/ivis_opengl/CMakeLists.txt +++ b/lib/ivis_opengl/CMakeLists.txt @@ -90,7 +90,7 @@ set_property(TARGET ivis-opengl PROPERTY FOLDER "lib") include(WZTargetConfiguration) WZ_TARGET_CONFIGURATION(ivis-opengl) -target_link_libraries(ivis-opengl PRIVATE framework launchinfo fmt::fmt) +target_link_libraries(ivis-opengl PRIVATE framework launchinfo fmt) if(CMAKE_SYSTEM_NAME MATCHES "Emscripten") # We should be using the Emscripten port linker flags for FreeType & Harfbuzz else() diff --git a/lib/netplay/CMakeLists.txt b/lib/netplay/CMakeLists.txt index 511ac7b89..82efbe6f4 100644 --- a/lib/netplay/CMakeLists.txt +++ b/lib/netplay/CMakeLists.txt @@ -84,6 +84,8 @@ if(MSVC AND CMAKE_VERSION VERSION_GREATER 3.7) source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" PREFIX "Headers" FILES ${HEADERS}) endif() +find_package (tl-expected REQUIRED) +find_package (LibPlum REQUIRED) find_package (Threads REQUIRED) find_package (ZLIB REQUIRED) @@ -113,7 +115,7 @@ set_property(TARGET netplay PROPERTY FOLDER "lib") include(WZTargetConfiguration) WZ_TARGET_CONFIGURATION(netplay) target_link_libraries(netplay - PRIVATE framework re2::re2 nlohmann_json plum-static Threads::Threads ZLIB::ZLIB fmt::fmt + PRIVATE framework re2 nlohmann_json plum Threads::Threads ZLIB::ZLIB fmt PUBLIC tl::expected) if(WZ_USE_IMPORTED_MINIUPNPC) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f07f0edb..4fe645425 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,7 +130,7 @@ endif() target_link_libraries(warzone2100 exception-handler gamelib wzmaplib ZipIOProvider ivis-opengl netplay sdl-backend framework sequence sound widget) target_link_libraries(warzone2100 launchinfo EmbeddedJSONSignature) -target_link_libraries(warzone2100 fmt::fmt) +target_link_libraries(warzone2100 fmt) if(ENABLE_NLS) target_link_libraries(warzone2100 ${Intl_LIBRARIES}) endif() @@ -146,7 +146,7 @@ else() include(IncludeFindCurl) target_link_libraries(warzone2100 CURL::libcurl) endif() -target_link_libraries(warzone2100 re2::re2) +target_link_libraries(warzone2100 re2) find_package(SQLite3 3.14 REQUIRED) target_link_libraries(warzone2100 SQLite::SQLite3)