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

Implements CMakePresets.json to simplify project config. #746

Merged
merged 2 commits into from
Jun 14, 2024
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
26 changes: 15 additions & 11 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ jobs:
title: "Development Build"

vanilla-linux:
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
platform: [clang, gcc]
networking: [net, nonet]
os: [ubuntu-22.04]

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand All @@ -49,14 +51,14 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y clang-format-14 libsdl2-dev libopenal-dev > /dev/null
sudo apt-get install -qq -y clang-format-14 libsdl2-dev libopenal-dev ninja-build > /dev/null

- name: Configure Vanilla Conquer
env:
CC: ${{ steps.vars.outputs.cc }}
CXX: ${{ steps.vars.outputs.cxx }}
run: |
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMAP_EDITORTD=ON -DMAP_EDITORRA=ON -DBUILD_TOOLS=ON -DBUILD_TESTS=ON -B build
cmake --preset ${{ matrix.platform }}-vanilla-${{ matrix.networking }}-tests

- name: Check formatting
if: ${{ matrix.platform }} == clang
Expand All @@ -66,7 +68,7 @@ jobs:

- name: Build Vanilla Conquer
run: |
cmake --build build -- -j 4
cmake --build build
cp ./build/vanillatd ./build/vanillatd.dbg
cp ./build/vanillara ./build/vanillara.dbg
cp ./build/vanillamix ./build/vanillamix.dbg
Expand All @@ -83,19 +85,21 @@ jobs:
ctest

- name: Create archives
if: ${{ matrix.networking == 'net' }}
run: |
mkdir artifact
7z a artifact/vanilla-conquer-linux-${{ matrix.platform }}-x86_64-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/vanillatd ./build/vanillara ./build/vanillamix
7z a artifact/vanilla-conquer-linux-${{ matrix.platform }}-x86_64-${{ steps.gitinfo.outputs.sha_short }}-debug.zip ./build/vanillatd.dbg ./build/vanillara.dbg ./build/vanillamix.dbg
7z a artifact/vanilla-conquer-linux-${{ matrix.platform }}-${{ matrix.os }}-x86_64-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/vanillatd ./build/vanillara ./build/vanillamix
7z a artifact/vanilla-conquer-linux-${{ matrix.platform }}-${{ matrix.os }}-x86_64-${{ steps.gitinfo.outputs.sha_short }}-debug.zip ./build/vanillatd.dbg ./build/vanillara.dbg ./build/vanillamix.dbg

- name: Upload artifact
uses: actions/[email protected]
if: ${{ matrix.networking == 'net' }}
uses: actions/upload-artifact@v4
with:
name: vanilla-conquer-linux-${{ matrix.platform }}-x86_64
name: vanilla-conquer-linux-${{ matrix.platform }}-${{ matrix.os }}-x86_64
path: artifact

- name: Upload development release
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' }}
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
name: Development Build
Expand All @@ -107,7 +111,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tagged release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
files: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ on:

jobs:
vanilla-macos:
runs-on: macos-12
runs-on: macos-12
strategy:
matrix:
networking: [net, nonet]

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand Down Expand Up @@ -60,7 +64,7 @@ jobs:
- name: Configure Vanilla Conquer
run: |
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
cmake -G Ninja -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMAP_EDITORTD=ON -DMAP_EDITORRA=ON -DBUILD_TOOLS=ON -B build
cmake --preset clang-vanilla-${{ matrix.networking }}-tests -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"

- name: Build Vanilla Conquer
run: |
Expand All @@ -76,19 +80,21 @@ jobs:
dylibbundler --create-dir --bundle-deps --overwrite-files --dest-dir ./build/vanillara.app/Contents/libs --fix-file build/vanillara.app/Contents/MacOS/vanillara

- name: Create archives
if: ${{ matrix.networking == 'net' }}
run: |
mkdir artifact
7z a artifact/vanilla-conquer-macos-clang-universal2-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/vanillatd.app ./build/vanillara.app ./build/vanillamix
7z a artifact/vanilla-conquer-macos-clang-universal2-${{ steps.gitinfo.outputs.sha_short }}-debug.zip ./build/vanillatd.dSYM ./build/vanillara.dSYM ./build/vanillamix.dSYM

