Skip to content
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
55 changes: 15 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,42 @@ on:
branches: [main]
workflow_dispatch:
# nothing here

jobs:
build-linux:
build:
strategy:
fail-fast: false
matrix:
build_type: [Debug, Release]
compiler: [gcc]
runs-on: ubuntu-latest
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{matrix.os}}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Necessary Packages
run: sudo apt update && sudo apt install -y cmake build-essential

- name: Install GCC
if: ${{matrix.compiler == 'gcc'}}
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: x64

- name: Configure CMake
run: cmake -G "Unix Makefiles" -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DSOURCEPP_BUILD_TESTS=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest


build-msvc:
strategy:
matrix:
build_type: [Debug, Release]
runs-on: windows-latest
defaults:
run:
shell: cmd
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up MSVC
- name: Set up MSVC [Windows]
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
spectre: true

- name: Install Dependencies [macOS]
if: matrix.os == 'macos-latest'
run: brew install ninja

- name: Install Dependencies [Linux]
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install -y ninja-build

- name: Configure CMake
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DSOURCEPP_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{matrix.build_type}}

- name: Test
working-directory: ${{github.workspace}}/build
working-directory: '${{github.workspace}}/build'
run: ctest
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@
cmake-build-*/

# Generated
lang/csharp/vpkpp/vpkpp.csproj
test/Helpers.h

# CSharp
lang/csharp/**/bin
lang/csharp/**/obj
lang/csharp/**/TestResults
lang/csharp/**/*.DotSettings.user
10 changes: 8 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[submodule "src/thirdparty/bufferstream"]
path = src/thirdparty/bufferstream
url = https://github.com/craftablescience/BufferStream
[submodule "src/thirdparty/cryptopp"]
path = src/thirdparty/cryptopp
url = https://github.com/abdes/cryptopp-cmake
[submodule "src/thirdparty/miniz"]
path = src/thirdparty/miniz
url = https://github.com/richgel999/miniz
path = src/thirdparty/miniz
url = https://github.com/richgel999/miniz
[submodule "src/thirdparty/minizip-ng"]
path = src/thirdparty/minizip-ng
url = https://github.com/zlib-ng/minizip-ng
185 changes: 83 additions & 102 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
project(sourcepp)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# Options (General)
option(SOURCEPP_USE_DMXPP "Build dmxpp library" ON)
option(SOURCEPP_USE_FGDPP "Build fgdpp library" ON)
option(SOURCEPP_USE_KVPP "Build kvpp library" ON)
option(SOURCEPP_USE_MDLPP "Build mdlpp library" ON)
option(SOURCEPP_USE_VICEPP "Build vicepp library" ON)
option(SOURCEPP_USE_VTFPP "Build vtfpp library" ON)
option(SOURCEPP_BUILD_TESTS "Build tests for enabled libraries" OFF)
option(SOURCEPP_USE_STATIC_MSVC_RUNTIME "Link to static MSVC runtime library" OFF)
option(SOURCEPP_USE_DMXPP "Build dmxpp library" ON)
option(SOURCEPP_USE_FGDPP "Build fgdpp library" ON)
option(SOURCEPP_USE_KVPP "Build kvpp library" ON)
option(SOURCEPP_USE_MDLPP "Build mdlpp library" ON)
option(SOURCEPP_USE_VICEPP "Build vicepp library" ON)
option(SOURCEPP_USE_VPKPP "Build vpkpp library" ON)
if(NOT APPLE)
option(SOURCEPP_USE_VTFPP "Build vtfpp library" ON)
else()
set(SOURCEPP_USE_VTFPP OFF CACHE INTERNAL "")
endif()
option(SOURCEPP_BUILD_C_WRAPPERS "Build C wrappers for supported libraries" ON)
option(SOURCEPP_BUILD_TESTS "Build tests for enabled libraries" OFF)
option(SOURCEPP_USE_STATIC_MSVC_RUNTIME "Link to static MSVC runtime library" OFF)


# Options (Library)
Expand All @@ -35,6 +41,14 @@ if(NOT TARGET bufferstream)
endif()


# cryptopp
if (NOT TARGET cryptopp::cryptopp)
set(CRYPTOPP_BUILD_TESTING OFF CACHE INTERNAL "")
set(CRYPTOPP_INSTALL OFF CACHE INTERNAL "")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/cryptopp")
endif()


# ice
if(SOURCEPP_USE_VICEPP)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/ice")
Expand All @@ -47,28 +61,71 @@ if(SOURCEPP_USE_VTFPP AND NOT TARGET miniz)
endif()


# minizip-ng
if (SOURCEPP_USE_VPKPP AND NOT TARGET MINIZIP::minizip)
set(MZ_COMPAT OFF CACHE INTERNAL "")
set(MZ_ZLIB OFF CACHE INTERNAL "")
set(MZ_BZIP2 OFF CACHE INTERNAL "")
set(MZ_LZMA OFF CACHE INTERNAL "")
set(MZ_ZSTD OFF CACHE INTERNAL "")
set(MZ_LIBCOMP OFF CACHE INTERNAL "")
set(MZ_PKCRYPT OFF CACHE INTERNAL "")
set(MZ_WZAES OFF CACHE INTERNAL "")
set(MZ_OPENSSL OFF CACHE INTERNAL "")
set(MZ_FETCH_LIBS ON CACHE INTERNAL "")
set(MZ_FORCE_FETCH_LIBS ON CACHE INTERNAL "")
set(SKIP_INSTALL_ALL ON CACHE INTERNAL "")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src/thirdparty/minizip-ng")
endif()


