Skip to content

Commit

Permalink
Implements CMakePresets.json to simplify project config.
Browse files Browse the repository at this point in the history
Adds presets covering CI builds and generating MSVC solutions.
Updates CI to use presets.
Adds Ubuntu 20.04 to CI checks.
Moves compiler configuration to presets.
Adds example for CMakeUserPresets.json for users to copy for custom
local presets.
  • Loading branch information
OmniBlade committed Mar 3, 2022
1 parent 884428f commit b36ecfe
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 34 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
title: "Development Build"

vanilla-linux:
runs-on: ubuntu-18.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
platform: [clang, gcc]
os: [ubuntu-18.04, ubuntu-20.04]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -49,14 +50,14 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq > /dev/null
sudo apt-get install -qq -y clang-format-10 libsdl2-dev libopenal-dev > /dev/null
sudo apt-get install -qq -y clang-format-10 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-tests
- name: Check formatting
if: ${{ matrix.platform }} == clang
Expand All @@ -66,7 +67,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 @@ -85,13 +86,13 @@ jobs:
- name: Create archives
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/upload-artifact@v2
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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down Expand Up @@ -85,7 +85,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 +94,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 -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 Down
14 changes: 7 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- uses: ilammy/msvc-dev-cmd@v1.4.1
- uses: ilammy/msvc-dev-cmd@v1.10.0
with:
arch: x86

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 Down Expand Up @@ -85,7 +85,7 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- uses: ilammy/msvc-dev-cmd@v1.4.1
- uses: ilammy/msvc-dev-cmd@v1.10.0
with:
arch: ${{ matrix.platform }}

Expand Down Expand Up @@ -123,17 +123,17 @@ 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_convert_EXECUTABLE=C:\Program Files\ImageMagick-7.0.10-Q16-HDRI\magick.exe" -DImageMagick_convert_FOUND=TRUE -B build
cmake --preset cl-vanilla-tests "-DSDL2_ROOT_DIR=$($Env:TEMP)\SDL2-2.0.12" "-DOPENAL_ROOT=C:\Program Files (x86)\OpenAL 1.1 SDK" "-DImageMagick_convert_EXECUTABLE=C:\Program Files\ImageMagick-7.0.10-Q16-HDRI\magick.exe" -DImageMagick_convert_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
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build*
/CMakeUserPresets.json
16 changes: 1 addition & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include(FeatureSummary)

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)
Expand Down Expand Up @@ -51,20 +51,6 @@ 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")
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()

add_definitions(-DENGLISH -DTRUE_FALSE_DEFINED)