- name: Upload artifact
uses: actions/[email protected]
if: ${{ matrix.networking == 'net' }}
uses: actions/upload-artifact@v4
with:
name: vanilla-conquer-macos-clang-universal2
path: artifact

- name: Upload development release
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' }}
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
name: Development Build
Expand All @@ -100,7 +106,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tagged release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
files: |
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
remaster_gcc:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand All @@ -21,11 +21,11 @@ jobs:
- name: Install Dependencies
run: |
sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y mingw-w64 > /dev/null
sudo apt-get install -qq -y ninja-build mingw-w64 > /dev/null

- name: Configure Vanilla Conquer
run: |
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/i686-mingw-w64-toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_REMASTERTD=ON -DBUILD_REMASTERRA=ON -DBUILD_VANILLATD=OFF -DBUILD_VANILLARA=OFF -DNETWORKING=OFF -B build
cmake --preset mingw-i686-remaster -B build

- name: Build Vanilla Conquer
run: |
Expand All @@ -48,7 +48,7 @@ jobs:
7z a artifact/vanilla-td-remaster-mod-gcc-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/Vanilla_TD

- name: Upload artifact
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
name: vanilla-conquer-remaster-gcc
path: artifact
Expand All @@ -58,9 +58,10 @@ jobs:
strategy:
matrix:
platform: [x86, amd64]
networking: [net, nonet]

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand All @@ -85,7 +86,7 @@ jobs:
- name: Install Dependencies
run: |
sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y mingw-w64 imagemagick > /dev/null
sudo apt-get install -qq -y ninja-build mingw-w64 imagemagick > /dev/null
wget -q https://www.libsdl.org/release/SDL2-devel-2.0.12-mingw.tar.gz
wget -q https://www.openal-soft.org/openal-binaries/openal-soft-1.21.0-bin.zip
tar -xf SDL2-devel-2.0.12-mingw.tar.gz -C /tmp
Expand All @@ -94,11 +95,11 @@ jobs:

- name: Configure Vanilla Conquer
run: |
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/${{ steps.vars.outputs.arc_path }}-mingw-w64-toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSDL2=ON -DSDL2_ROOT_DIR=/tmp/SDL2-2.0.12 -DSDL2_INCLUDE_DIR=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/include/SDL2 -DSDL2_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/lib/libSDL2.dll.a -DSDL2_SDLMAIN_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/lib/libSDL2main.a -DSDL2_RUNTIME_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/bin/SDL2.dll -DOPENAL=ON -DOPENAL_ROOT=/tmp/openal-soft-1.21.0-bin -DOPENAL_INCLUDE_DIR=/tmp/openal-soft-1.21.0-bin/include/AL -DOPENAL_LIBRARY=/tmp/openal-soft-1.21.0-bin/libs/${{ steps.vars.outputs.oal_path }}/libOpenAL32.dll.a -DOPENAL_RUNTIME_LIBRARY=/tmp/openal-soft-1.21.0-bin/bin/${{ steps.vars.outputs.oal_path }}/OpenAL32.dll -DBUILD_TOOLS=ON -DBUILD_REMASTERTD=OFF -DBUILD_REMASTERRA=OFF -DMAP_EDITORTD=ON -DMAP_EDITORRA=ON -DImageMagick_convert_EXECUTABLE=/usr/bin/convert -DImageMagick_convert_FOUND=TRUE -B build
cmake --preset mingw-${{ steps.vars.outputs.arc_path }}-vanilla -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DSDL2_ROOT_DIR=/tmp/SDL2-2.0.12 -DSDL2_INCLUDE_DIR=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/include/SDL2 -DSDL2_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/lib/libSDL2.dll.a -DSDL2_SDLMAIN_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/lib/libSDL2main.a -DSDL2_RUNTIME_LIBRARY=/tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/bin/SDL2.dll -DOPENAL=ON -DOPENAL_ROOT=/tmp/openal-soft-1.21.0-bin -DOPENAL_INCLUDE_DIR=/tmp/openal-soft-1.21.0-bin/include/AL -DOPENAL_LIBRARY=/tmp/openal-soft-1.21.0-bin/libs/${{ steps.vars.outputs.oal_path }}/libOpenAL32.dll.a -DOPENAL_RUNTIME_LIBRARY=/tmp/openal-soft-1.21.0-bin/bin/${{ steps.vars.outputs.oal_path }}/OpenAL32.dll -DImageMagick_convert_EXECUTABLE=/usr/bin/convert -DImageMagick_convert_FOUND=TRUE

