From b4b8ce08fe555c713dc64f77d092dad5e2b9b869 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 3 Mar 2022 12:50:44 +0000 Subject: [PATCH 1/2] Implements CMakePresets.json to simplify project config. 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. --- .github/workflows/linux.yml | 22 ++- .github/workflows/macos.yml | 14 +- .github/workflows/mingw.yml | 11 +- .github/workflows/windows.yml | 17 +- .gitignore | 3 + CMakeLists.txt | 40 +---- CMakePresets.json | 228 ++++++++++++++++++++++++ README.md | 44 +++-- common/CMakeLists.txt | 1 + resources/CMakeUserPresets.json.example | 39 ++++ tools/CMakeLists.txt | 1 - 11 files changed, 346 insertions(+), 74 deletions(-) create mode 100644 CMakePresets.json create mode 100644 resources/CMakeUserPresets.json.example diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1144f56b..abab59f7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -18,10 +18,12 @@ 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 @@ -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 @@ -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 @@ -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 + if: ${{ matrix.networking == 'net' }} uses: actions/upload-artifact@v3.1.2 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 @@ -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: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index ea5fbda1..e7cb2391 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -6,7 +6,11 @@ on: jobs: vanilla-macos: - runs-on: macos-12 + runs-on: macos-12 + strategy: + matrix: + networking: [net, nonet] + steps: - uses: actions/checkout@v3.3.0 with: @@ -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: | @@ -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 + if: ${{ matrix.networking == 'net' }} uses: actions/upload-artifact@v3.1.2 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 @@ -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: | diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index c9e889e1..9b450e18 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -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: | @@ -58,6 +58,7 @@ jobs: strategy: matrix: platform: [x86, amd64] + networking: [net, nonet] steps: - uses: actions/checkout@v3.3.0 @@ -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 @@ -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 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2c401a2e..dcd43265 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -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 @@ -78,6 +78,7 @@ jobs: strategy: matrix: platform: [x86, amd64] + networking: [net, nonet] steps: - uses: actions/checkout@v3.3.0 with: @@ -122,19 +123,20 @@ 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 @@ -142,13 +144,14 @@ jobs: 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 + if: ${{ matrix.networking == 'net' }} uses: actions/upload-artifact@v3.1.2 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 @@ -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: | diff --git a/.gitignore b/.gitignore index 0ec9e7f9..fe80d215 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /build* +/CMakeUserPresets.json +/.cache +/.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index be15b5f1..a7c8eec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..2290a57d --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,228 @@ +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "displayName": "Default Config", + "generator": "Ninja", + "hidden": true, + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "DSOUND": "OFF", + "DDRAW": "OFF", + "SDL2": "ON", + "OPENAL": "ON", + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "default-win", + "inherits": "default", + "displayName": "MSVC defaults", + "hidden": true, + "cacheVariables": { + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL", + "VC_CXX_FLAGS": "/Zc:strictStrings;-wd4244;-wd4018;-wd4291;-wd4101;-wd4267", + "CMAKE_CXX_FLAGS_RELEASE": "/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-net-tests", + "inherits": "cl-vanilla", + "displayName": "MSVC Vanilla build with tests", + "cacheVariables": { + "BUILD_TESTS": "ON" + } + }, + { + "name": "cl-vanilla-nonet-tests", + "inherits": "cl-vanilla-net-tests", + "displayName": "MSVC Vanilla build with tests and no networking", + "cacheVariables": { + "NETWORKING": "OFF" + } + }, + { + "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;-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-net-tests", + "inherits": "gcc-vanilla", + "displayName": "GCC Vanilla build with tests", + "cacheVariables": { + "BUILD_TESTS": "ON" + } + }, + { + "name": "gcc-vanilla-nonet-tests", + "inherits": "gcc-vanilla-net-tests", + "displayName": "GCC Vanilla build with tests", + "cacheVariables": { + "NETWORKING": "OFF" + } + }, + { + "name": "clang-vanilla", + "inherits": "default-unix", + "displayName": "Clang Vanilla build", + "environment": { + "CC": "clang", + "CXX": "clang++" + } + }, + { + "name": "clang-vanilla-net-tests", + "inherits": "clang-vanilla", + "displayName": "Clang Vanilla build with tests", + "cacheVariables": { + "BUILD_TESTS": "ON" + } + }, + { + "name": "clang-vanilla-nonet-tests", + "inherits": "clang-vanilla-net-tests", + "displayName": "Clang Vanilla build with tests", + "cacheVariables": { + "NETWORKING": "OFF" + } + }, + { + "name": "default-mingw", + "inherits": "default", + "hidden": true, + "displayName": "MinGW-w64 defaults", + "cacheVariables": { + "CMAKE_CXX_FLAGS_DEBUG": "-g -Og", + "CMAKE_C_FLAGS_DEBUG": "-g -Og", + "CMAKE_CXX_FLAGS_RELEASE": "-O3 -g -DNDEBUG", + "CMAKE_C_FLAGS_RELEASE": "-O3 -g -DNDEBUG", + "CMAKE_EXE_LINKER_FLAGS": "-static-libstdc++ -static-libgcc", + "CMAKE_SHARESD_LINKER_FLAGS": "-static-libstdc++ -static-libgcc", + "VC_CXX_FLAGS": "-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" + } + } + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 55d3a1e5..d55b6dce 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,14 @@ All of these rooms are bridged together so people can choose their preferred ser We support wide variety of compilers and platforms to target. Vanilla Conquer is known to compile with recent enough gcc, MSVC, mingw-w64 or clang and known to run on Windows, Linux, macOS and BSDs. +### Presets + +A [CMakePresets.json](CMakePresets.json) file is provided that contains presets for common build configurations and is used by our CI scripts to build the release builds. These presets require the [Ninja](https://ninja-build.org/) build tool to be available in the system PATH in order to be used. + +We also provide an example [CMakeUserPresets.json](resources/CMakeUserPresets.json.example) that can be copied to the root source directory and renamed. You can edit this file to create your own development presets that won't be included in git commits. A few example presets are provided which override the release presets to build a "debug" configuration. + +To build using a preset, add `--preset preset_name` to the CMake command line examples below. + ### Windows #### Requirements @@ -35,13 +43,11 @@ Extract SDL2 and OpenAL somewhere you know. If you are building only Remastered #### Building -In a VS command line window: +In a VS command line window in the Vanilla Conquer source directory: ```sh -mkdir build -cd build -cmake .. -DSDL2_ROOT_DIR=C:\path\to\SDL2 -DOPENAL_ROOT=C:\path\to\OpenAL -cmake --build . +cmake -DSDL2_ROOT_DIR=C:\path\to\SDL2 -DOPENAL_ROOT=C:\path\to\OpenAL -B build . +cmake --build build ``` This will build Vanilla Conquer executables in the build directory. If you are building Remastered dlls you need to configure cmake with `-A win32` and ensure your VS command line is x86. @@ -57,24 +63,38 @@ This will build Vanilla Conquer executables in the build directory. If you are b On Debian/Ubuntu you can install the build requirements as follows: +```sh +sudo apt update +sudo apt install g++ cmake libsdl2-dev libopenal-dev +or +sudo apt install g++ cmake libsdl1.2-dev libopenal-dev ``` -sudo apt-get update -sudo apt-get install g++ cmake libsdl2-dev libopenal-dev + +On Fedora/RedHat based system you can install the build requirements as follows: + +```sh +sudo dnf install gcc-c++ cmake SDL2-devel openal-soft-devel or -sudo apt-get install g++ cmake libsdl1.2-dev libopenal-dev +sudo dnf install gcc-c++ cmake SDL-devel openal-soft-devel ``` #### Building ```sh -mkdir build -cd build -cmake .. -make -j8 +cmake -B build . +cmake --build build ``` This will build Vanilla Conquer executables in the build directory. +#### macOS considerations + +To create a portable bundle for macOS we run [macdylibbundler](https://github.com/auriamg/macdylibbundler) in our CI builds as an extra step to add the SDL2 and OpenAL libraries to the bundle. If you wish to create a portable bundle yourself, you will need to do this step manually as CMake will not currently do it for you. + +### Icons + +CMake will attempt to generate icons in an appropriate format for Windows and macOS if ImageMagick is found in the system PATH. Otherwise you will end up with generic "program" icons. + ## Releases Binary releases of the latest commit are available from [here](https://github.com/TheAssemblyArmada/Vanilla-Conquer/releases/tag/latest), which is updated whenever new code is merged into the main branch. diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 03cd6e3e..14599075 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -169,6 +169,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 $<$:_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) diff --git a/resources/CMakeUserPresets.json.example b/resources/CMakeUserPresets.json.example new file mode 100644 index 00000000..7ae9d703 --- /dev/null +++ b/resources/CMakeUserPresets.json.example @@ -0,0 +1,39 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "gcc-vanilla-debug", + "inherits": "gcc-vanilla", + "displayName": "GCC Vanilla debug build", + "binaryDir": "${sourceDir}/build_gcc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "clang-vanilla-debug", + "inherits": "clang-vanilla", + "displayName": "Clang Vanilla debug build", + "binaryDir": "${sourceDir}/build_clang", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "mingw-i686-vanilla-debug", + "inherits": "mingw-i686-vanilla", + "displayName": "MinGW-w64 32bit Vanilla debug build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "mingw-x86_64-vanilla-debug", + "inherits": "mingw-x86_64-vanilla", + "displayName": "MinGW-w64 64bit Vanilla debug build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 23e72463..438f64da 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,4 @@ if (BUILD_TOOLS) - enable_language(C) # For miniposix. add_subdirectory(miniposix) add_subdirectory(mixtool) endif() From d867dc4c77337eb3ccdef3ec5bb0cc3141f07b23 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 13 Jun 2024 15:17:44 +0100 Subject: [PATCH 2/2] Update deprecated github actions --- .github/workflows/linux.yml | 4 ++-- .github/workflows/macos.yml | 4 ++-- .github/workflows/mingw.yml | 14 ++++++++------ .github/workflows/windows.yml | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index abab59f7..efa2369a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,7 +26,7 @@ jobs: os: [ubuntu-22.04] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 0 @@ -93,7 +93,7 @@ jobs: - name: Upload artifact if: ${{ matrix.networking == 'net' }} - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: name: vanilla-conquer-linux-${{ matrix.platform }}-${{ matrix.os }}-x86_64 path: artifact diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e7cb2391..f1e706c4 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,7 +12,7 @@ jobs: networking: [net, nonet] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 0 @@ -88,7 +88,7 @@ jobs: - name: Upload artifact if: ${{ matrix.networking == 'net' }} - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: name: vanilla-conquer-macos-clang-universal2 path: artifact diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 9b450e18..e91433f5 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -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 @@ -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 @@ -61,7 +61,7 @@ jobs: networking: [net, nonet] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 0 @@ -111,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/upload-artifact@v3.1.2 + 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 @@ -135,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: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index dcd43265..fa676ac7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -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 @@ -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 @@ -80,7 +80,7 @@ jobs: platform: [x86, amd64] networking: [net, nonet] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 0 @@ -145,7 +145,7 @@ jobs: - name: Upload artifact if: ${{ matrix.networking == 'net' }} - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: name: vanilla-conquer-win-msvc-${{ steps.vars.outputs.arc_path }} path: artifact