Skip to content

Commit

Permalink
Added source files and required libs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianoDiDio committed Mar 30, 2024
1 parent d524ac6 commit a057c78
Show file tree
Hide file tree
Showing 58 changed files with 12,055 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CMake Build Matrix
on:
push:
branches:
- '**'

jobs:
build:

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

defaults:
run:
shell: ${{ matrix.config.shell }}

strategy:
fail-fast: false

matrix:
config:
- {
name: "Windows",
os: windows-latest,
shell: "msys2 {0}",
artifact: "Release-Windows"
}
- {
name: "Ubuntu",
os: ubuntu-latest,
shell: "sh",
artifact: "Release-Linux",
}
steps:
- name: Setup Windows dependencies
if: startsWith(matrix.config.os, 'Windows')
uses: msys2/setup-msys2@v2
with:
install: >-
git
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
mingw-w64-x86_64-gcc
mingw-w64-x86_64-mesa
- name: Setup Ubuntu dependencies
if: startsWith(matrix.config.name, 'Ubuntu')
run: |
sudo apt-get update
sudo apt install libegl1-mesa-dev libglu1-mesa-dev libasound2-dev libpulse-dev ninja-build cmake build-essential -y
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Configure
run: |
mkdir Build
cmake \
-B Build \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_PVS_STUDIO_ANALYZER=OFF \
-G Ninja \
- name: Build
run: cmake --build Build --parallel
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.artifact }}
path: Build/bin/
25 changes: 25 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[submodule "libs/glew-cmake"]
path = libs/glew-cmake
url = https://github.com/Perlmint/glew-cmake.git
[submodule "libs/libpng"]
path = libs/libpng
url = https://github.com/glennrp/libpng.git
[submodule "libs/zlib"]
path = libs/zlib
url = https://github.com/madler/zlib
[submodule "libs/SDL"]
path = libs/SDL
url = https://github.com/libsdl-org/SDL
branch = release-2.26.x
[submodule "libs/libsamplerate"]
path = libs/libsamplerate
url = https://github.com/libsndfile/libsamplerate
[submodule "libs/ImGuiFileDialog"]
path = libs/ImGuiFileDialog
url = https://github.com/AdrianoDiDio/ImGuiFileDialog.git
[submodule "libs/cglm"]
path = libs/cglm
url = https://github.com/recp/cglm
[submodule "libs/cimgui"]
path = libs/cimgui
url = https://github.com/cimgui/cimgui
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.16)
include(FetchContent)

project(Jurassic-Park-PSX-File-Viewer)

OPTION(ENABLE_PVS_STUDIO_ANALYZER "Enable PVS studio analyzer." ON)

# On Windows CMAKE_RUNTIME_OUTPUT_DIRECTORY is used to tell CMAKE where
# to put DLLs.
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/SharedLibraries )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/SharedLibraries )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/ )

SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "$\{ORIGIN\}")

# Common dependencies for every project that requires it...
set(OpenGL_GL_PREFERENCE LEGACY)
find_package(OpenGL REQUIRED)

if( ENABLE_PVS_STUDIO_ANALYZER )
# Make sure that PVS studio is available for every subdirectory...
FetchContent_Declare(
PVS_CMakeModule
GIT_REPOSITORY "https://github.com/viva64/pvs-studio-cmake-module.git"
GIT_TAG "master"
)
FetchContent_MakeAvailable(PVS_CMakeModule)
include("${pvs_cmakemodule_SOURCE_DIR}/PVS-Studio.cmake")
endif()
add_subdirectory(libs)
add_subdirectory(src)
58 changes: 58 additions & 0 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)


set(OpenGL_GL_PREFERENCE LEGACY)
find_package(OpenGL REQUIRED)

add_subdirectory(cglm ${CMAKE_CURRENT_BINARY_DIR}/cglm EXCLUDE_FROM_ALL)

add_subdirectory(libsamplerate ${CMAKE_CURRENT_BINARY_DIR}/libsamplerate EXCLUDE_FROM_ALL)

set(SDL2_DISABLE_INSTALL ON CACHE BOOL "" FORCE)
set(SDL2_DISABLE_UNINSTALL ON CACHE BOOL "" FORCE)
add_subdirectory(SDL ${CMAKE_CURRENT_BINARY_DIR}/SDL EXCLUDE_FROM_ALL)

