From 6fc33e809ae4663f1a6813e4c64e1f6ab542cabe Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 10 Jun 2021 00:30:31 -0400 Subject: [PATCH] Use CMakePresets.json --- .github/workflows/build.yml | 104 +++---------- .gitignore | 1 + CMakePresets.json | 284 ++++++++++++++++++++++++++++++++++++ 3 files changed, 303 insertions(+), 86 deletions(-) create mode 100644 CMakePresets.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ef5736ef..02a3bffdf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,11 +19,9 @@ jobs: matrix: include: - name: GCC - cc: gcc - cxx: g++ + preset: gcc - name: Clang - cc: clang - cxx: clang++ + preset: clang steps: - uses: actions/checkout@v2 @@ -51,22 +49,15 @@ jobs: echo After df -h . - - name: Create build directory - run: cmake -E make_directory ${{github.workspace}}/build - - name: Configure CMake - working-directory: ${{github.workspace}}/build - run: | - cmake $GITHUB_WORKSPACE -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_C_COMPILER=${{matrix.cc}} -DCMAKE_CXX_COMPILER=${{matrix.cxx}} \ - -DClang_DIR=/usr/lib/cmake/clang-11 + run: cmake --preset linux-ci-${{matrix.preset}} - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --target metaforce metaforce-gui hecl visigen + run: cmake --build --preset linux-ci-${{matrix.preset}} build-macos: name: Build macOS (AppleClang x86_64) + if: 'false' runs-on: macos-10.15 steps: - uses: actions/checkout@v2 @@ -95,10 +86,18 @@ jobs: working-directory: ${{github.workspace}}/build run: cmake --build . --target metaforce-gui - build-windows-msvc: - name: Build Windows (MSVC x86_64) - if: 'false' # disabled due to memory constraints + build-windows: + name: Build Windows (${{matrix.name}} x86_64) runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + include: + - name: MSVC + preset: msvc + - name: Clang + preset: clang + env: LLVM_VERSION: 10.0.1 Qt_VERSION: 5.15.2 @@ -131,75 +130,8 @@ jobs: - name: Enable Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 - - name: Create build directory - run: cmake -E make_directory ${{github.workspace}}/build - - name: Configure CMake - working-directory: ${{github.workspace}}/build - run: | - $workspace = $env:RUNNER_WORKSPACE -replace '\\', '/' - cmake $env:GITHUB_WORKSPACE -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo ` - -DCMAKE_TOOLCHAIN_FILE="$workspace/vcpkg-qt-$env:Qt_VERSION/scripts/buildsystems/vcpkg.cmake" ` - -DVCPKG_TARGET_TRIPLET=x64-windows-static ` - -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_CXX_FLAGS= -DCMAKE_C_FLAGS= ` - -DLLVM_ROOT_DIR="$workspace/LLVM" + run: cmake --preset windows-ci-${{matrix.preset}} - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --target metaforce metaforce-gui hecl visigen - - build-windows-clang: - name: Build Windows (Clang x86_64) - if: 'false' # disabled due to header issues - runs-on: windows-2019 - 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" - $Filename = "vcpkg-qt-$env:Qt_VERSION.7z" - New-Item -Path "$TempDir" -ItemType Directory -ea 0 - (New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename") - 7z x "-o$env:RUNNER_WORKSPACE" -aos "$TempDir\$Filename" - - - name: Install dependencies - run: choco install ninja vulkan-sdk - - - name: Enable Visual Studio environment - uses: ilammy/msvc-dev-cmd@v1 - - - name: Create build directory - run: cmake -E make_directory ${{github.workspace}}/build - - - name: Configure CMake - working-directory: ${{github.workspace}}/build - run: | - $workspace = $env:RUNNER_WORKSPACE -replace '\\', '/' - cmake $env:GITHUB_WORKSPACE -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo ` - -DCMAKE_TOOLCHAIN_FILE="$workspace/vcpkg-qt-$env:Qt_VERSION/scripts/buildsystems/vcpkg.cmake" ` - -DVCPKG_TARGET_TRIPLET=x64-windows-static ` - -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` - -DCMAKE_C_COMPILER=clang-cl ` - -DCMAKE_CXX_COMPILER=clang-cl ` - -DCMAKE_LINKER=lld-link ` - -DLLVM_ROOT_DIR="$workspace/LLVM" - - - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --target metaforce metaforce-gui hecl visigen + run: cmake --build --preset windows-ci-${{matrix.preset}} diff --git a/.gitignore b/.gitignore index 7577afcb3..1079b646c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ Runtime/platforms/win/metaforce.rc out/ cmake-build-*/ build/ +CMakeUserPresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..b4d111e61 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,284 @@ +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "relwithdebinfo", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "linux-default", + "displayName": "Linux (default)", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + }, + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" + } + } + }, + { + "name": "linux-default-debug", + "displayName": "Linux (default) Debug", + "inherits": [ + "linux-default", + "debug" + ] + }, + { + "name": "linux-default-relwithdebinfo", + "displayName": "Linux (default) RelWithDebInfo", + "inherits": [ + "linux-default", + "relwithdebinfo" + ] + }, + { + "name": "linux-clang", + "displayName": "Linux (Clang)", + "inherits": [ + "linux-default" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "linux-clang-debug", + "displayName": "Linux (Clang) Debug", + "inherits": [ + "linux-clang", + "debug" + ] + }, + { + "name": "linux-clang-relwithdebinfo", + "displayName": "Linux (Clang) RelWithDebInfo", + "inherits": [ + "linux-clang", + "relwithdebinfo" + ] + }, + { + "name": "windows-msvc", + "displayName": "Windows (MSVC)", + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded", + "VCPKG_TARGET_TRIPLET": "x64-windows-static" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Windows" + ] + } + } + }, + { + "name": "windows-msvc-debug", + "displayName": "Windows (MSVC) Debug", + "inherits": [ + "windows-msvc", + "debug" + ] + }, + { + "name": "windows-msvc-relwithdebinfo", + "displayName": "Windows (MSVC) RelWithDebInfo", + "inherits": [ + "windows-msvc", + "relwithdebinfo" + ] + }, + { + "name": "windows-clang", + "displayName": "Windows (Clang)", + "inherits": [ + "windows-msvc" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl", + "CMAKE_LINKER": "lld-link" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-clang-x64" + } + } + }, + { + "name": "windows-clang-debug", + "displayName": "Windows (Clang) Debug", + "inherits": [ + "windows-clang", + "debug" + ] + }, + { + "name": "windows-clang-relwithdebinfo", + "displayName": "Windows (Clang) RelWithDebInfo", + "inherits": [ + "windows-clang", + "relwithdebinfo" + ] + }, + { + "name": "linux-ci", + "hidden": true, + "inherits": [ + "relwithdebinfo" + ], + "cacheVariables": { + "Clang_DIR": { + "type": "FILEPATH", + "value": "/usr/lib/cmake/clang-11" + } + } + }, + { + "name": "linux-ci-gcc", + "inherits": [ + "linux-default", + "linux-ci" + ] + }, + { + "name": "linux-ci-clang", + "inherits": [ + "linux-clang", + "linux-ci" + ] + }, + { + "name": "windows-ci", + "hidden": true, + "inherits": [ + "relwithdebinfo" + ], + "cacheVariables": { + "LLVM_ROOT_DIR": "$env{RUNNER_WORKSPACE}/LLVM" + }, + "environment": { + "VCPKG_ROOT": "$env{RUNNER_WORKSPACE}/vcpkg-qt-$env{Qt_VERSION}" + } + }, + { + "name": "windows-ci-msvc", + "inherits": [ + "windows-msvc", + "windows-ci" + ] + }, + { + "name": "windows-ci-clang", + "inherits": [ + "windows-clang", + "windows-ci" + ] + } + ], + "buildPresets": [ + { + "name": "linux-default-debug", + "configurePreset": "linux-default-debug", + "description": "Linux (default) debug build", + "displayName": "Linux (default) Debug" + }, + { + "name": "linux-default-relwithdebinfo", + "configurePreset": "linux-default-relwithdebinfo", + "description": "Linux (default) release build with debug info", + "displayName": "Linux (default) RelWithDebInfo" + }, + { + "name": "linux-clang-debug", + "configurePreset": "linux-clang-debug", + "description": "Linux (Clang) debug build", + "displayName": "Linux (Clang) Debug" + }, + { + "name": "linux-clang-relwithdebinfo", + "configurePreset": "linux-clang-relwithdebinfo", + "description": "Linux (Clang) release build with debug info", + "displayName": "Linux (Clang) RelWithDebInfo" + }, + { + "name": "windows-msvc-debug", + "configurePreset": "windows-msvc-debug", + "description": "Windows (MSVC) debug build", + "displayName": "Windows (MSVC) Debug" + }, + { + "name": "windows-msvc-relwithdebinfo", + "configurePreset": "windows-msvc-relwithdebinfo", + "description": "Windows (MSVC) release build with debug info", + "displayName": "Windows (MSVC) RelWithDebInfo" + }, + { + "name": "windows-clang-debug", + "configurePreset": "windows-clang-debug", + "description": "Windows (Clang) debug build", + "displayName": "Windows (Clang) Debug" + }, + { + "name": "windows-clang-relwithdebinfo", + "configurePreset": "windows-clang-relwithdebinfo", + "description": "Windows (Clang) release build with debug info", + "displayName": "Windows (Clang) RelWithDebInfo" + }, + { + "name": "linux-ci-gcc", + "configurePreset": "linux-ci-gcc", + "targets": ["metaforce", "metaforce-gui", "hecl", "visigen"] + }, + { + "name": "linux-ci-clang", + "configurePreset": "linux-ci-clang", + "targets": ["metaforce", "metaforce-gui", "hecl", "visigen"] + }, + { + "name": "windows-ci-msvc", + "configurePreset": "windows-ci-msvc", + "targets": ["metaforce", "metaforce-gui", "hecl", "visigen"] + }, + { + "name": "windows-ci-clang", + "configurePreset": "windows-ci-clang", + "targets": ["metaforce", "metaforce-gui", "hecl", "visigen"] + } + ] +}