From ac7ca10061a3fbe165bac681381de7cff038d735 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Wed, 4 Jan 2023 17:28:11 -0600 Subject: [PATCH 1/3] cmake: Separate cpm xmp-lite setup --- thirdparty/CMakeLists.txt | 60 +---------------------------------- thirdparty/cpm-xmp-lite.cmake | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 thirdparty/cpm-xmp-lite.cmake diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 850e4580c..18397528c 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -288,65 +288,7 @@ if(DiscordRPC_ADDED) endif() endif() -CPMAddPackage( - NAME xmp-lite - VERSION 4.5.0 - URL "https://github.com/libxmp/libxmp/releases/download/libxmp-4.5.0/libxmp-lite-4.5.0.tar.gz" - EXCLUDE_FROM_ALL ON - DOWNLOAD_ONLY ON -) -if(xmp-lite_ADDED) - set(xmp_sources - virtual.c - format.c - period.c - player.c - read_event.c - misc.c - dataio.c - lfo.c - scan.c - control.c - filter.c - effects.c - mixer.c - mix_all.c - load_helpers.c - load.c - hio.c - smix.c - memio.c - win32.c - - loaders/common.c - loaders/itsex.c - loaders/sample.c - loaders/xm_load.c - loaders/mod_load.c - loaders/s3m_load.c - loaders/it_load.c - ) - list(TRANSFORM xmp_sources PREPEND "${xmp-lite_SOURCE_DIR}/src/") - - add_library(xmp-lite "${SRB2_INTERNAL_LIBRARY_TYPE}" ${xmp_sources}) - - target_compile_definitions(xmp-lite PRIVATE -D_REENTRANT -DLIBXMP_CORE_PLAYER -DLIBXMP_NO_PROWIZARD -DLIBXMP_NO_DEPACKERS) - if("${SRB2_INTERNAL_LIBRARY_TYPE}" STREQUAL "STATIC") - if(WIN32) - # BUILDING_STATIC has to be public to work around a bug in xmp.h - # which adds __declspec(dllimport) even when statically linking - target_compile_definitions(xmp-lite PUBLIC -DBUILDING_STATIC) - else() - target_compile_definitions(xmp-lite PRIVATE -DBUILDING_STATIC) - endif() - else() - target_compile_definitions(xmp-lite PRIVATE -DBUILDING_DLL) - endif() - target_include_directories(xmp-lite PRIVATE "${xmp-lite_SOURCE_DIR}/src") - target_include_directories(xmp-lite PUBLIC "${xmp-lite_SOURCE_DIR}/include/libxmp-lite") - - add_library(xmp-lite::xmp-lite ALIAS xmp-lite) -endif() +include("cpm-xmp-lite.cmake") add_subdirectory(tcbrindle_span) add_subdirectory(stb_vorbis) diff --git a/thirdparty/cpm-xmp-lite.cmake b/thirdparty/cpm-xmp-lite.cmake new file mode 100644 index 000000000..21a721e0a --- /dev/null +++ b/thirdparty/cpm-xmp-lite.cmake @@ -0,0 +1,60 @@ +CPMAddPackage( + NAME xmp-lite + VERSION 4.5.0 + URL "https://github.com/libxmp/libxmp/releases/download/libxmp-4.5.0/libxmp-lite-4.5.0.tar.gz" + EXCLUDE_FROM_ALL ON + DOWNLOAD_ONLY ON +) + +if(xmp-lite_ADDED) + set(xmp_sources + virtual.c + format.c + period.c + player.c + read_event.c + misc.c + dataio.c + lfo.c + scan.c + control.c + filter.c + effects.c + mixer.c + mix_all.c + load_helpers.c + load.c + hio.c + smix.c + memio.c + win32.c + + loaders/common.c + loaders/itsex.c + loaders/sample.c + loaders/xm_load.c + loaders/mod_load.c + loaders/s3m_load.c + loaders/it_load.c + ) + list(TRANSFORM xmp_sources PREPEND "${xmp-lite_SOURCE_DIR}/src/") + + add_library(xmp-lite "${SRB2_INTERNAL_LIBRARY_TYPE}" ${xmp_sources}) + + target_compile_definitions(xmp-lite PRIVATE -D_REENTRANT -DLIBXMP_CORE_PLAYER -DLIBXMP_NO_PROWIZARD -DLIBXMP_NO_DEPACKERS) + if("${SRB2_INTERNAL_LIBRARY_TYPE}" STREQUAL "STATIC") + if(WIN32) + # BUILDING_STATIC has to be public to work around a bug in xmp.h + # which adds __declspec(dllimport) even when statically linking + target_compile_definitions(xmp-lite PUBLIC -DBUILDING_STATIC) + else() + target_compile_definitions(xmp-lite PRIVATE -DBUILDING_STATIC) + endif() + else() + target_compile_definitions(xmp-lite PRIVATE -DBUILDING_DLL) + endif() + target_include_directories(xmp-lite PRIVATE "${xmp-lite_SOURCE_DIR}/src") + target_include_directories(xmp-lite PUBLIC "${xmp-lite_SOURCE_DIR}/include/libxmp-lite") + + add_library(xmp-lite::xmp-lite ALIAS xmp-lite) +endif() From dd182cd0a11f8a3f04127a1b9d82577bc5b22f11 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Wed, 4 Jan 2023 17:29:19 -0600 Subject: [PATCH 2/3] cmake: Separate cpm discordrpc setup --- thirdparty/CMakeLists.txt | 80 ++------------------------------- thirdparty/cpm-discordrpc.cmake | 63 ++++++++++++++++++++++++++ thirdparty/cpm-rapidjson.cmake | 13 ++++++ 3 files changed, 79 insertions(+), 77 deletions(-) create mode 100644 thirdparty/cpm-discordrpc.cmake create mode 100644 thirdparty/cpm-rapidjson.cmake diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 18397528c..7aa04fc32 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -209,85 +209,11 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") ) target_compile_features(gme PRIVATE cxx_std_11) target_link_libraries(gme PRIVATE ZLIB::ZLIB) + endif() -CPMAddPackage( - NAME RapidJSON - VERSION 1.1.0 - URL "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz" - EXCLUDE_FROM_ALL ON - DOWNLOAD_ONLY ON -) -if(RapidJSON_ADDED) - add_library(RapidJSON INTERFACE) - add_library(RapidJSON::RapidJSON ALIAS RapidJSON) - target_include_directories(RapidJSON INTERFACE "${RapidJSON_SOURCE_DIR}/include") -endif() - -CPMAddPackage( - NAME DiscordRPC - VERSION 3.4.0 - URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip" - EXCLUDE_FROM_ALL ON - DOWNLOAD_ONLY ON -) - -if(DiscordRPC_ADDED) - set(DiscordRPC_SOURCES - include/discord_rpc.h - include/discord_register.h - - src/discord_rpc.cpp - src/rpc_connection.h - src/rpc_connection.cpp - src/serialization.h - src/serialization.cpp - src/connection.h - src/backoff.h - src/msg_queue.h - ) - list(TRANSFORM DiscordRPC_SOURCES PREPEND "${DiscordRPC_SOURCE_DIR}/") - - # Discord RPC is always statically linked because it's tiny. - add_library(discord-rpc STATIC ${DiscordRPC_SOURCES}) - add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc) - - target_include_directories(discord-rpc PUBLIC "${DiscordRPC_SOURCE_DIR}/include") - target_compile_features(discord-rpc PUBLIC cxx_std_11) - target_link_libraries(discord-rpc PRIVATE RapidJSON::RapidJSON) - - # Platform-specific connection and register impls - if(WIN32) - target_compile_definitions(discord-rpc PUBLIC -DDISCORD_WINDOWS) - target_sources(discord-rpc PRIVATE - "${DiscordRPC_SOURCE_DIR}/src/connection_win.cpp" - "${DiscordRPC_SOURCE_DIR}/src/discord_register_win.cpp" - ) - target_link_libraries(discord-rpc PRIVATE psapi advapi32) - endif() - - if(UNIX) - target_sources(discord-rpc PRIVATE - "${DiscordRPC_SOURCE_DIR}/src/connection_unix.cpp" - ) - - if(APPLE) - target_compile_definitions(discord-rpc PUBLIC -DDISCORD_OSX) - target_sources(discord-rpc PRIVATE - "${DiscordRPC_SOURCE_DIR}/src/discord_register_osx.m" - ) - target_link_libraries(discord-rpc PUBLIC "-framework AppKit") - endif() - - if(UNIX AND NOT APPLE) - target_compile_definitions(discord-rpc PUBLIC -DDISCORD_LINUX) - target_sources(discord-rpc PRIVATE - "${DiscordRPC_SOURCE_DIR}/src/discord_register_linux.cpp" - ) - endif() - endif() -endif() - +include("cpm-rapidjson.cmake") +include("cpm-discordrpc.cmake") include("cpm-xmp-lite.cmake") add_subdirectory(tcbrindle_span) diff --git a/thirdparty/cpm-discordrpc.cmake b/thirdparty/cpm-discordrpc.cmake new file mode 100644 index 000000000..078ebaab5 --- /dev/null +++ b/thirdparty/cpm-discordrpc.cmake @@ -0,0 +1,63 @@ +CPMAddPackage( + NAME DiscordRPC + VERSION 3.4.0 + URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip" + EXCLUDE_FROM_ALL ON + DOWNLOAD_ONLY ON +) + +if(DiscordRPC_ADDED) + set(DiscordRPC_SOURCES + include/discord_rpc.h + include/discord_register.h + + src/discord_rpc.cpp + src/rpc_connection.h + src/rpc_connection.cpp + src/serialization.h + src/serialization.cpp + src/connection.h + src/backoff.h + src/msg_queue.h + ) + list(TRANSFORM DiscordRPC_SOURCES PREPEND "${DiscordRPC_SOURCE_DIR}/") + + # Discord RPC is always statically linked because it's tiny. + add_library(discord-rpc STATIC ${DiscordRPC_SOURCES}) + add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc) + + target_include_directories(discord-rpc PUBLIC "${DiscordRPC_SOURCE_DIR}/include") + target_compile_features(discord-rpc PUBLIC cxx_std_11) + target_link_libraries(discord-rpc PRIVATE RapidJSON::RapidJSON) + + # Platform-specific connection and register impls + if(WIN32) + target_compile_definitions(discord-rpc PUBLIC -DDISCORD_WINDOWS) + target_sources(discord-rpc PRIVATE + "${DiscordRPC_SOURCE_DIR}/src/connection_win.cpp" + "${DiscordRPC_SOURCE_DIR}/src/discord_register_win.cpp" + ) + target_link_libraries(discord-rpc PRIVATE psapi advapi32) + endif() + + if(UNIX) + target_sources(discord-rpc PRIVATE + "${DiscordRPC_SOURCE_DIR}/src/connection_unix.cpp" + ) + + if(APPLE) + target_compile_definitions(discord-rpc PUBLIC -DDISCORD_OSX) + target_sources(discord-rpc PRIVATE + "${DiscordRPC_SOURCE_DIR}/src/discord_register_osx.m" + ) + target_link_libraries(discord-rpc PUBLIC "-framework AppKit") + endif() + + if(UNIX AND NOT APPLE) + target_compile_definitions(discord-rpc PUBLIC -DDISCORD_LINUX) + target_sources(discord-rpc PRIVATE + "${DiscordRPC_SOURCE_DIR}/src/discord_register_linux.cpp" + ) + endif() + endif() +endif() diff --git a/thirdparty/cpm-rapidjson.cmake b/thirdparty/cpm-rapidjson.cmake new file mode 100644 index 000000000..2836625ed --- /dev/null +++ b/thirdparty/cpm-rapidjson.cmake @@ -0,0 +1,13 @@ +CPMAddPackage( + NAME RapidJSON + VERSION 1.1.0 + URL "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz" + EXCLUDE_FROM_ALL ON + DOWNLOAD_ONLY ON +) + +if(RapidJSON_ADDED) + add_library(RapidJSON INTERFACE) + add_library(RapidJSON::RapidJSON ALIAS RapidJSON) + target_include_directories(RapidJSON INTERFACE "${RapidJSON_SOURCE_DIR}/include") +endif() From 81d1aa79c21f9699d19e5ca191f95b583149967a Mon Sep 17 00:00:00 2001 From: Eidolon Date: Wed, 4 Jan 2023 17:30:37 -0600 Subject: [PATCH 3/3] cmake: Split common deps setup scripts --- thirdparty/CMakeLists.txt | 205 +----------------------------------- thirdparty/cpm-curl.cmake | 35 ++++++ thirdparty/cpm-libgme.cmake | 15 +++ thirdparty/cpm-png.cmake | 73 +++++++++++++ thirdparty/cpm-sdl2.cmake | 13 +++ thirdparty/cpm-zlib.cmake | 54 ++++++++++ 6 files changed, 195 insertions(+), 200 deletions(-) create mode 100644 thirdparty/cpm-curl.cmake create mode 100644 thirdparty/cpm-libgme.cmake create mode 100644 thirdparty/cpm-png.cmake create mode 100644 thirdparty/cpm-sdl2.cmake create mode 100644 thirdparty/cpm-zlib.cmake diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 7aa04fc32..86a090b07 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -9,207 +9,12 @@ else() set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES ON) endif() - if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - CPMAddPackage( - NAME SDL2 - VERSION 2.24.2 - URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip" - EXCLUDE_FROM_ALL ON - OPTIONS - "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" - "SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" - "SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" - "SDL_TEST OFF" - "SDL2_DISABLE_SDL2MAIN ON" - "SDL2_DISABLE_INSTALL ON" - ) -endif() - -if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - CPMAddPackage( - NAME ZLIB - VERSION 1.2.13 - URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip" - EXCLUDE_FROM_ALL - DOWNLOAD_ONLY YES - ) - if(ZLIB_ADDED) - set(ZLIB_SRCS - crc32.h - deflate.h - gzguts.h - inffast.h - inffixed.h - inflate.h - inftrees.h - trees.h - zutil.h - - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c - ) - list(TRANSFORM ZLIB_SRCS PREPEND "${ZLIB_SOURCE_DIR}/") - - configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY) - configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY) - configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY) - - add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS}) - set_target_properties(ZLIB PROPERTIES - VERSION 1.2.13 - OUTPUT_NAME "z" - ) - target_include_directories(ZLIB PRIVATE "${ZLIB_SOURCE_DIR}") - target_include_directories(ZLIB PUBLIC "${ZLIB_BINARY_DIR}/include") - if(MSVC) - target_compile_definitions(ZLIB PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - endif() - add_library(ZLIB::ZLIB ALIAS ZLIB) - endif() -endif() - -if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - CPMAddPackage( - NAME png - VERSION 1.6.38 - URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip" - # png cmake build is broken on msys/mingw32 - DOWNLOAD_ONLY YES - ) - - if(png_ADDED) - # Since png's cmake build is broken, we're going to create a target manually - set( - PNG_SOURCES - - png.h - pngconf.h - - pngpriv.h - pngdebug.h - pnginfo.h - pngstruct.h - - png.c - pngerror.c - pngget.c - pngmem.c - pngpread.c - pngread.c - pngrio.c - pngrtran.c - pngrutil.c - pngset.c - pngtrans.c - pngwio.c - pngwrite.c - pngwtran.c - pngwutil.c - ) - list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/") - - add_custom_command( - OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h" - COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include" - DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" - VERBATIM - ) - add_custom_command( - OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h" - COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h" - DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" - VERBATIM - ) - list( - APPEND PNG_SOURCES - "${png_BINARY_DIR}/include/png.h" - "${png_BINARY_DIR}/include/pngconf.h" - "${png_BINARY_DIR}/include/pnglibconf.h" - ) - add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES}) - - # Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason - target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0) - - # The png includes need to be available to consumers - target_include_directories(png PUBLIC "${png_BINARY_DIR}/include") - - # ... and these also need to be present only for png build - target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}") - target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}") - target_include_directories(png PRIVATE "${png_BINARY_DIR}") - - target_link_libraries(png PRIVATE ZLIB::ZLIB) - add_library(PNG::PNG ALIAS png) - endif() -endif() - -if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - set( - internal_curl_options - - "BUILD_CURL_EXE OFF" - "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" - "CURL_DISABLE_TESTS ON" - "HTTP_ONLY ON" - "CURL_DISABLE_CRYPTO_AUTH ON" - "CURL_DISABLE_NTLM ON" - "ENABLE_MANUAL OFF" - "ENABLE_THREADED_RESOLVER OFF" - "CURL_USE_LIBPSL OFF" - "CURL_USE_LIBSSH2 OFF" - "USE_LIBIDN2 OFF" - "CURL_ENABLE_EXPORT_TARGET OFF" - ) - if(${CMAKE_SYSTEM} MATCHES Windows) - list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") - list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON") - endif() - if(${CMAKE_SYSTEM} MATCHES Darwin) - list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") - list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON") - endif() - if(${CMAKE_SYSTEM} MATCHES Linux) - list(APPEND internal_curl_options "CURL_USE_OPENSSL ON") - endif() - - CPMAddPackage( - NAME curl - VERSION 7.86.0 - URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip" - EXCLUDE_FROM_ALL ON - OPTIONS ${internal_curl_options} - ) -endif() - -if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - CPMAddPackage( - NAME libgme - VERSION 0.6.3 - URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip" - EXCLUDE_FROM_ALL ON - OPTIONS - "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" - "ENABLE_UBSAN OFF" - "GME_YM2612_EMU MAME" - ) - target_compile_features(gme PRIVATE cxx_std_11) - target_link_libraries(gme PRIVATE ZLIB::ZLIB) - +include("cpm-sdl2.cmake") + include("cpm-zlib.cmake") + include("cpm-png.cmake") + include("cpm-curl.cmake") + include("cpm-libgme.cmake") endif() include("cpm-rapidjson.cmake") diff --git a/thirdparty/cpm-curl.cmake b/thirdparty/cpm-curl.cmake new file mode 100644 index 000000000..3d8c6e61d --- /dev/null +++ b/thirdparty/cpm-curl.cmake @@ -0,0 +1,35 @@ +set( + internal_curl_options + + "BUILD_CURL_EXE OFF" + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "CURL_DISABLE_TESTS ON" + "HTTP_ONLY ON" + "CURL_DISABLE_CRYPTO_AUTH ON" + "CURL_DISABLE_NTLM ON" + "ENABLE_MANUAL OFF" + "ENABLE_THREADED_RESOLVER OFF" + "CURL_USE_LIBPSL OFF" + "CURL_USE_LIBSSH2 OFF" + "USE_LIBIDN2 OFF" + "CURL_ENABLE_EXPORT_TARGET OFF" +) +if(${CMAKE_SYSTEM} MATCHES Windows) + list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") + list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON") +endif() +if(${CMAKE_SYSTEM} MATCHES Darwin) + list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF") + list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON") +endif() +if(${CMAKE_SYSTEM} MATCHES Linux) + list(APPEND internal_curl_options "CURL_USE_OPENSSL ON") +endif() + +CPMAddPackage( + NAME curl + VERSION 7.86.0 + URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip" + EXCLUDE_FROM_ALL ON + OPTIONS ${internal_curl_options} +) diff --git a/thirdparty/cpm-libgme.cmake b/thirdparty/cpm-libgme.cmake new file mode 100644 index 000000000..1786ad0ec --- /dev/null +++ b/thirdparty/cpm-libgme.cmake @@ -0,0 +1,15 @@ +CPMAddPackage( + NAME libgme + VERSION 0.6.3 + URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "ENABLE_UBSAN OFF" + "GME_YM2612_EMU MAME" +) + +if(libgme_ADDED) + target_compile_features(gme PRIVATE cxx_std_11) + target_link_libraries(gme PRIVATE ZLIB::ZLIB) +endif() diff --git a/thirdparty/cpm-png.cmake b/thirdparty/cpm-png.cmake new file mode 100644 index 000000000..716ff27b8 --- /dev/null +++ b/thirdparty/cpm-png.cmake @@ -0,0 +1,73 @@ +CPMAddPackage( + NAME png + VERSION 1.6.38 + URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip" + # png cmake build is broken on msys/mingw32 + DOWNLOAD_ONLY YES +) + +if(png_ADDED) + # Since png's cmake build is broken, we're going to create a target manually + set( + PNG_SOURCES + + png.h + pngconf.h + + pngpriv.h + pngdebug.h + pnginfo.h + pngstruct.h + + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c + ) + list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/") + + add_custom_command( + OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h" + COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include" + DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" + VERBATIM + ) + add_custom_command( + OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h" + COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h" + DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" + VERBATIM + ) + list( + APPEND PNG_SOURCES + "${png_BINARY_DIR}/include/png.h" + "${png_BINARY_DIR}/include/pngconf.h" + "${png_BINARY_DIR}/include/pnglibconf.h" + ) + add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES}) + + # Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason + target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0) + + # The png includes need to be available to consumers + target_include_directories(png PUBLIC "${png_BINARY_DIR}/include") + + # ... and these also need to be present only for png build + target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}") + target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}") + target_include_directories(png PRIVATE "${png_BINARY_DIR}") + + target_link_libraries(png PRIVATE ZLIB::ZLIB) + add_library(PNG::PNG ALIAS png) +endif() diff --git a/thirdparty/cpm-sdl2.cmake b/thirdparty/cpm-sdl2.cmake new file mode 100644 index 000000000..58cf9afc2 --- /dev/null +++ b/thirdparty/cpm-sdl2.cmake @@ -0,0 +1,13 @@ +CPMAddPackage( + NAME SDL2 + VERSION 2.24.2 + URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip" + EXCLUDE_FROM_ALL ON + OPTIONS + "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" + "SDL_TEST OFF" + "SDL2_DISABLE_SDL2MAIN ON" + "SDL2_DISABLE_INSTALL ON" +) diff --git a/thirdparty/cpm-zlib.cmake b/thirdparty/cpm-zlib.cmake new file mode 100644 index 000000000..aee090083 --- /dev/null +++ b/thirdparty/cpm-zlib.cmake @@ -0,0 +1,54 @@ +CPMAddPackage( + NAME ZLIB + VERSION 1.2.13 + URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip" + EXCLUDE_FROM_ALL + DOWNLOAD_ONLY YES +) + +if(ZLIB_ADDED) + set(ZLIB_SRCS + crc32.h + deflate.h + gzguts.h + inffast.h + inffixed.h + inflate.h + inftrees.h + trees.h + zutil.h + + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + inflate.c + infback.c + inftrees.c + inffast.c + trees.c + uncompr.c + zutil.c + ) + list(TRANSFORM ZLIB_SRCS PREPEND "${ZLIB_SOURCE_DIR}/") + + configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY) + configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY) + configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY) + + add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS}) + set_target_properties(ZLIB PROPERTIES + VERSION 1.2.13 + OUTPUT_NAME "z" + ) + target_include_directories(ZLIB PRIVATE "${ZLIB_SOURCE_DIR}") + target_include_directories(ZLIB PUBLIC "${ZLIB_BINARY_DIR}/include") + if(MSVC) + target_compile_definitions(ZLIB PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + endif() + add_library(ZLIB::ZLIB ALIAS ZLIB) +endif()