- name: Build Vanilla Conquer
run: |
cmake --build build -- -j 4
cmake --build build
cp ./build/vanillatd.exe ./build/vanillatd.dbg
cp ./build/vanillara.exe ./build/vanillara.dbg
cp ./build/vanillamix.exe ./build/vanillamix.dbg
Expand All @@ -110,19 +111,21 @@ jobs:
${{ steps.vars.outputs.arc_path }}-w64-mingw32-objcopy --add-gnu-debuglink=./build/vanillamix.dbg ./build/vanillamix.exe

- name: Create archives
if: ${{ matrix.networking == 'net' }}
run: |
mkdir artifact
7z a artifact/vanilla-conquer-win-gcc-${{ steps.vars.outputs.arc_path }}-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/vanillatd.exe ./build/vanillara.exe ./build/vanillamix.exe /tmp/SDL2-2.0.12/${{ steps.vars.outputs.arc_path }}-w64-mingw32/bin/SDL2.dll /tmp/openal-soft-1.21.0-bin/bin/${{ steps.vars.outputs.oal_path }}/OpenAL32.dll
7z a artifact/vanilla-conquer-win-gcc-${{ steps.vars.outputs.arc_path }}-${{ steps.gitinfo.outputs.sha_short }}-debug.zip ./build/vanillatd.dbg ./build/vanillara.dbg ./build/vanillamix.dbg

- name: Upload artifact
uses: actions/[email protected]
uses: actions/upload-artifact@v4
if: ${{ matrix.networking == 'net' }}
with:
name: vanilla-conquer-win-gcc-${{ steps.vars.outputs.arc_path }}
path: artifact

- name: Upload development release
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' }}
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
name: Development Build
Expand All @@ -134,7 +137,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tagged release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
files: |
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
remaster_msvc:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand All @@ -31,11 +31,11 @@ jobs:

- name: Configure Vanilla Conquer
run: |
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_REMASTERTD=ON -DBUILD_REMASTERRA=ON -DBUILD_VANILLATD=OFF -DBUILD_VANILLARA=OFF -DNETWORKING=OFF -B build
cmake --preset cl-remaster

- name: Build Vanilla Conquer
run: |
cmake --build build --config RelWithDebInfo
cmake --build build

- name: Create archives
shell: bash
Expand All @@ -47,7 +47,7 @@ jobs:
7z a artifact/vanilla-td-remaster-mod-msvc-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/Vanilla_TD

- name: Upload artifact
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
name: vanilla-conquer-remaster-msvc
path: artifact
Expand Down Expand Up @@ -78,8 +78,9 @@ jobs:
strategy:
matrix:
platform: [x86, amd64]
networking: [net, nonet]
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
Expand Down Expand Up @@ -122,33 +123,35 @@ jobs:

