Skip to content

Commit

Permalink
Use windowsToolchain and workflow preset on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausKlein committed Oct 15, 2024
1 parent e7da20e commit f6352f0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
67 changes: 35 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,39 +207,42 @@ jobs:
Add-Content "$env:GITHUB_ENV" 'EnforceProcessCountAcrossBuilds=true'
- name: Configure preset
if: matrix.os != 'windows-2022'
shell: pwsh
run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])"
-D BUILD_SHARED_LIBS=${{ matrix.shared }}

- name: Configure on windows
if: matrix.os == 'windows-2022'
shell: pwsh
run: cmake -G "Visual Studio 17 2022" -S . -B build -D CMAKE_BUILD_TYPE=Release
-D CMAKE_INSTALL_PREFIX=$(Get-Location)/stagedir -D BUILD_SHARED_LIBS=${{ matrix.shared }}

- name: Setup PATH
if: matrix.os == 'windows-2022' && matrix.type == 'shared'
run: Add-Content "$env:GITHUB_PATH" "$(Get-Location)\build\Release"

- name: Build
run: cmake --build build --config Release -j 2

- name: Install
run: cmake --install build --config Release --prefix stagedir

- name: Test
working-directory: build
run: ctest --output-on-failure --no-tests=error -C Release -j 2

- name: TestInstalledVersion
if: matrix.os != 'windows-2022'
# if: matrix.os != 'windows-2022'
shell: bash
run: |
cmake -B example/build -S example -G Ninja -D CMAKE_BUILD_TYPE=Release \
-D "CMAKE_PREFIX_PATH=$PWD/stagedir;$PWD/conan" \
# --toolchain "$PWD/conan/conan_toolchain.cmake"
ninja -C example/build
ninja -C example/build test
export hostSystemName=$("${{ matrix.os }}".split("-")[0])
uname || echo ${hostSystemName}
perl -p -e "s/<hostSystemName>/${hostSystemName}/g;" .CMakeUserPresets.json > CMakeUserPresets.json
cmake --workflow --preset=dev # XXX "--preset=ci-$("${{ matrix.os }}".split("-")[0])"
# - name: Configure on windows
# if: matrix.os == 'windows-2022'
# shell: pwsh
# run: cmake -G "Visual Studio 17 2022" -S . -B build -D CMAKE_BUILD_TYPE=Release
# -D CMAKE_INSTALL_PREFIX=$(Get-Location)/stagedir -D BUILD_SHARED_LIBS=${{ matrix.shared }}

# - name: Setup PATH
# if: matrix.os == 'windows-2022' && matrix.type == 'shared'
# run: Add-Content "$env:GITHUB_PATH" "$(Get-Location)\build\Release"

# - name: Build
# run: cmake --build build --config Release -j 2

# - name: Install
# run: cmake --install build --config Release --prefix stagedir

# - name: Test
# working-directory: build
# run: ctest --output-on-failure --no-tests=error -C Release -j 2

# - name: TestInstalledVersion
# if: matrix.os != 'windows-2022'
# run: |
# cmake -B example/build -S example -G Ninja -D CMAKE_BUILD_TYPE=Release \
# -D "CMAKE_PREFIX_PATH=$PWD/stagedir;$PWD/conan" \
# # --toolchain "$PWD/conan/conan_toolchain.cmake"
# ninja -C example/build
# ninja -C example/build test

docs:
# Deploy docs only when builds succeed
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cmake/WindowsToolchain"]
path = cmake/WindowsToolchain
url = https://github.com/MarkSchofield/WindowsToolchain.git
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ endif()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)

include(cmake/CPM.cmake)

if(PROJECT_IS_TOP_LEVEL)
include(cmake/AddUninstallTarget.cmake)
include(cmake/lint-targets.cmake)
Expand All @@ -37,6 +35,7 @@ endmacro()
#########################################################################
# cmake-format: off

# include(cmake/CPM.cmake)
# instead of find_package(fmt REQUIRED)
# cpmaddpackage(
# NAME fmt
Expand All @@ -59,8 +58,6 @@ target_sources(Algo
FILES
algo-interface.cppm
)
# TODO(CK): target_link_libraries(Algo PRIVATE fmt::fmt)
# target_link_libraries(Algo PRIVATE $<BUILD_INTERFACE:fmt::fmt-header-only>)

# CMake requires the language standard to be specified as compile feature
# when a target provides C++23 modules and the target will be installed
Expand All @@ -69,7 +66,6 @@ target_compile_features(Algo PUBLIC cxx_std_23)
include(GenerateExportHeader)
generate_export_header(Algo
CUSTOM_CONTENT_FROM_VARIABLE
# XXX pragma_suppress_c4251
)
target_sources(Algo
PUBLIC
Expand Down
17 changes: 12 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"hidden": true,
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo;Release;Debug",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/conan/conan_toolchain.cmake",
"CMAKE_POLICY_DEFAULT_CMP0091": "NEW"
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/conan/conan_toolchain.cmake"
}
},
{
Expand Down Expand Up @@ -114,6 +113,7 @@
{
"name": "ci-linux",
"generator": "Ninja",
"description": "This build is only available on Linux",
"hidden": true,
"inherits": [
"flags-linux",
Expand All @@ -126,6 +126,7 @@
{
"name": "ci-darwin",
"generator": "Ninja",
"description": "This build is only available on Darwin",
"hidden": true,
"inherits": [
"flags-darwin",
Expand All @@ -140,11 +141,14 @@
"inherits": [
"ci-std"
],
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"toolchainFile": "cmake/WindowsToolchain/Windows.MSVC.toolchain.cmake",
"generator": "Ninja Multi-Config",
"description": "This build is only available on Windows",
"hidden": true,
"architecture": "x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_SYSTEM_PROCESSOR": "AMD64"
},
"condition": {
"type": "equals",
Expand All @@ -156,6 +160,7 @@
"name": "coverage-linux",
"binaryDir": "${sourceDir}/build/coverage",
"inherits": "ci-linux",
"description": "This build is only available on Linux",
"hidden": true,
"cacheVariables": {
"ENABLE_COVERAGE": true,
Expand All @@ -171,6 +176,7 @@
"name": "coverage-darwin",
"binaryDir": "${sourceDir}/build/coverage",
"inherits": "ci-darwin",
"description": "This build is only available on Darwin",
"hidden": true,
"cacheVariables": {
"ENABLE_COVERAGE": true,
Expand Down Expand Up @@ -199,6 +205,7 @@
"ci-linux",
"dev-mode"
],
"description": "This build is only available on Linux",
"cacheVariables": {
"CMAKE_SKIP_INSTALL_RULES": true,
"CMAKE_BUILD_TYPE": "Sanitize",
Expand Down
1 change: 1 addition & 0 deletions cmake/WindowsToolchain
Submodule WindowsToolchain added at b44662

0 comments on commit f6352f0

Please sign in to comment.