From c7a4dde1deb8bb43f2be9c027e475944bfdcd43c Mon Sep 17 00:00:00 2001 From: McMassiveNZ <12842622+McMassiveNZ@users.noreply.github.com> Date: Sun, 28 May 2023 21:58:29 +0200 Subject: [PATCH] Update to match window-starter template --- scripts/.clang-tidy => .clang-tidy | 0 .github/workflows/ci.yml | 33 ++----------------- .gitmodules | 3 -- CMakeLists.txt | 7 +--- .../cmake => cmake}/compilerwarnings.cmake | 0 cmake/cpm.cmake | 33 +++++++++++++++++++ cmake/googletest.cmake | 18 ++++++++++ {scripts/cmake => cmake}/precompiled.cmake | 0 {scripts/cmake => cmake}/sanitizers.cmake | 0 {scripts/cmake => cmake}/staticanalysis.cmake | 0 external/vcpkg | 1 - scripts/cmake/googletest.cmake | 18 ---------- test/CMakeLists.txt | 14 -------- test/test_main.cpp | 6 ---- 14 files changed, 55 insertions(+), 78 deletions(-) rename scripts/.clang-tidy => .clang-tidy (100%) delete mode 100644 .gitmodules rename {scripts/cmake => cmake}/compilerwarnings.cmake (100%) create mode 100644 cmake/cpm.cmake create mode 100644 cmake/googletest.cmake rename {scripts/cmake => cmake}/precompiled.cmake (100%) rename {scripts/cmake => cmake}/sanitizers.cmake (100%) rename {scripts/cmake => cmake}/staticanalysis.cmake (100%) delete mode 160000 external/vcpkg delete mode 100644 scripts/cmake/googletest.cmake delete mode 100644 test/CMakeLists.txt delete mode 100644 test/test_main.cpp diff --git a/scripts/.clang-tidy b/.clang-tidy similarity index 100% rename from scripts/.clang-tidy rename to .clang-tidy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3738a6c..acc32fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,46 +18,38 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] build_configuration: [Debug, Release] compiler: [llvm, gcc] - vcpkg_bootstrap: [bootstrap-vcpkg.sh] exclude: - os: windows-latest - vcpkg_bootstrap: bootstrap-vcpkg.sh include: - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: llvm build_configuration: Debug - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: llvm build_configuration: Release - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: gcc build_configuration: Debug - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: gcc build_configuration: Release - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: msvc build_configuration: Debug - os: 'windows-latest' triplet: x64-windows - vcpkg_bootstrap: bootstrap-vcpkg.bat compiler: msvc build_configuration: Release @@ -70,22 +62,12 @@ jobs: steps: - name: checkout uses: actions/checkout@v3 - with: - submodules: true - name: cache uses: actions/cache@v3 with: - path: | - ~/vcpkg - ./build/vcpkg_installed - ${{ env.HOME }}/.cache/vcpkg/archives - ${{ env.XDG_CACHE_HOME }}/vcpkg/archives - ${{ env.LOCALAPPDATA }}\vcpkg\archives - ${{ env.APPDATA }}\vcpkg\archives - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.build_configuration }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}} - restore-keys: | - ${{ runner.os }}-${{ matrix.build_configuration }}- + path: "**/cpm_modules" + key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} - name: setup dependencies uses: aminya/setup-cpp@v1 @@ -93,20 +75,11 @@ jobs: compiler: ${{ matrix.compiler }} vcvarsall: ${{ contains(matrix.os, 'windows')}} cmake: true - vcpkg: true ccache: true clangtidy: ${{ env.CLANG_TIDY_VERSION }} - cppcheck: true - - - name: Boostrap Vcpkg - run: ${{github.workspace}}/external/vcpkg/${{matrix.vcpkg_bootstrap}} -disableMetrics - - - name: Install packaged dependencies - run: ${{github.workspace}}/external/vcpkg/vcpkg install spdlog --triplet ${{matrix.triplet}} - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_configuration}} - -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/external/vcpkg/scripts/buildsystems/vcpkg.cmake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_configuration}} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_configuration}} diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index cda8672..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "external/vcpkg"] - path = external/vcpkg - url = https://github.com/Microsoft/vcpkg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1095418..459fca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,11 +18,6 @@ set(CMAKE_SCRIPTS_DIR ${CMAKE_CURRENT_LIST_DIR}/scripts/cmake) include(${CMAKE_SCRIPTS_DIR}/compilerwarnings.cmake) include(${CMAKE_SCRIPTS_DIR}/sanitizers.cmake) include(${CMAKE_SCRIPTS_DIR}/staticanalysis.cmake) - -if (ENABLE_TESTS) - message("-- Unit Testing Enabled") - enable_testing() - add_subdirectory(test) -endif() +include(${CMAKE_SCRIPTS_DIR}/cpm.cmake) add_subdirectory(src) diff --git a/scripts/cmake/compilerwarnings.cmake b/cmake/compilerwarnings.cmake similarity index 100% rename from scripts/cmake/compilerwarnings.cmake rename to cmake/compilerwarnings.cmake diff --git a/cmake/cpm.cmake b/cmake/cpm.cmake new file mode 100644 index 0000000..a3086b7 --- /dev/null +++ b/cmake/cpm.cmake @@ -0,0 +1,33 @@ +set(CPM_DOWNLOAD_VERSION 0.38.1) + +if(CPM_SOURCE_CACHE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +# Expand relative path. This is important if the provided path contains a tilde (~) +get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) + +function(download_cpm) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endfunction() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + download_cpm() +else() + # resume download if it previously failed + file(READ ${CPM_DOWNLOAD_LOCATION} check) + if("${check}" STREQUAL "") + download_cpm() + endif() + unset(check) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/googletest.cmake b/cmake/googletest.cmake new file mode 100644 index 0000000..1a971fe --- /dev/null +++ b/cmake/googletest.cmake @@ -0,0 +1,18 @@ +include_guard() + +CPMAddPackage( + NAME googletest + GITHUB_REPOSITORY google/googletest + GIT_TAG v1.13.0 + VERSION 1.13.0 + OPTIONS + "INSTALL_GTEST OFF" + "gtest_force_shared_crt ON" +) + +set_property(TARGET + gtest + gtest_main + gmock + gmock_main + PROPERTY FOLDER third_party/GoogleTest) diff --git a/scripts/cmake/precompiled.cmake b/cmake/precompiled.cmake similarity index 100% rename from scripts/cmake/precompiled.cmake rename to cmake/precompiled.cmake diff --git a/scripts/cmake/sanitizers.cmake b/cmake/sanitizers.cmake similarity index 100% rename from scripts/cmake/sanitizers.cmake rename to cmake/sanitizers.cmake diff --git a/scripts/cmake/staticanalysis.cmake b/cmake/staticanalysis.cmake similarity index 100% rename from scripts/cmake/staticanalysis.cmake rename to cmake/staticanalysis.cmake diff --git a/external/vcpkg b/external/vcpkg deleted file mode 160000 index af031ae..0000000 --- a/external/vcpkg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit af031ae388730db1cf6d1d7b3752c74209d7bbe1 diff --git a/scripts/cmake/googletest.cmake b/scripts/cmake/googletest.cmake deleted file mode 100644 index 29379ff..0000000 --- a/scripts/cmake/googletest.cmake +++ /dev/null @@ -1,18 +0,0 @@ -include_guard() - -include(FetchContent) -FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # release-1.12.1 -) -# For Windows: Prevent overriding the parent project's compiler/linker settings -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) - -set_property(TARGET - gtest - gtest_main - gmock - gmock_main - PROPERTY FOLDER GoogleTest) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 19d9dc9..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -include(${CMAKE_SCRIPTS_DIR}/googletest.cmake) - -add_executable( - opengl-starter-test - test_main.cpp -) - -target_link_libraries( - opengl-starter-test - gtest_main -) - -include(GoogleTest) -gtest_discover_tests(opengl-starter-test) diff --git a/test/test_main.cpp b/test/test_main.cpp deleted file mode 100644 index d46382c..0000000 --- a/test/test_main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -TEST(testmain, example) -{ - EXPECT_EQ(42, 7*6); -} \ No newline at end of file