From e827f19554cea194578ede18acd41ee469047429 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Sun, 29 Mar 2026 03:29:51 +0200 Subject: [PATCH] Give up on fetching libjpeg-turbo ourselves, rely on find_package and user providing it at build time --- CMakeLists.txt | 20 +++++++++++--------- cmake/libjpeg.cmake | 12 ------------ 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 cmake/libjpeg.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 797b055c47..cae567cbce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,15 @@ option(DUSK_BUILD_WARNINGS "If off, compiler warnings will be suppressed") option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled with optimizations on Debug, intending to make the game run at 30 FPS. Note for MSVC: you will need to remove '/RTC1' from your debug flags in CMake.") option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) +find_package(libjpeg-turbo) +set(DUSK_MOVIE_SUPPORT_REAL ${DUSK_MOVIE_SUPPORT}) +if (DUSK_MOVIE_SUPPORT AND NOT libjpeg-turbo_FOUND) + message(WARNING "libjpeg-turbo not found but DUSK_MOVIE_SUPPORT set, movie playback will not be available!") + set(DUSK_MOVIE_SUPPORT_REAL OFF) +endif () + +message(WARNING "FOUND: ${libjpeg-turbo_FOUND}") + if (CMAKE_SYSTEM_NAME STREQUAL Linux) # -Wno-multichar: Multi-character constants ('ABCD') are implementation-defined but all compilers # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. @@ -54,10 +63,6 @@ endif () include(FetchContent) -if (DUSK_MOVIE_SUPPORT) - include(ExternalProject) -endif () - message(STATUS "dusk: Fetching cxxopts") FetchContent_Declare( cxxopts @@ -67,9 +72,6 @@ FetchContent_Declare( FetchContent_MakeAvailable(cxxopts) -if (DUSK_MOVIE_SUPPORT) - include(cmake/libjpeg.cmake) -endif () include(files.cmake) # TODO: version handling for res includes @@ -116,8 +118,8 @@ add_library(game SHARED ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${J src/dusk/imgui/ImGuiAudio.cpp) target_link_libraries(game PRIVATE game_debug cxxopts::cxxopts) -if (DUSK_MOVIE_SUPPORT) - target_link_libraries(game PRIVATE libjpeg-turbo-lib) +if (DUSK_MOVIE_SUPPORT_REAL) + target_link_libraries(game PRIVATE libjpeg-turbo::turbojpeg-static) target_compile_definitions(game PRIVATE MOVIE_SUPPORT=1) endif () target_compile_definitions(game PRIVATE TARGET_PC AVOID_UB=1 VERSION=0 NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0 diff --git a/cmake/libjpeg.cmake b/cmake/libjpeg.cmake deleted file mode 100644 index b7f719f003..0000000000 --- a/cmake/libjpeg.cmake +++ /dev/null @@ -1,12 +0,0 @@ -ExternalProject_Add( - libjpeg-turbo - URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/3.1.90.tar.gz - URL_HASH SHA256=076ef1431f2803a91f07e0f92433d4dcf39bc9113226c4f46ba3d3d54f514c9d - DOWNLOAD_EXTRACT_TIMESTAMP TRUE - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -) - -ExternalProject_Get_Property(libjpeg-turbo INSTALL_DIR) -add_library(libjpeg-turbo-lib STATIC IMPORTED GLOBAL) -set_target_properties(libjpeg-turbo-lib PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/turbojpeg-static.lib) -target_include_directories(libjpeg-turbo-lib INTERFACE ${INSTALL_DIR}/include)