diff --git a/.github/actions/setup-ninja/action.yml b/.github/actions/setup-ninja/action.yml index 690c248c..3ac4a221 100644 --- a/.github/actions/setup-ninja/action.yml +++ b/.github/actions/setup-ninja/action.yml @@ -36,7 +36,7 @@ runs: echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT} - name: 'Restore cached ${{ steps.calc.outputs.archive }}' id: cache-restore - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' key: ${{ steps.calc.outputs.cache-key }} @@ -47,7 +47,7 @@ runs: Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}" - name: 'Cache ${{ steps.calc.outputs.archive }}' if: ${{ (!steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false') }} - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' key: ${{ steps.calc.outputs.cache-key }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 71216b87..c4d9732b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,8 @@ include("${PROJECT_SOURCE_DIR}/cmake/sdlmanpages.cmake") # Increment this if/when we break backwards compatibility. set(PHYSFS_SOVERSION 1) +set(PC_PRIVATE_REQUIRES "") + set(PHYSFS_M_SRCS) set(PHYSFS_CPP_SRCS) @@ -196,8 +198,8 @@ endif() option(PHYSFS_PLATFORM_SDL3 "Enable building for the SDL3 file system" FALSE) if(PHYSFS_PLATFORM_SDL3) - find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3) - add_definitions(-DPHYSFS_PLATFORM_SDL3=1) + find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS Headers SDL3) + list(APPEND PC_PRIVATE_REQUIRES "sdl3") endif() if(EMSCRIPTEN) @@ -230,6 +232,7 @@ if(PHYSFS_BUILD_STATIC) target_compile_definitions(physfs-static PRIVATE "PHYSFS_STATIC") endif() if(PHYSFS_PLATFORM_SDL3) + target_compile_definitions(physfs-static PRIVATE PHYSFS_PLATFORM_SDL3=1) target_link_libraries(physfs-static PUBLIC SDL3::Headers) endif() target_include_directories(physfs-static PUBLIC "$") @@ -260,7 +263,9 @@ if(PHYSFS_BUILD_SHARED) set_property(TARGET physfs-shared PROPERTY VS_WINRT_COMPONENT TRUE) endif() if(PHYSFS_PLATFORM_SDL3) - target_link_libraries(physfs-shared PUBLIC SDL3::SDL3-shared) + target_compile_definitions(physfs-shared PRIVATE PHYSFS_PLATFORM_SDL3=1) + target_link_libraries(physfs-shared PUBLIC SDL3::Headers) + target_link_libraries(physfs-shared PRIVATE SDL3::SDL3-shared) endif() target_include_directories(physfs-shared PUBLIC "$") target_link_libraries(physfs-shared PRIVATE ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) @@ -283,9 +288,6 @@ if(PHYSFS_BUILD_TEST) add_executable(test_physfs test/test_physfs.c) target_link_libraries(test_physfs PRIVATE PhysFS::PhysFS) sdl_add_warning_options(test_physfs WARNING_AS_ERROR ${PHYSFS_WERROR}) - if(PHYSFS_PLATFORM_SDL3) - target_link_libraries(test_physfs PRIVATE SDL3::SDL3) - endif() if(DOS) set_target_properties(test_physfs PROPERTIES OUTPUT_NAME "TESTPHYS") # 8.3 file names! endif() @@ -305,9 +307,6 @@ if(PHYSFS_BUILD_TEST) if(UNIX) add_executable(physfshttpd extras/physfshttpd.c) target_link_libraries(physfshttpd PRIVATE PhysFS::PhysFS) - if(PHYSFS_PLATFORM_SDL3) - target_link_libraries(physfshttpd PRIVATE SDL3::SDL3) - endif() sdl_add_warning_options(physfshttpd WARNING_AS_ERROR ${PHYSFS_WERROR}) endif() endif() @@ -375,6 +374,7 @@ if(PHYSFS_INSTALL) install(FILES LICENSE.txt DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/PhysicsFS${PROJECT_VERSION_MAJOR}") + string(REPLACE ";" " " PC_PRIVATE_REQUIRES "${PC_PRIVATE_REQUIRES}") configure_file(cmake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall-physfs COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") @@ -450,6 +450,7 @@ message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF) message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660) message_bool_option("GOB/LAB/LFD support" PHYSFS_ARCHIVE_LECARCHIVES) message_bool_option("POD support" PHYSFS_ARCHIVE_POD) +message_bool_option("SDL3 filesystem support" PHYSFS_PLATFORM_SDL3) message_bool_option("Build static library" PHYSFS_BUILD_STATIC) message_bool_option("Build shared library" PHYSFS_BUILD_SHARED) message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST) diff --git a/cmake/PhysFSConfig.cmake.in b/cmake/PhysFSConfig.cmake.in index fec6cd6c..5dfa3d67 100644 --- a/cmake/PhysFSConfig.cmake.in +++ b/cmake/PhysFSConfig.cmake.in @@ -6,6 +6,8 @@ set_package_properties(PhysicsFS PROPERTIES @PACKAGE_INIT@ +set(PHYSFS_PLATFORM_SDL3 @PHYSFS_PLATFORM_SDL3@) + set(PhysFS_PhysFS_FOUND) set(PhysFS_PhysFS-shared_FOUND) @@ -17,6 +19,12 @@ endif() set(PhysFS_PhysFS-static_FOUND) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/PhysFS-static-targets.cmake") + + if(PHYSFS_PLATFORM_SDL3) + include(CMakeFindDependencyMacro) + find_dependency(SDL3) + endif() + include("${CMAKE_CURRENT_LIST_DIR}/PhysFS-static-targets.cmake") set(PhysFS_PhysFS-static_FOUND TRUE) set(PhysFS_PhysFS_FOUND TRUE) diff --git a/cmake/physfs.pc.in b/cmake/physfs.pc.in index f7e03070..5813d950 100644 --- a/cmake/physfs.pc.in +++ b/cmake/physfs.pc.in @@ -7,5 +7,6 @@ Name: PhysicsFS Description: PhysicsFS is a library to provide abstract access to various archives. URL: https://icculus.org/physfs/ Version: @PHYSFS_VERSION@ +Requires.private: @PC_PRIVATE_REQUIRES@ Libs: -L${libdir} -lphysfs Cflags: -I${includedir} diff --git a/test/test_physfs.c b/test/test_physfs.c index 8cff0121..f449acfd 100644 --- a/test/test_physfs.c +++ b/test/test_physfs.c @@ -402,10 +402,9 @@ static void cmd_tree_recursive(const char *prefix, const char *fullPath, const c } else { - int file_count; char **i; printf("\n"); - for (i = rc, file_count = 0; *i != NULL; i++, file_count++) { + for (i = rc; *i != NULL; i++) { char *newFullPath = malloc(strlen(fullPath) + strlen(*i) + 2); char *thisPrefix; strcpy(newFullPath, fullPath);