- name: Configure Vanilla Conquer
run: |
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TOOLS=ON -DBUILD_TESTS=ON -DSDL2=ON "-DSDL2_ROOT_DIR=$($Env:TEMP)\SDL2-2.0.12" -DOPENAL=ON "-DOPENAL_ROOT=C:\Program Files (x86)\OpenAL 1.1 SDK" -DBUILD_REMASTERTD=OFF -DBUILD_REMASTERRA=OFF -DMAP_EDITORTD=ON -DMAP_EDITORRA=ON "-DImageMagick_magick_EXECUTABLE=$($(Get-Command magick.exe).Source)" -DImageMagick_magick_FOUND=TRUE -B build
cmake --preset cl-vanilla-${{ matrix.networking }}-tests -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON "-DSDL2_ROOT_DIR=$($Env:TEMP)\SDL2-2.0.12" "-DOPENAL_ROOT=C:\Program Files (x86)\OpenAL 1.1 SDK" "-DImageMagick_magick_EXECUTABLE=$($(Get-Command magick.exe).Source)" -DImageMagick_magick_FOUND=TRUE

- name: Build Vanilla Conquer
run: |
cmake --build build --config RelWithDebInfo
cmake --build build

- name: Run unit tests
run: |
cd build
Copy-Item -Path "$Env:TEMP\SDL2-2.0.12\lib\${{ steps.vars.outputs.sdl_path }}\SDL2.dll" -Destination . -verbose
ctest -C RelWithDebInfo
ctest -C Release

- name: Create archives
if: ${{ matrix.networking == 'net' }}
shell: bash
run: |
mkdir artifact
7z a artifact/vanilla-conquer-win-msvc-${{ steps.vars.outputs.arc_path }}-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/vanillatd.exe ./build/vanillara.exe ./build/vanillamix.exe $TEMP/SDL2-2.0.12/lib/${{ steps.vars.outputs.sdl_path }}/SDL2.dll $TEMP/openal-soft-1.21.0-bin/bin/${{ steps.vars.outputs.oal_path }}/OpenAL32.dll
7z a artifact/vanilla-conquer-win-msvc-${{ steps.vars.outputs.arc_path }}-${{ steps.gitinfo.outputs.sha_short }}-debug.zip ./build/vanillatd.pdb ./build/vanillara.pdb ./build/vanillamix.pdb

- name: Upload artifact
uses: actions/[email protected]
if: ${{ matrix.networking == 'net' }}
uses: actions/upload-artifact@v4
with:
name: vanilla-conquer-win-msvc-${{ steps.vars.outputs.arc_path }}
path: artifact

- name: Upload development release
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' }}
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/vanilla' && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
name: Development Build
Expand All @@ -160,7 +163,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tagged release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.networking == 'net' }}
uses: softprops/action-gh-release@v1
with:
files: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/build*
/CMakeUserPresets.json
/.cache
/.vscode
40 changes: 4 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.15)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include(FeatureSummary)
include(CheckCXXCompilerFlag)

if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
endif()

project(VanillaConquer CXX)
project(VanillaConquer C CXX)

option(BUILD_REMASTERTD "Build Tiberian Dawn remaster dll." OFF)
option(BUILD_REMASTERRA "Build Red Alert remaster dll." OFF)
Expand Down Expand Up @@ -72,39 +72,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT MSVC)
if(WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "-gstabs3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
set(STATIC_LIBS "-static-libstdc++ -static-libgcc")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(CMAKE_FIND_FRAMEWORK "LAST")
endif()

message(STATUS "Checking whether compiler supports -fdata-sections")
check_cxx_compiler_flag("-Werror -fdata-sections" HAVE_DATA_SECTIONS)
if(HAVE_DATA_SECTIONS)
message(STATUS "yes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections")
else()
message(STATUS "no")
endif()

message(STATUS "Checking whether compiler supports -ffunction-sections")
check_cxx_compiler_flag("-Werror -ffunction-sections" HAVE_FUNCTION_SECTIONS)
if(HAVE_FUNCTION_SECTIONS)
message(STATUS "yes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections")
else()
message(STATUS "no")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -Wwrite-strings -Werror=write-strings -fcheck-new -fsigned-char -fdata-sections -ffunction-sections -DNOMINMAX")
else()
set(CMAKE_CXX_FLAGS "/Zc:strictStrings")
endif()
set(CMAKE_FIND_FRAMEWORK "LAST")

add_definitions(-DTRUE_FALSE_DEFINED)

Expand Down
Loading
Loading