Merge remote-tracking branch 'origin/test/universal' into cmake-presets

# Conflicts:
#	.github/workflows/build.yml
#	CMakeLists.txt
#	Editor/badging/CMakeLists.txt
#	Editor/locale/CMakeLists.txt
#	Runtime/locale/locales-inl.hpp
#	hecl/CMakeLists.txt
#	specter/lib/TextView.cpp
This commit is contained in:
Luke Street 2021-06-11 19:52:19 -04:00
commit f8363b90a7
11 changed files with 411 additions and 238 deletions

View File

@ -2,8 +2,6 @@ name: Build
on:
push:
branches-ignore:
- main
paths-ignore:
- '*.json'
- '*.md'
@ -31,11 +29,17 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install build-essential curl git cmake ninja-build clang lld python3 python-is-python3 \
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get -y install curl git cmake ninja-build llvm-dev libclang-dev clang lld libcurl4-openssl-dev \
zlib1g-dev libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev \
libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev libcurl4-openssl-dev qt5-default \
llvm-11-dev libclang-11-dev clang-11
libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev python3 python-is-python3 qt5-default \
intel-oneapi-ipp-devel ccache
yarn global add @sentry/cli
echo "$(yarn global bin)" >> $GITHUB_PATH
# free up disk space
# https://github.com/actions/virtual-environments/issues/2840#issuecomment-790492173
@ -49,16 +53,39 @@ jobs:
echo After
df -h .
- name: Configure ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ubuntu-20.04-${{matrix.cc}}
max-size: 1G
# - name: Configure CMake
# run: |
# cmake -B build . -GNinja -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
# -DCMAKE_INSTALL_PREFIX:PATH="$GITHUB_WORKSPACE/install" \
# -DCMAKE_C_COMPILER:STRING=${{matrix.cc}} \
# -DCMAKE_CXX_COMPILER:STRING=${{matrix.cxx}} \
# -DCMAKE_C_COMPILER_LAUNCHER:STRING=ccache \
# -DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache
- name: Configure CMake
run: cmake --preset linux-ci-${{matrix.preset}}
- name: Build
run: cmake --build --preset linux-ci-${{matrix.preset}}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: metaforce-${{env.METAFORCE_VERSION}}-linux-${{matrix.cc}}-x86_64
path: build/install
build-macos:
name: Build macOS (AppleClang x86_64)
if: 'false'
name: Build macOS (AppleClang universal)
runs-on: macos-10.15
env:
Qt_VERSION: 5.15.2
IPP_VERSION: 2021.2.0.192
steps:
- uses: actions/checkout@v2
with:
@ -69,26 +96,60 @@ jobs:
run: |
brew update
brew upgrade --formula
brew install ninja qt@5 graphicsmagick imagemagick
brew link qt@5
brew install ninja graphicsmagick imagemagick ccache
yarn global add create-dmg
# universal qt5 from macports
curl -LSfs https://axiodl.com/files/qt-$Qt_VERSION.mpkg -o /tmp/qt-$Qt_VERSION.mpkg
sudo installer -pkg /tmp/qt-$Qt_VERSION.mpkg -target /
- name: Create build directory
run: cmake -E make_directory ${{github.workspace}}/build
- name: Install Intel IPP
if: 'false' # not supported for universal build
run: |
NAME="m_ipp_oneapi_p_${IPP_VERSION}_offline"
curl -LSfs https://registrationcenter-download.intel.com/akdlm/irc_nas/17606/$NAME.dmg -o /tmp/$NAME.dmg
sudo hdiutil attach /tmp/$NAME.dmg -quiet
sudo /Volumes/$NAME/bootstrapper.app/Contents/MacOS/install.sh -c --action install --eula accept
sudo hdiutil detach /Volumes/$NAME -quiet
rm /tmp/$NAME.dmg
- name: Configure ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: macos-10.15-appleclang
max-size: 1G
- name: Configure CMake
working-directory: ${{github.workspace}}/build
run: |
export PATH="/usr/local/opt/qt@5/bin:$PATH" # FIXME remove
cmake $GITHUB_WORKSPACE -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
-DCMAKE_C_COMPILER_LAUNCHER:STRING=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
-DCMAKE_INSTALL_PREFIX:PATH="$GITHUB_WORKSPACE/install" \
-DQt5Widgets_DIR:PATH=/opt/local/libexec/qt5/lib/cmake/Qt5Widgets \
-DCMAKE_OSX_ARCHITECTURES:STRING="arm64;x86_64" \
-DPNG_DIR:PATH=/opt/local/lib
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --target metaforce-gui
run: cmake --build build --config $BUILD_TYPE --target install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: metaforce-${{env.METAFORCE_VERSION}}-macos-appleclang-universal
path: build/install
build-windows:
name: Build Windows (${{matrix.name}} x86_64)
runs-on: windows-2019
env:
Qt_VERSION: 5.15.2
IPP_VERSION: 2021.2.0.210
BUILDCACHE_VERSION: v0.26.1
# C: has ~90GB available space at the moment
BUILDCACHE_DIR: C:\buildcache
BUILD_DIR: C:\build
INSTALL_DIR: C:\install
strategy:
fail-fast: false
matrix:
@ -98,24 +159,12 @@ jobs:
- name: Clang
preset: clang
env:
LLVM_VERSION: 10.0.1
Qt_VERSION: 5.15.2
IPP_VERSION: 2021.2.0.210
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Install LLVM
run: |
$TempDir = "$env:RUNNER_WORKSPACE\temp"
$Filename = "LLVM-$env:LLVM_VERSION-win64.exe"
New-Item -Path "$TempDir" -ItemType Directory -ea 0
(New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename")
Start-Process "$TempDir\$Filename" -ArgumentList "/S /D=$env:RUNNER_WORKSPACE\LLVM" -Wait
- name: Install vcpkg Qt
run: |
$TempDir = "$env:RUNNER_WORKSPACE\temp"
@ -124,14 +173,67 @@ jobs:
(New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename")
7z x "-o$env:RUNNER_WORKSPACE" -aos "$TempDir\$Filename"
- name: Install Intel IPP
run: |
$TempDir = "$env:RUNNER_WORKSPACE\temp"
$Filename = "w_ipp_oneapi_p_${env:IPP_VERSION}_offline.exe"
New-Item -Path "$TempDir" -ItemType Directory -ea 0
(New-Object Net.WebClient).DownloadFile("https://registrationcenter-download.intel.com/akdlm/irc_nas/17739/$Filename", "$TempDir\$Filename")
Start-Process "$TempDir\$Filename" -ArgumentList "--x --s --f $TempDir\ipp" -Wait
Start-Process "$TempDir\ipp\bootstrapper.exe" -ArgumentList "--eula accept -c --action install" -Wait
- name: Install dependencies
run: choco install ninja vulkan-sdk
run: |
choco install ninja vulkan-sdk
# set up buildcache
$TempDir = "$env:RUNNER_WORKSPACE\temp"
New-Item -Path "$TempDir" -ItemType Directory -ea 0
(New-Object Net.WebClient).DownloadFile("https://github.com/mbitsnbites/buildcache/releases/download/$env:BUILDCACHE_VERSION/buildcache-windows.zip", "$TempDir\buildcache.zip")
Expand-Archive -LiteralPath "$TempDir\buildcache.zip" -DestinationPath "$TempDir"
echo "$TempDir\buildcache\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "BUILDCACHE_ACCURACY=STRICT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "BUILDCACHE_MAX_CACHE_SIZE=1073741824" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# check available disk space
Get-PSDrive
- name: Restore buildcache
uses: actions/cache@v2
with:
path: ${{env.BUILDCACHE_DIR}}
key: buildcache-windows-2019-${{matrix.oname}}
- name: Enable Visual Studio environment
uses: ilammy/msvc-dev-cmd@v1
# - name: Configure CMake
# run: |
# buildcache -z
# cmake -B "$env:BUILD_DIR" . -GNinja -DCMAKE_BUILD_TYPE:STRING=$env:BUILD_TYPE `
# -DCMAKE_INSTALL_PREFIX:PATH="$env:INSTALL_DIR" `
# -DCMAKE_TOOLCHAIN_FILE:PATH="$env:RUNNER_WORKSPACE\vcpkg-qt-$env:Qt_VERSION\scripts\buildsystems\vcpkg.cmake" `
# -DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static `
# -DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded `
# -DCMAKE_C_COMPILER:STRING=${{matrix.cc}} `
# -DCMAKE_CXX_COMPILER:STRING=${{matrix.cc}} `
# -DCMAKE_LINKER:STRING=${{matrix.ld}} `
# -DCMAKE_C_COMPILER_LAUNCHER:STRING=buildcache `
# -DCMAKE_CXX_COMPILER_LAUNCHER:STRING=buildcache `
# -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="/MD /Z7 /O2 /Ob1 /DNDEBUG" `
# -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="/MD /Z7 /O2 /Ob1 /DNDEBUG"
- name: Configure CMake
run: cmake --preset windows-ci-${{matrix.preset}}
- name: Build
run: cmake --build --preset windows-ci-${{matrix.preset}}
- name: Print buildcache stats
run: buildcache -s
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: metaforce-${{env.METAFORCE_VERSION}}-win32-${{matrix.oname}}-x86_64
path: ${{env.INSTALL_DIR}}

View File

@ -65,10 +65,16 @@ endif()
message(STATUS "Metaforce version set to ${METAFORCE_WC_DESCRIBE}")
project(metaforce LANGUAGES C CXX ASM VERSION ${METAFORCE_VERSION_STRING})
if (APPLE)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ATHENA_ARCH)
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" ATHENA_HOST_ARCH)
set(ATHENA_EXTENSION "tar.gz")
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(PLATFORM_NAME macos)
elseif (WIN32)
set(ATHENA_ARCH universal)
set(ATHENA_HOST_ARCH universal)
elseif (CMAKE_SYSTEM_NAME STREQUAL Windows)
set(PLATFORM_NAME win32)
set(ATHENA_EXTENSION ".7z")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(PLATFORM_NAME linux)
endif ()
@ -361,7 +367,39 @@ if (NOT WIN32)
set(ZLIB_LIBRARIES ZLIB::ZLIB CACHE STRING "zlib libraries" FORCE)
endif()
add_subdirectory(extern/nod)
option(BUILD_ATHENA "Build Athena libraries from source" ON)
option(BUILD_ATDNA "Build atdna utility from source (requires LLVM)" OFF)
if (NOT BUILD_ATDNA)
set(ATHENA_BASE_URL "https://github.com/libAthena/athena/releases/download/latest")
if (WIN32)
set(ATHENA_EXT 7z)
else()
set(ATHENA_EXT tar.gz)
endif()
include(FetchContent)
FetchContent_Declare(athena-host
URL "${ATHENA_BASE_URL}/athena-${PLATFORM_NAME}-${ATHENA_HOST_ARCH}.${ATHENA_EXT}")
message(STATUS "Fetching atdna host binary")
FetchContent_Populate(athena-host)
include(${athena-host_SOURCE_DIR}/lib/cmake/atdna/atdnaConfig.cmake)
endif ()
if (BUILD_ATHENA OR BUILD_ATDNA)
add_subdirectory(extern/athena EXCLUDE_FROM_ALL)
else()
if (ATHENA_ARCH STREQUAL ATHENA_HOST_ARCH)
set(athena_SOURCE_DIR "${athena-host_SOURCE_DIR}")
else()
FetchContent_Declare(athena
URL "${ATHENA_BASE_URL}/athena-${PLATFORM_NAME}-${ATHENA_ARCH}.tar.gz")
FetchContent_Populate(athena)
endif()
include(${athena_SOURCE_DIR}/lib/cmake/athena/AthenaConfig.cmake)
include(${athena_SOURCE_DIR}/lib/cmake/lzokay/lzokayConfig.cmake)
add_library(lzokay ALIAS lzokay::lzokay)
include(extern/athena/atdna/atdnaHelpers.cmake)
endif()
set(DATA_SPEC_LIBS RetroDataSpec AssetNameMap)
set(HECL_DATASPEC_DECLS
@ -391,18 +429,47 @@ set(HECL_DATASPEC_PUSHES
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC);
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);")
add_subdirectory(extern/athena)
add_subdirectory(extern/boo)
add_subdirectory(hecl/shaderc)
add_subdirectory(extern/nod EXCLUDE_FROM_ALL)
add_subdirectory(extern/boo EXCLUDE_FROM_ALL)
include(ExternalProject)
ExternalProject_Add(shaderc
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/hecl/shaderc"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install)
function(shaderc out)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
else()
set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out})
endif()
unset(theInsList)
foreach(in ${ARGN})
if(IS_ABSOLUTE ${in})
list(APPEND theInsList ${in})
else()
list(APPEND theInsList ${CMAKE_CURRENT_SOURCE_DIR}/${in})
endif()
endforeach()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
file(RELATIVE_PATH outRel ${CMAKE_BINARY_DIR} ${theOut})
ExternalProject_Get_Property(shaderc INSTALL_DIR)
add_custom_command(OUTPUT ${theOut}.cpp ${theOut}.hpp
COMMAND "${INSTALL_DIR}/bin/shaderc" ARGS -o ${theOut} ${theInsList}
DEPENDS ${theInsList} shaderc
COMMENT "Compiling shader ${outRel}.shader")
endfunction()
include(hecl/ApplicationTools.cmake)
add_subdirectory(Shaders)
add_subdirectory(hecl/bintoc)
add_subdirectory(imgui)
add_subdirectory(extern/libSquish)
add_subdirectory(extern/libpng)
add_subdirectory(extern/libjpeg-turbo)
add_subdirectory(hecl)
add_subdirectory(extern/zeus)
add_subdirectory(extern/libSquish EXCLUDE_FROM_ALL)
add_subdirectory(extern/libpng EXCLUDE_FROM_ALL)
add_subdirectory(extern/libjpeg-turbo EXCLUDE_FROM_ALL)
add_subdirectory(hecl EXCLUDE_FROM_ALL)
add_subdirectory(extern/zeus EXCLUDE_FROM_ALL)
target_include_directories(hecl-full PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(hecl-light PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(hecl-full PRIVATE zeus nod)
@ -432,19 +499,21 @@ if(NOT TARGET atdna)
endif()
endif()
add_subdirectory(extern/amuse)
add_subdirectory(assetnameparser)
add_subdirectory(extern/amuse EXCLUDE_FROM_ALL)
if (NOT CMAKE_CROSSCOMPILING)
add_subdirectory(assetnameparser EXCLUDE_FROM_ALL)
endif ()
add_compile_definitions(URDE_ZIP_INPUT_STREAM=1) # Enable CZipInputStream now that zlib header is known
add_subdirectory(DataSpec)
add_subdirectory(extern/kabufuda)
add_subdirectory(extern/kabufuda EXCLUDE_FROM_ALL)
add_subdirectory(extern/jbus)
add_subdirectory(extern/jbus EXCLUDE_FROM_ALL)
set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/jbus/include)
add_subdirectory(NESEmulator)
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
add_subdirectory(Runtime)
add_subdirectory(mpcksum)
add_subdirectory(gbalink)
add_subdirectory(mpcksum EXCLUDE_FROM_ALL)
add_subdirectory(gbalink EXCLUDE_FROM_ALL)
add_subdirectory(visigen)
add_dependencies(hecl visigen)
@ -472,3 +541,34 @@ if (NOT WINDOWS_STORE AND NOT NX)
endif()
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
# Packaging logic
list(APPEND BINARY_TARGETS metaforce hecl visigen)
set(DSYM_ONLY_TARGETS "")
if (TARGET crashpad_handler)
list(APPEND BINARY_TARGETS crashpad_handler)
endif ()
set(BIN_PREFIX "${CMAKE_INSTALL_PREFIX}")
if (TARGET metaforce-gui)
if (APPLE)
# app bundle already has all needed binaries
install(TARGETS metaforce-gui DESTINATION ${BIN_PREFIX})
list(APPEND DSYM_ONLY_TARGETS metaforce-gui)
# we have to rename here, cmake is inflexible about bundle naming
install(CODE "execute_process(COMMAND rm -fr ${BIN_PREFIX}/Metaforce.app)")
install(CODE "execute_process(COMMAND mv ${BIN_PREFIX}/metaforce-gui.app ${BIN_PREFIX}/Metaforce.app)")
set(BIN_PREFIX "${BIN_PREFIX}/Metaforce.app/Contents/MacOS")
else()
list(APPEND BINARY_TARGETS metaforce-gui)
endif ()
endif ()
install(TARGETS ${BINARY_TARGETS} DESTINATION ${BIN_PREFIX})
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
foreach (target IN LISTS BINARY_TARGETS DSYM_ONLY_TARGETS)
if (WIN32)
install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${BIN_PREFIX} OPTIONAL)
elseif (APPLE)
install(CODE "execute_process(COMMAND dsymutil ${BIN_PREFIX}/${target})")
endif ()
endforeach ()
endif ()