# stb
if(SOURCEPP_USE_VTFPP)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/stb")
endif()


# Shared code
list(APPEND ${PROJECT_NAME}_SOURCES
add_library(${PROJECT_NAME} STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/buffer/Buffer.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/crypto/Adler32.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/crypto/CRC32.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/crypto/MD5.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/crypto/RSA.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/crypto/String.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/fs/FS.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/math/Angles.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/math/Float.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/math/Integer.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/math/Matrix.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/math/Vector.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/sourcepp/string/String.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/buffer/Buffer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/crypto/Adler32.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/crypto/CRC32.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/crypto/MD5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/crypto/RSA.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/crypto/String.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/fs/FS.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sourcepp/string/String.cpp")
add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SOURCES})
target_link_libraries(${PROJECT_NAME} PUBLIC bufferstream)
target_link_libraries(${PROJECT_NAME} PUBLIC bufferstream cryptopp::cryptopp)
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")


# Shared C code
if(SOURCEPP_BUILD_C_WRAPPERS)
list(APPEND ${PROJECT_NAME}c_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/sourceppc/API.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/sourceppc/Buffer.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/sourceppc/Convert.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/sourceppc/Helpers.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/sourceppc/String.h"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/src/sourceppc/Buffer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/src/sourceppc/Convert.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/src/sourceppc/String.cpp")
endif()


# Tests, part 1
if(SOURCEPP_BUILD_TESTS)
set(SOURCEPP_TEST_NAME "${PROJECT_NAME}_test")
Expand All @@ -81,110 +138,34 @@ if(SOURCEPP_BUILD_TESTS)
FetchContent_MakeAvailable(googletest)
enable_testing()

set(${PROJECT_NAME}_ASSET_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/test/res/")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test/Helpers.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/test/Helpers.h")

list(APPEND ${SOURCEPP_TEST_NAME}_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/test/Helpers.h"
"${CMAKE_CURRENT_SOURCE_DIR}/test/Helpers.cpp")
set(${SOURCEPP_TEST_NAME}_SOURCES "")
list(APPEND ${SOURCEPP_TEST_NAME}_DEPS gtest_main)
endif()


# Add scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_scripts")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddPrettyParser)
include(AddSourcePPLibrary)
include(TargetLinkCompressonator)


# dmxpp
if(SOURCEPP_USE_DMXPP)
add_pretty_parser(dmxpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/dmxpp/structs/Value.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/dmxpp/dmxpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dmxpp/structs/Value.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dmxpp/dmxpp.cpp")
endif()


# fgdpp
if(SOURCEPP_USE_FGDPP)
add_pretty_parser(fgdpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/fgdpp/structs/EntityProperties.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/fgdpp/fgdpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/fgdpp/fgdpp.cpp")
if(FGDPP_ENABLE_SPEN_FGD_SUPPORT)
target_compile_definitions(fgdpp PUBLIC FGDPP_UNIFIED_FGD)
endif()
endif()


# kvpp
if(SOURCEPP_USE_KVPP)
add_pretty_parser(kvpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/kvpp/kvpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/kvpp/kvpp.cpp")
endif()


# mdlpp
if(SOURCEPP_USE_MDLPP)
add_pretty_parser(mdlpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/mdlpp/structs/Generic.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/mdlpp/structs/MDL.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/mdlpp/structs/VTX.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/mdlpp/structs/VVD.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/mdlpp/mdlpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/mdlpp/structs/MDL.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/mdlpp/structs/VTX.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/mdlpp/structs/VVD.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/mdlpp/mdlpp.cpp")
endif()


# vicepp
if(SOURCEPP_USE_VICEPP)
add_pretty_parser(vicepp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/vicepp/vicepp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/vicepp/vicepp.cpp")
target_link_libraries(vicepp PRIVATE sourcepp_ice)
endif()


# vtfpp
if(SOURCEPP_USE_VTFPP)
add_pretty_parser(vtfpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/ImageConversion.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/ImageFormats.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/vtfpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/vtfpp/ImageConversion.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/vtfpp/vtfpp.cpp")
target_link_libraries(vtfpp PRIVATE miniz sourcepp_stb)

# Compressonator
if(MSVC)
if(SOURCEPP_USE_STATIC_MSVC_RUNTIME)
target_link_libraries(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/win64/Compressonator_MT$<$<CONFIG:Debug>:d>.lib")
else()
target_link_libraries(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/win64/Compressonator_MD$<$<CONFIG:Debug>:d>.lib")
endif()
elseif(UNIX)
target_link_libraries(vtfpp PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Compressonator.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_AVX.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_AVX512.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_SSE.a")
else()
message(FATAL_ERROR "Unable to link to Compressonator library!")
endif()
target_include_directories(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/include")
endif()
# Add libraries
add_sourcepp_library(dmxpp)
add_sourcepp_library(fgdpp)
add_sourcepp_library(kvpp)
add_sourcepp_library(mdlpp)
add_sourcepp_library(vicepp)
add_sourcepp_library(vpkpp C CSHARP)
add_sourcepp_library(vtfpp)


# Tests, part 2
if(SOURCEPP_BUILD_TESTS)
add_executable(${SOURCEPP_TEST_NAME} ${${SOURCEPP_TEST_NAME}_SOURCES})
target_link_libraries(${SOURCEPP_TEST_NAME} PUBLIC ${${SOURCEPP_TEST_NAME}_DEPS})
target_compile_definitions(${SOURCEPP_TEST_NAME} PUBLIC ASSET_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/test/res/")

include(GoogleTest)
gtest_discover_tests(${SOURCEPP_TEST_NAME})
endif()
Loading