From d924440a65b4a49d8b48bf173121cefcad67ab14 Mon Sep 17 00:00:00 2001 From: Pradeep Garigipati Date: Mon, 25 Mar 2024 19:27:22 +0530 Subject: [PATCH] Update CMake presets and use newer vcpkg baseline and other CI updates (#247) * Update CMake presets and use newer vcpkg baseline * Update main branch name in github workflows * Update cmake version in project and fix boost name in vcpkg manifest * Update all CI jobs to be simple and use new versions --- .github/workflows/clang-format-lint.yml | 12 +++---- .github/workflows/unix_build.yml | 18 +++++----- .github/workflows/windows_build.yml | 42 ++++-------------------- .gitignore | 2 ++ CMakeLists.txt | 2 +- CMakePresets.json | 28 ++++++++++++---- examples/CMakeLists.txt | 2 +- src/backend/common/chart_renderables.hpp | 8 ++--- src/backend/common/util.cpp | 2 +- src/backend/opengl/gl_helpers.cpp | 2 +- vcpkg/vcpkg.json => vcpkg.json | 3 +- 11 files changed, 53 insertions(+), 68 deletions(-) rename vcpkg/vcpkg.json => vcpkg.json (71%) diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 5b5dbdf2..e3b6e213 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -1,10 +1,10 @@ on: push: branches: - - master + - main pull_request: branches: - - master + - main name: ci @@ -17,15 +17,15 @@ jobs: uses: actions/checkout@master - name: Check Sources - uses: DoozyX/clang-format-lint-action@v0.11 + uses: DoozyX/clang-format-lint-action@v0.17 with: source: './src' extensions: 'h,cpp,hpp' - clangFormatVersion: 11 + clangFormatVersion: 17 - name: Check Examples - uses: DoozyX/clang-format-lint-action@v0.11 + uses: DoozyX/clang-format-lint-action@v0.17 with: source: './examples' extensions: 'h,cpp,hpp' - clangFormatVersion: 11 + clangFormatVersion: 17 diff --git a/.github/workflows/unix_build.yml b/.github/workflows/unix_build.yml index dcb44d6b..c673ae7f 100644 --- a/.github/workflows/unix_build.yml +++ b/.github/workflows/unix_build.yml @@ -1,10 +1,10 @@ on: push: branches: - - master + - main pull_request: branches: - - master + - main name: ci @@ -13,18 +13,18 @@ jobs: name: OpenGL runs-on: ${{ matrix.os }} env: - CMAKE_VER: 3.5.1 + CMAKE_VER: 3.16.3 strategy: fail-fast: false matrix: window_toolkit: [glfw3, sdl2] - os: [ubuntu-18.04, macos-latest] + os: [ubuntu-latest, macos-latest] steps: - name: Checkout Repository uses: actions/checkout@master - - name: Download CMake 3.5.1 for Linux + - name: Download CMake for Linux if: matrix.os != 'macos-latest' env: OS_NAME: ${{ matrix.os }} @@ -48,7 +48,7 @@ jobs: echo "CMAKE_PROGRAM=cmake" >> $GITHUB_ENV - name: Install Common Dependencies for Ubuntu - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-18.04' + if: matrix.os == 'ubuntu-latest' run: | sudo add-apt-repository ppa:mhier/libboost-latest sudo apt-get -qq update @@ -66,7 +66,7 @@ jobs: brew install $pkg - name: Install Linux Window Toolkit - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-18.04' + if: matrix.os == 'ubuntu-latest' env: FG_TOOLKIT: ${{ matrix.window_toolkit }} run: | @@ -79,9 +79,7 @@ jobs: FG_TOOLKIT: ${{ matrix.window_toolkit }} run: | mkdir build && cd build - ${CMAKE_PROGRAM} -DCMAKE_C_COMPILER=gcc-6 \ - -DCMAKE_CXX_COMPILER=g++-6 \ - -DFG_USE_WINDOW_TOOLKIT:STRING=${FG_TOOLKIT} .. + ${CMAKE_PROGRAM} -DFG_USE_WINDOW_TOOLKIT:STRING=${FG_TOOLKIT} .. - name: CMake Configure on OSX if: matrix.os == 'macos-latest' diff --git a/.github/workflows/windows_build.yml b/.github/workflows/windows_build.yml index 243141a2..1b2ca923 100644 --- a/.github/workflows/windows_build.yml +++ b/.github/workflows/windows_build.yml @@ -1,59 +1,30 @@ on: push: branches: - - master + - main tags: - 'v*' pull_request: branches: - - master + - main name: ci jobs: build_opengl_backend: name: OpenGL - runs-on: ${{ matrix.os }} - env: - FREEIMAGE_VER: 3.18.0 - FREEIMAGE_VER_STR: 3180 strategy: fail-fast: false matrix: window_toolkit: [glfw3, sdl2] os: [windows-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout Repository uses: actions/checkout@master - - name: FreeImage Cache - uses: actions/cache@v1 - id: freeimage-cache - with: - path: freeimage - key: freeimage-${{ env.FREEIMAGE_VER }} - - - name: FreeImage Download - if: steps.freeimage-cache.outputs.cache-hit != 'true' - run: | - $url = 'https://nchc.dl.sourceforge.net/project/freeimage/Binary%20Distribution/{0}/FreeImage{1}Win32Win64.zip' -f $env:FREEIMAGE_VER, $env:FREEIMAGE_VER_STR - Invoke-WebRequest -Uri $url -OutFile freeimage.zip - Expand-Archive .\freeimage.zip -DestinationPath .\ - Remove-Item -Path .\freeimage.zip - - - name: Install Common Dependencies - run: | - $vcpkg_triplet_path = $env:GITHUB_WORKSPACE + "/CMakeModules/ForgeFreetypeVCPKGTriplet.cmake" - Copy-Item -Path $vcpkg_triplet_path -Destination C:/vcpkg/triplets/x64-windows.cmake - vcpkg install --triplet x64-windows boost-functional freetype opencl - - - name: Install GLFW3 - if: matrix.window_toolkit == 'glfw3' - run: vcpkg install glfw3:x64-windows - - - name: Install SDL2 - if: matrix.window_toolkit == 'sdl2' - run: vcpkg install sdl2:x64-windows + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 - name: Configure and Build env: @@ -61,8 +32,7 @@ jobs: run: | mkdir build && cd build cmake ` - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=C:\vcpkg\scripts\buildsystems\vcpkg.cmake ` - -DFreeImage_ROOT:PATH=..\freeimage\Dist\x64 ` + -DCMAKE_TOOLCHAIN_FILE:FILEPATH="${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake" ` -DFG_USE_WINDOW_TOOLKIT:STRING=$Env:FG_TOOLKIT .. cmake --build . --parallel --target ALL_BUILD --config Release cmake --build . --parallel --target INSTALL --config Release diff --git a/.gitignore b/.gitignore index 4fdd2dcf..c33d36f1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ GPATH include/fg/version.h src/backend/common/version.hpp docs/details/examples.dox +.vs/ +CMakeUserPresets.CMake diff --git a/CMakeLists.txt b/CMakeLists.txt index de1a80ec..1aa2e21e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16.3) project(Forge VERSION 1.1.0 LANGUAGES C CXX) diff --git a/CMakePresets.json b/CMakePresets.json index fbc3bf80..2ff0b681 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,9 +1,9 @@ { - "version": 2, + "version": 6, "cmakeMinimumRequired": { "major": 3, - "minor": 20, - "patch": 0 + "minor": 28, + "patch": 4 }, "configurePresets": [ { @@ -11,6 +11,11 @@ "description": "Forge build with OpenGL backend using GLFW in Debug configuration", "binaryDir": "${sourceDir}/build/${presetName}", "generator": "Ninja", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, "cacheVariables": { "CMAKE_BUILD_TYPE": { "type": "String", @@ -76,12 +81,21 @@ } }, { - "name": "msvc2019-gl-glfw3", + "name": "msvc-gl-glfw3", "description": "Forge build with OpenGL backend using GLFW", "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Visual Studio 16 2019", + "generator": "Visual Studio 17 2022", "architecture": "x64", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "PATH", + "value": "%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" + }, "FG_RENDERING_BACKEND": { "type": "String", "value": "OpenGL" @@ -109,9 +123,9 @@ } }, { - "name": "msvc2019-gl-sdl2", + "name": "msvc-gl-sdl2", "description": "Forge build with OpenGL backend using SDL", - "inherits": "msvc2019-gl-glfw3", + "inherits": "msvc-gl-glfw3", "cacheVariables": { "FG_USE_WINDOW_TOOLKIT": "sdl2" } diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1d4ff4d6..8b3b58be 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16.3) project(Forge-Examples LANGUAGES CXX) diff --git a/src/backend/common/chart_renderables.hpp b/src/backend/common/chart_renderables.hpp index c97b8c5b..fb059d3c 100644 --- a/src/backend/common/chart_renderables.hpp +++ b/src/backend/common/chart_renderables.hpp @@ -29,7 +29,7 @@ class Histogram : public ChartRenderableBase { Histogram(const fg_histogram pOther) : ChartRenderableBase( - reinterpret_cast(pOther)->impl()) {} + reinterpret_cast(pOther)->impl()) {} }; class Plot : public ChartRenderableBase { @@ -48,7 +48,7 @@ class Plot : public ChartRenderableBase { Plot(const fg_plot pOther) : ChartRenderableBase( - reinterpret_cast(pOther)->impl()) {} + reinterpret_cast(pOther)->impl()) {} inline void setMarkerSize(const float pMarkerSize) { mShrdPtr->setMarkerSize(pMarkerSize); @@ -82,7 +82,7 @@ class Surface : public ChartRenderableBase { Surface(const fg_surface pOther) : ChartRenderableBase( - reinterpret_cast(pOther)->impl()) {} + reinterpret_cast(pOther)->impl()) {} }; class VectorField : public ChartRenderableBase { @@ -100,7 +100,7 @@ class VectorField : public ChartRenderableBase { VectorField(const fg_vector_field pOther) : ChartRenderableBase( - reinterpret_cast(pOther)->impl()) {} + reinterpret_cast(pOther)->impl()) {} inline unsigned dbo() const { return mShrdPtr->directions(); } diff --git a/src/backend/common/util.cpp b/src/backend/common/util.cpp index 2945f808..ef0de64a 100644 --- a/src/backend/common/util.cpp +++ b/src/backend/common/util.cpp @@ -153,7 +153,7 @@ pair calcRotationFromArcBall(const vec2& lastPos, auto project = [](const float pX, const float pY, const float pWidth, const float pHeight) { glm::vec3 P = glm::vec3((2.0f * pX) / pWidth - 1.0f, - (2.0f * pY) / pHeight - 1.0f, 0.0f); + (2.0f * pY) / pHeight - 1.0f, 0.0f); float xySqrdSum = P.x * P.x + P.y * P.y; float rSqrd = (ARC_BALL_RADIUS * ARC_BALL_RADIUS); float rSqrdBy2 = rSqrd / 2.0f; diff --git a/src/backend/opengl/gl_helpers.cpp b/src/backend/opengl/gl_helpers.cpp index b152c642..da040ca7 100644 --- a/src/backend/opengl/gl_helpers.cpp +++ b/src/backend/opengl/gl_helpers.cpp @@ -94,7 +94,7 @@ GLuint screenQuadVAO(const int pWindowId) { if (svaoMap.find(pWindowId) == svaoMap.end()) { static const float texcords[8] = {0.0, 1.0, 1.0, 1.0, - 1.0, 0.0, 0.0, 0.0}; + 1.0, 0.0, 0.0, 0.0}; static const uint32_t indices[6] = {0, 1, 2, 0, 2, 3}; GLuint tbo = createBuffer(GL_ARRAY_BUFFER, 8, texcords, GL_STATIC_DRAW); diff --git a/vcpkg/vcpkg.json b/vcpkg.json similarity index 71% rename from vcpkg/vcpkg.json rename to vcpkg.json index e9322b6e..8319bb47 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg.json @@ -2,8 +2,9 @@ "name": "forge", "version": "1.1.0", "supports": "x64", + "builtin-baseline": "898b728edc5e0d12b50015f9cd18247c4257a3eb", "dependencies": [ - "boost-functional", + "boost-container-hash", "freetype", "freeimage", {