set(GLEW_CUSTOM_OUTPUT_DIRS ON CACHE BOOL "" FORCE)
set(ONLY_LIBS ON CACHE BOOL "" FORCE)
set(glew-cmake_BUILD_SHARED OFF CACHE BOOL "" FORCE)
add_definitions(-DGLEW_STATIC)
add_subdirectory(glew-cmake/build/cmake ${CMAKE_CURRENT_BINARY_DIR}/glew-cmake EXCLUDE_FROM_ALL)

add_subdirectory(zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)

set(ZLIB_ROOT zlib)

set(ZLIB_LIBRARY zlib)
set(PNG_BUILD_ZLIB OFF CACHE BOOL "" FORCE)
set(PNG_SHARED ON CACHE BOOL "" FORCE)
set(PNG_STATIC OFF CACHE BOOL "" FORCE)
set(PNG_EXECUTABLES OFF CACHE BOOL "" FORCE)
set(PNG_TESTS OFF CACHE BOOL "" FORCE)
set(SKIP_INSTALL_ALL ON CACHE BOOL "" FORCE)

add_subdirectory(libpng ${CMAKE_CURRENT_BINARY_DIR}/libpng EXCLUDE_FROM_ALL)

set(IMGUI_SOURCE_FILES cimgui/cimgui.cpp
cimgui/imgui/imgui.cpp
cimgui/imgui/imgui_draw.cpp
cimgui/imgui/imgui_demo.cpp
cimgui/imgui/imgui_widgets.cpp
cimgui/imgui/imgui_tables.cpp
cimgui/imgui/backends/imgui_impl_opengl3.cpp
cimgui/imgui/backends/imgui_impl_sdl2.cpp
ImGuiFileDialog/ImGuiFileDialog.cpp
)

add_library(cimgui STATIC ${IMGUI_SOURCE_FILES})
target_compile_definitions(cimgui PRIVATE "IMGUI_USER_CONFIG=\"${PROJECT_SOURCE_DIR}/src/Common/IMGUIConfig.h\"")

target_include_directories(cimgui PRIVATE cimgui/imgui)
target_link_libraries(cimgui SDL2)

if( WIN32 )
target_link_libraries(cimgui -static-libstdc++ -static-libgcc -static)
target_compile_definitions(cimgui PRIVATE "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else()
target_link_libraries(cimgui dl)
target_compile_definitions(cimgui PRIVATE "-DIMGUI_IMPL_API=extern \"C\" ")
endif()
1 change: 1 addition & 0 deletions libs/ImGuiFileDialog
Submodule ImGuiFileDialog added at 4a779e
1 change: 1 addition & 0 deletions libs/SDL
Submodule SDL added at ac13ca
1 change: 1 addition & 0 deletions libs/cglm
Submodule cglm added at edfb5e
1 change: 1 addition & 0 deletions libs/cimgui
Submodule cimgui added at eb0649
1 change: 1 addition & 0 deletions libs/glew-cmake
Submodule glew-cmake added at a5494d
1 change: 1 addition & 0 deletions libs/libpng
Submodule libpng added at f1848a
1 change: 1 addition & 0 deletions libs/libsamplerate
Submodule libsamplerate added at 20819b
1 change: 1 addition & 0 deletions libs/zlib
Submodule zlib added at 0f51fb
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(Common)
add_subdirectory(JPModelViewer)
39 changes: 39 additions & 0 deletions src/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.16)
project(Common)

set(COMMON_SOURCE_FILES Common.c Config.c Video.c Sound.c Engine.c
ShaderManager.c VAO.c IMGUIUtils.c
TIM.c VRAM.c
)

add_library(${PROJECT_NAME} STATIC ${COMMON_SOURCE_FILES})

if( ENABLE_PVS_STUDIO_ANALYZER )
pvs_studio_add_target(TARGET ${PROJECT_NAME}.Analyze
ANALYZE ${PROJECT_NAME}
SUPPRESS_BASE suppress_base.json
LOG FORMAT fullhtml
LOG ${PROJECT_NAME}-Report
ARGS -e *libs*
MODE GA:1,2
)
endif()

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/cimgui/)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/cimgui/generator)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/cimgui/generator/output)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/ImGuiFileDialog)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/glew-cmake/include)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/SDL)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/libsamplerate)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/zlib)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/libpng)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/../../libs/libpng)
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLEW CIMGUI_USE_OPENGL3 CIMGUI_USE_SDL2)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
$<$<CONFIG:Debug>:_DEBUG>
)
target_link_libraries(${PROJECT_NAME} SDL2 glew_s png m cimgui cglm_headers samplerate)


Loading

0 comments on commit a057c78

Please sign in to comment.