if(WIN32)
Expand Down
200 changes: 200 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"generator": "Ninja",
"hidden": true,
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"DSOUND": "OFF",
"DDRAW": "OFF",
"SDL2": "ON",
"OPENAL": "ON",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "default-win",
"inherits": "default",
"displayName": "MSVC defaults",
"hidden": true,
"cacheVariables": {
"VC_CXX_FLAGS": "/Zc:strictStrings",
"CMAKE_CXX_FLAGS_RELEASE": "/MD /Zi /O2 /Ob2 /DNDEBUG",
"CMAKE_EXE_LINKER_FLAGS_RELEASE": "/debug:full /INCREMENTAL:NO",
"CMAKE_MODULE_LINKER_FLAGS_RELEASE": "/debug:full /INCREMENTAL:NO",
"CMAKE_SHARED_LINKER_FLAGS_RELEASE": "/debug:full /INCREMENTAL:NO"
}
},
{
"name": "cl-remaster",
"inherits": "default-win",
"displayName": "MSVC Remaster build",
"cacheVariables": {
"BUILD_REMASTERTD": "ON",
"BUILD_REMASTERRA": "ON",
"BUILD_VANILLATD": "OFF",
"BUILD_VANILLARA": "OFF",
"MAP_EDITORTD": "OFF",
"MAP_EDITORRA": "OFF",
"BUILD_TOOLS": "OFF"
}
},
{
"name": "cl-vanilla",
"inherits": "default-win",
"displayName": "MSVC Vanilla build",
"cacheVariables": {
"BUILD_REMASTERTD": "OFF",
"BUILD_REMASTERRA": "OFF",
"MAP_EDITORTD": "ON",
"MAP_EDITORRA": "ON",
"BUILD_TOOLS": "ON"
}
},
{
"name": "cl-vanilla-tests",
"inherits": "cl-vanilla",
"displayName": "MSVC Vanilla build with tests",
"cacheVariables": {
"BUILD_TEST": "ON"
}
},
{
"name": "msvc2019-i686-remaster",
"inherits": "cl-remaster",
"binaryDir": "${sourceDir}/build_remaster",
"displayName": "MSVC 2019 32bit Remaster build",
"generator": "Visual Studio 16 2019",
"architecture": "Win32"
},
{
"name": "msvc2019-i686-vanilla",
"inherits": "cl-vanilla",
"binaryDir": "${sourceDir}/build_msvc32",
"displayName": "MSVC 2019 32bit Vanilla build",
"generator": "Visual Studio 16 2019",
"architecture": "Win32"
},
{
"name": "msvc2019-x86-64-vanilla",
"inherits": "cl-vanilla",
"binaryDir": "${sourceDir}/build_msvc64",
"displayName": "MSVC 2019 64bit Vanilla build",
"architecture": "x64"
},
{
"name": "default-unix",
"inherits": "default",
"hidden": true,
"displayName": "UNIX defaults",
"cacheVariables": {
"CMAKE_CXX_FLAGS_DEBUG": "-g3 -Og",
"CMAKE_C_FLAGS_DEBUG": "-g3 -Og",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -g3 -DNDEBUG",
"CMAKE_C_FLAGS_RELEASE": "-O3 -g3 -DNDEBUG",
"VC_CXX_FLAGS": "-w;-Wwrite-strings;-Werror=write-strings;-fcheck-new;-fsigned-char;-DNOMINMAX",
"MAP_EDITORTD": "ON",
"MAP_EDITORRA": "ON",
"BUILD_TOOLS": "ON"
}
},
{
"name": "gcc-vanilla",
"inherits": "default-unix",
"displayName": "GCC Vanilla build",
"environment": {
"CC": "gcc",
"CXX": "g++"
}
},
{
"name": "gcc-vanilla-tests",
"inherits": "gcc-vanilla",
"displayName": "GCC Vanilla build with tests",
"cacheVariables": {
"BUILD_TEST": "ON"
}
},
{
"name": "clang-vanilla",
"inherits": "default-unix",
"displayName": "Clang Vanilla build",
"environment": {
"CC": "clang",
"CXX": "clang++"
}
},
{
"name": "clang-vanilla-tests",
"inherits": "clang-vanilla",
"displayName": "Clang Vanilla build with tests",
"cacheVariables": {
"BUILD_TEST": "ON"
}
},
{
"name": "default-mingw",
"inherits": "default",
"hidden": true,
"displayName": "MinGW-w64 defaults",
"cacheVariables": {
"CMAKE_CXX_FLAGS_DEBUG": "-gstabs3 -Og",
"CMAKE_C_FLAGS_DEBUG": "-gstabs3 -Og",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -gstabs3 -DNDEBUG",
"CMAKE_C_FLAGS_RELEASE": "-O3 -gstabs3 -DNDEBUG",
"VC_CXX_FLAGS": "-static-libstdc++;-static-libgcc;-fpermissive;-w;-Wwrite-strings;-Werror=write-strings;-fcheck-new;-fsigned-char;-DNOMINMAX",
"MAP_EDITORTD": "ON",
"MAP_EDITORRA": "ON",
"BUILD_TOOLS": "ON"
}
},
{
"name": "mingw-i686-remaster",
"inherits": "default-mingw",
"displayName": "MinGW-w64 32bit Remaster build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "${sourceDir}/cmake/i686-mingw-w64-toolchain.cmake"
},
"BUILD_REMASTERTD": "ON",
"BUILD_REMASTERRA": "ON",
"BUILD_VANILLATD": "OFF",
"BUILD_VANILLARA": "OFF",
"MAP_EDITORTD": "OFF",
"MAP_EDITORRA": "OFF",
"BUILD_TOOLS": "OFF"
}
},
{
"name": "mingw-i686-vanilla",
"inherits": "default-mingw",
"displayName": "MinGW-w64 32bit Vanilla build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "${sourceDir}/cmake/i686-mingw-w64-toolchain.cmake"
}
}
},
{
"name": "mingw-x86_64-vanilla",
"inherits": "default-mingw",
"displayName": "MinGW-w64 64bit Vanilla build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "${sourceDir}/cmake/x86_64-mingw-w64-toolchain.cmake"
}
}
}
]
}
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ add_library(common STATIC ${COMMON_SRC} ${COMMON_HEADERS})
target_link_libraries(common PUBLIC ${COMMON_LIBS})
target_include_directories(common PUBLIC .)
target_compile_definitions(common PRIVATE FIXIT_FAST_LOAD $<$<CONFIG:Debug>:_DEBUG>)
target_compile_options(common PUBLIC ${VC_CXX_FLAGS})
# Make build check state of git to check for uncommitted changes.
add_dependencies(common check_git)

Expand Down
Loading

0 comments on commit b36ecfe

Please sign in to comment.