View File

@ -51,9 +51,6 @@ NFS files dumped from Metroid Prime Trilogy on Wii U VC can be used directly wit
* Windows: [Microsoft Store](https://go.microsoft.com/fwlink?linkID=2082640)
* Verify it's added to `%PATH%` by typing `python` in `cmd`.
* macOS: `brew install python@3`
* LLVM development package *(headers and libs)*
* [Specialized Windows Package](https://axiodl.com/files/LLVM-10.0.1-win64.exe)
* macOS: `brew install --force-bottle llvm`
* **[Windows]** [Visual Studio 2019 Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx)
* Select `C++ Development` and verify the following packages are included:
* `Windows 10 SDK`
@ -64,8 +61,8 @@ NFS files dumped from Metroid Prime Trilogy on Wii U VC can be used directly wit
* **[Linux]** recent development packages of `udev`, `x11`, `xcb`, `xinput`, `glx`, `asound`
* Ubuntu 20.04+ packages
```
build-essential curl git ninja-build llvm-dev libclang-dev clang lld zlib1g-dev libcurl4-openssl-dev
libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev libpulse-dev
build-essential curl git ninja-build clang lld zlib1g-dev libcurl4-openssl-dev \
libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev libpulse-dev \
libudev-dev libpng-dev libncurses5-dev cmake libx11-xcb-dev python3 python-is-python3 qt5-default
```
* Arch packages

View File

@ -1,20 +1,32 @@
if(NOT WIN32 AND NOT APPLE AND NOT NX) # remove WIN32 when specter/freetype is gone
find_library(PNG_LIB NAMES png libpng)
endif()
if(NOT PNG_LIB)
message(STATUS "Using HECL's built-in libpng")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm(64)?")
set(INTRINSICS
if (APPLE)
# only consider static libs
find_library(PNG_LIB NAMES libpng.a PATHS ${PNG_DIR} NO_DEFAULT_PATHS NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_SYSTEM_PATH)
if (PNG_LIB)
set(PNG_LIBRARIES ${PNG_LIB} ${ZLIB_LIBRARIES} CACHE PATH "PNG libraries" FORCE)
find_path(PNG_INCLUDE_DIR png.h PATHS "${PNG_LIB}/../../include" NO_DEFAULT_PATHS NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_SYSTEM_PATH)
set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIR} CACHE PATH "PNG include path" FORCE)
message(STATUS "Using libpng at ${PNG_LIB}, include: ${PNG_INCLUDE_DIR}")
endif()
elseif (NOT WIN32 AND NOT NX) # remove WIN32 when specter/freetype is gone
find_package(PNG REQUIRED)
set(PNG_LIBRARIES ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} CACHE STRING "PNG libraries" FORCE)
set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIR} CACHE PATH "PNG include path" FORCE)
endif ()
if (NOT PNG_LIBRARIES)
message(STATUS "Using HECL's built-in libpng")
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm(64)?" OR (APPLE AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES))
list(APPEND INTRINSICS
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c
arm/palette_neon_intrinsics.c)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
set(INTRINSICS
endif ()
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR (APPLE AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES))
list(APPEND INTRINSICS
intel/filter_sse2_intrinsics.c
intel/intel_init.c)
endif()
add_library(png
endif ()
add_library(png
png.h
pngconf.h
pngdebug.h
@ -39,15 +51,11 @@ add_library(png
pngwtran.c
pngwutil.c
${INTRINSICS})
if(APPLE)
if (APPLE)
target_compile_options(png PRIVATE -Wno-implicit-fallthrough)
endif()
target_link_libraries(png PUBLIC ${ZLIB_LIBRARIES})
target_include_directories(png PUBLIC ${ZLIB_INCLUDE_DIR})
set(PNG_LIBRARIES png CACHE PATH "PNG libraries" FORCE)
set(PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "PNG include path" FORCE)
else()
set(PNG_LIBRARIES ${PNG_LIB} CACHE PATH "PNG libraries" FORCE)
find_path(PNG_INCLUDE_DIR png.h)
set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIR} CACHE PATH "PNG include path" FORCE)
endif()
endif ()
target_link_libraries(png PUBLIC ${ZLIB_LIBRARIES})
target_include_directories(png PUBLIC ${ZLIB_INCLUDE_DIR})
set(PNG_LIBRARIES png CACHE PATH "PNG libraries" FORCE)
set(PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "PNG include path" FORCE)
endif ()

