Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove submodules, add full physfs #10

Merged
merged 3 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
.vscode
.DS_Store
8 changes: 0 additions & 8 deletions .gitmodules

This file was deleted.

89 changes: 76 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,37 @@ project (raylib-physfs
LANGUAGES C
)

# Include Directory
add_subdirectory(include)
include(FetchContent)

# Adding Raylib for graphics
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games
FetchContent_Declare(raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git GIT_TAG master)
FetchContent_MakeAvailable(raylib)

# Adding PhysFS for filesystem abstraction
# You can change these to support other formats
set(PHYSFS_ARCHIVE_ZIP ON CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_7Z OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_GRP OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_WAD OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_HOG OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_MVL OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_QPAK OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_SLB OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE)
set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE)

# library options
set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE)
set(PHYSFS_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(PHYSFS_BUILD_TEST OFF CACHE BOOL "" FORCE)
set(PHYSFS_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(PHYSFS_DISABLE_INSTALL OFF CACHE BOOL "" FORCE)

FetchContent_Declare(physfs GIT_REPOSITORY https://github.com/icculus/physfs.git GIT_TAG main)
FetchContent_MakeAvailable(physfs)
include_directories(${physfs_SOURCE_DIR}/src)

# Options
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Expand All @@ -17,16 +46,50 @@ else()
endif()
option(RAYLIB_PHYSFS_BUILD_EXAMPLES "Examples" ${RAYLIB_PHYSFS_IS_MAIN})

# Examples
add_library(raylib_physfs INTERFACE)

# Include Directory
target_include_directories(raylib_physfs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)

# Set the header files as install files.
install(FILES raylib-physfs.h
DESTINATION include
)

# examples
if (RAYLIB_PHYSFS_BUILD_EXAMPLES)
add_subdirectory(examples)

# Testing
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
enable_testing()
if (BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/audio/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/shaders/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/text/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/textures/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources/)

add_executable(audio_music_stream)
target_sources(audio_music_stream PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/audio/audio_music_stream.c")
target_include_directories(audio_music_stream PRIVATE ".")
target_link_libraries(audio_music_stream PRIVATE raylib physfs-static)

add_executable(audio_sound_loading)
target_sources(audio_sound_loading PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/audio/audio_sound_loading.c")
target_include_directories(audio_sound_loading PRIVATE ".")
target_link_libraries(audio_sound_loading PRIVATE raylib physfs-static)

add_executable(shaders_texture_waves)
target_sources(shaders_texture_waves PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/shaders/shaders_texture_waves.c")
target_include_directories(shaders_texture_waves PRIVATE ".")
target_link_libraries(shaders_texture_waves PRIVATE raylib physfs-static)

add_executable(text_basic_loading)
target_sources(text_basic_loading PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/text/text_basic_loading.c")
target_include_directories(text_basic_loading PRIVATE ".")
target_link_libraries(text_basic_loading PRIVATE raylib physfs-static)

add_executable(text_font_loading)
target_sources(text_font_loading PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/text/text_font_loading.c")
target_include_directories(text_font_loading PRIVATE ".")
target_link_libraries(text_font_loading PRIVATE raylib physfs-static)

add_executable(textures_image_loading)
target_sources(textures_image_loading PRIVATE "${CMAKE_CURRENT_LIST_DIR}/examples/textures/textures_image_loading.c")
target_include_directories(textures_image_loading PRIVATE ".")
target_link_libraries(textures_image_loading PRIVATE raylib physfs-static)
endif()
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Tests](https://github.com/RobLoach/raylib-physfs/actions/workflows/Tests.yml/badge.svg)](https://github.com/RobLoach/raylib-physfs/actions/workflows/Tests.yml)

Load [raylib](https://www.raylib.com/) images, sounds, music, fonts and shaders from data archives, like `.zip` files, through [PhysicsFS](https://icculus.org/physfs/). This comes bundled with [miniphysfs](https://github.com/edubart/miniphysfs), so that there's no need to link PhysFS.
Load [raylib](https://www.raylib.com/) images, sounds, music, fonts and shaders from data archives, like `.zip` files, through [PhysicsFS](https://icculus.org/physfs/).

## Features

Expand All @@ -15,13 +15,12 @@ Load [raylib](https://www.raylib.com/) images, sounds, music, fonts and shaders

## Usage

This is a header-only library. To use it, define `RAYLIB_PHYSFS_IMPLEMENTATION` in one `.c` source file before including [`raylib-physfs.h`](include/raylib-physfs.h). You will also have to link the raylib dependencies.
This is a header-only library. To use it, define `RAYLIB_PHYSFS_IMPLEMENTATION` in one `.c` source file before including [`raylib-physfs.h`](include/raylib-physfs.h). You will also have to link the raylib & physfs dependencies.

### Example

``` c
#define RAYLIB_PHYSFS_IMPLEMENTATION
#define PHYSFS_SUPPORTS_ONLY_ZIP
#include "raylib-physfs.h"

int main() {
Expand Down Expand Up @@ -70,11 +69,8 @@ const char* GetPerfDirectory(const char *org, const char *app); // Get the user'

### Defines

Add these defines to help shape the behaviour of raylib-physfs...
Have a look at [Cmake config](CMakeLists.txt) to see how to define different things that change the behavior of physfs, raylib, and raylib-physfs.

- `RAYLIB_PHYSFS_IMPLEMENTATION` Define this in one of your `.c`/`.cpp` files prior to including *raylib-physfs.h*
- `RAYLIB_PHYSFS_STATIC` Use [`static`](https://en.wikipedia.org/wiki/Static_(keyword)) function definitions
- `PHYSFS_SUPPORTS_ONLY_ZIP` Only support .zip archives, rather than all the available ones.

## Development

Expand Down
65 changes: 0 additions & 65 deletions examples/CMakeLists.txt

This file was deleted.

9 changes: 0 additions & 9 deletions include/CMakeLists.txt

This file was deleted.

Loading