View File

@ -52,14 +52,12 @@ endforeach()
configure_file(include/hecl/ApplicationReps.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/ApplicationReps.hpp @ONLY)
if(NOT TARGET bintoc)
add_subdirectory(bintoc)
endif()
if(NOT TARGET bintoc)
# Use native if cross compiling
find_package(hecl-bintoc REQUIRED)
endif()
include(ExternalProject)
ExternalProject_Add(bintoc
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bintoc"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install)
include(bintoc/bintocHelpers.cmake)
if(NOT TARGET atdna)
# Import native atdna if cross-compiling

View File

@ -1,62 +1,9 @@
if(NOT CMAKE_CROSSCOMPILING)
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
cmake_policy(VERSION 3.15...3.20)
project(bintoc LANGUAGES C)
add_executable(bintoc bintoc.c)
target_include_directories(bintoc PRIVATE ${ZLIB_INCLUDE_DIR})
target_link_libraries(bintoc ${ZLIB_LIBRARIES})
function(bintoc out in sym)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
else()
set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out})
endif()
if(IS_ABSOLUTE ${in})
set(theIn ${in})
else()
set(theIn ${CMAKE_CURRENT_SOURCE_DIR}/${in})
endif()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
add_custom_command(OUTPUT ${theOut}
COMMAND $<TARGET_FILE:bintoc> ARGS ${theIn} ${theOut} ${sym}
DEPENDS ${theIn} bintoc)
endfunction()
function(bintoc_compress out in sym)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
else()
set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out})
endif()
if(IS_ABSOLUTE ${in})
set(theIn ${in})
else()
set(theIn ${CMAKE_CURRENT_SOURCE_DIR}/${in})
endif()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
add_custom_command(OUTPUT ${theOut}
COMMAND $<TARGET_FILE:bintoc> ARGS --compress ${theIn} ${theOut} ${sym}
DEPENDS ${theIn} bintoc)
endfunction()
find_package(ZLIB REQUIRED)
target_link_libraries(bintoc PRIVATE ZLIB::ZLIB)
##################
# Package Export #
##################
# Add all targets to the build-tree export set
export(TARGETS bintoc FILE "${CMAKE_CURRENT_BINARY_DIR}/hecl-bintocTargets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE hecl-bintoc)
# Create the atdnaConfig.cmake
# ... for the build tree
configure_file(hecl-bintocConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/hecl-bintocConfig.cmake" @ONLY)
# ... for the install tree
configure_file(hecl-bintocConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hecl-bintocConfig.cmake" @ONLY)
# ... for both
configure_file(hecl-bintocConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/hecl-bintocConfigVersion.cmake" @ONLY)
else()
# Use native if cross compiling
find_package(hecl-bintoc REQUIRED)
endif()
install(TARGETS bintoc DESTINATION bin)

View File

@ -1,13 +1,3 @@
# - Config file for the bintoc package
# Compute paths
get_filename_component(BINTOC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET bintoc AND NOT bintoc_BINARY_DIR)
include("${BINTOC_CMAKE_DIR}/hecl-bintocTargets.cmake")
endif()
function(bintoc out in sym)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
@ -21,9 +11,10 @@ function(bintoc out in sym)
endif()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
ExternalProject_Get_Property(bintoc INSTALL_DIR)
add_custom_command(OUTPUT ${theOut}
COMMAND $<TARGET_FILE:bintoc> ARGS ${theIn} ${theOut} ${sym}
DEPENDS ${theIn})
COMMAND "${INSTALL_DIR}/bin/bintoc" ARGS ${theIn} ${theOut} ${sym}
DEPENDS ${theIn} bintoc)
endfunction()
function(bintoc_compress out in sym)
@ -39,7 +30,8 @@ function(bintoc_compress out in sym)
endif()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
ExternalProject_Get_Property(bintoc INSTALL_DIR)
add_custom_command(OUTPUT ${theOut}
COMMAND $<TARGET_FILE:bintoc> ARGS --compress ${theIn} ${theOut} ${sym}
DEPENDS ${theIn})
COMMAND "${INSTALL_DIR}/bin/bintoc" ARGS --compress ${theIn} ${theOut} ${sym}
DEPENDS ${theIn} bintoc)
endfunction()

View File

@ -1,12 +0,0 @@
set(PACKAGE_VERSION "@BINTOC_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@ -87,12 +87,6 @@ target_link_libraries(hecl-light PUBLIC ${HECL_APPLICATION_REPS_TARGETS_LIST} bo
target_atdna(hecl-light atdna_HMDLMeta_light.cpp ../include/hecl/HMDLMeta.hpp)
target_atdna(hecl-light atdna_CVar_light.cpp ../include/hecl/CVar.hpp)
add_library(hecl-compilers Compilers.cpp WideStringConvert.cpp)
get_target_property(BOO_INCLUDES boo INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(hecl-compilers PUBLIC ../include ${BOO_INCLUDES})
target_link_libraries(hecl-compilers PUBLIC athena-core logvisor xxhash
glslang OSDependent OGLCompiler SPIRV glslang-default-resource-limits)
if(COMMAND add_sanitizers)
add_sanitizers(hecl-full)
add_sanitizers(hecl-light)

View File

@ -1,7 +1,92 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
cmake_policy(VERSION 3.15...3.20)
project(shaderc LANGUAGES C CXX)
if (MSVC)
# Shaddup MSVC
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
_CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1
_SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1
_ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1)
add_compile_options(/IGNORE:4221
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4018>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4800>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4005>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4311>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4068>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4267>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4244>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4200>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4305>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4067>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4146>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4309>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4805>
${VS_OPTIONS})
string(REPLACE "/GR " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(
# Disable exceptions
$<$<COMPILE_LANGUAGE:CXX>:/EHsc->
# Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:/GR->
# Enforce various standards compliant behavior.
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
# Enable standard volatile semantics.
$<$<COMPILE_LANGUAGE:CXX>:/volatile:iso>
# Reports the proper value for the __cplusplus preprocessor macro.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
# Use latest C++ standard.
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Flags for MSVC (not clang-cl)
add_compile_options(
# Allow constexpr variables to have explicit external linkage.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>
# Assume that new throws exceptions, allowing better code generation.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:throwingNew>
# Link-time Code Generation for Release builds
$<$<CONFIG:Release>:/GL>
)
# Link-time Code Generation for Release builds
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
endif()
else()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()
# two step: --target shaderc, --target install
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
add_custom_target(atdna) # avoid building
add_subdirectory(../../extern/athena athena)
add_subdirectory(../../extern/boo boo)
add_library(hecl-compilers ../lib/Compilers.cpp ../lib/WideStringConvert.cpp)
get_target_property(BOO_INCLUDES boo INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(hecl-compilers PUBLIC ../include ${BOO_INCLUDES})
target_link_libraries(hecl-compilers PUBLIC athena-core logvisor xxhash
glslang OSDependent OGLCompiler SPIRV glslang-default-resource-limits)
add_library(shaderc_lib shaderc.cpp shaderc.hpp)
target_link_libraries(shaderc_lib PUBLIC hecl-compilers athena-core logvisor)
add_executable(shaderc main.cpp)
target_link_libraries(shaderc shaderc_lib)
if (NOT WIN32)
target_link_libraries(shaderc pthread)
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
@ -10,29 +95,5 @@ if (NOT WIN32)
target_link_libraries(shaderc dl)
endif()
endif()
if(COMMAND add_sanitizers)
add_sanitizers(shaderc_lib)
add_sanitizers(shaderc)
endif()
function(shaderc out)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
else()
set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out})
endif()
unset(theInsList)
foreach(in ${ARGN})
if(IS_ABSOLUTE ${in})
list(APPEND theInsList ${in})
else()
list(APPEND theInsList ${CMAKE_CURRENT_SOURCE_DIR}/${in})
endif()
endforeach()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
file(RELATIVE_PATH outRel ${CMAKE_BINARY_DIR} ${theOut})
add_custom_command(OUTPUT ${theOut}.cpp ${theOut}.hpp
COMMAND $<TARGET_FILE:shaderc> ARGS -o ${theOut} ${theInsList}
DEPENDS ${theInsList} shaderc COMMENT "Compiling shader ${outRel}.shader")
endfunction()
install(TARGETS shaderc DESTINATION bin)

View File

@ -144,20 +144,6 @@ elseif (APPLE)
set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
add_custom_command(
TARGET metaforce-gui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:metaforce> $<TARGET_FILE_DIR:metaforce-gui>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:hecl> $<TARGET_FILE_DIR:metaforce-gui>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:visigen> $<TARGET_FILE_DIR:metaforce-gui>
DEPENDS metaforce hecl visigen
)
if (NOT "${SENTRY_DSN}" STREQUAL "")
add_custom_command(
TARGET metaforce-gui POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:crashpad_handler> $<TARGET_FILE_DIR:metaforce-gui>
DEPENDS crashpad_handler
)
endif()
endif ()
add_subdirectory(platforms/freedesktop)