Skip to content

Commit

Permalink
Fix windows build and add CI for macos and windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausKlein committed Nov 19, 2024
1 parent 4bbbe4e commit 071bde5
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# .github/workflows/macos.yml
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: Macos Build

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
build:
runs-on: macos-15
strategy:
fail-fast: false

matrix:
preset: [debug, release]
# TODO: compiler: [g++, clang++-19]
compiler: [g++, clang++-18]

steps:
- uses: actions/checkout@v4

- name: Setup Cpp
# if: startsWith(matrix.compiler, 'clang')
uses: aminya/setup-cpp@v1
with:
# TODO: compiler: llvm-19
# clangtidy: true
# cmake: true
ninja: true

- name: Install llvm-19
if: startsWith(matrix.compiler, 'clang')
run: |
brew install llvm@19 || echo ignored
- name: macos clang++-18 ${{ matrix.preset }}
if: startsWith(matrix.compiler, 'clang')
run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake --workflow --preset ${{ matrix.preset }}

- name: macos g++ ${{ matrix.preset }}
if: startsWith(matrix.compiler, 'g++')
run: CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }}
48 changes: 48 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# .github/workflows/windows.yml
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: Windows Build

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false

matrix:
preset: [debug, release]
# TODO: compiler: [cl, clang-cl]
compiler: [cl]

steps:
- uses: actions/checkout@v4

# see https://github.com/marketplace/actions/enable-developer-command-prompt
- uses: ilammy/msvc-dev-cmd@v1
with:
vsversion: 2022

# - name: build environment
# run: pip install -r requirements.txt

- name: cmake workflow ${{ matrix.preset }}
shell: bash
run: |
cmake --version
ninja --version
CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }}
# - name: configure
# run: CXX=${{ matrix.compiler }} cmake --preset ${{ matrix.preset }}

# - name: build
# run: cmake --build --preset ${{ matrix.preset }}

# - name: ctest
# run: ctest --preset ${{ matrix.preset }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/stagedir
/build
/out
CMakeUserPresets.json
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ set_target_properties(
beman_inplace_vector
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON
)
target_compile_features(
beman_inplace_vector
INTERFACE
"$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand All @@ -63,7 +69,7 @@ block()
if(EXISTS cmake/Config.cmake.in)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
VERSION ${CMAKE_PROJECT_VERSION}
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

Expand Down
107 changes: 107 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"version": 9,
"cmakeMinimumRequired": {
"major": 3,
"minor": 30,
"patch": 0
},
"include": [
"cmake/CMake${hostSystemName}Presets.json"
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug",
"configuration": "Debug",
"targets": [
"install"
]
},
{
"name": "release",
"configurePreset": "release",
"configuration": "Release",
"targets": [
"all_verify_interface_header_sets",
"install"
]
}
],
"testPresets": [
{
"name": "test_base",
"hidden": true,
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": false
}
},
{
"name": "debug",
"inherits": "test_base",
"configuration": "Debug",
"configurePreset": "debug"
},
{
"name": "release",
"inherits": "test_base",
"configuration": "Release",
"configurePreset": "release"
}
],
"packagePresets": [
{
"name": "release",
"configurePreset": "release",
"configurations": [
"Release"
],
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "debug",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
},
{
"type": "test",
"name": "debug"
}
]
},
{
"name": "release",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
},
{
"type": "test",
"name": "release"
},
{
"type": "package",
"name": "release"
}
]
}
]
}
48 changes: 48 additions & 0 deletions cmake/CMakeDarwinPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": 6,
"include": [
"CMakeGenericPresets.json"
],
"configurePresets": [
{
"name": "debug-base-Darwin",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "release-base-Darwin",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "debug",
"displayName": "Debug Build",
"inherits": [
"root-config",
"debug-base-Darwin"
]
},
{
"name": "release",
"displayName": "Release Build",
"inherits": [
"root-config",
"release-base-Darwin"
]
}
]
}
23 changes: 23 additions & 0 deletions cmake/CMakeGenericPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 6,
"configurePresets": [
{
"name": "root-config",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/stagedir",
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceDir}/stagedir"
},
"CMAKE_CXX_EXTENSIONS": false,
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_SKIP_TEST_ALL_DEPENDENCY": false
}
}
]
}
49 changes: 49 additions & 0 deletions cmake/CMakeLinuxPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": 6,
"include": [
"CMakeGenericPresets.json"
],
"configurePresets": [
{
"name": "debug-base-Linux",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "release-base-Linux",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wno-shadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Woverloaded-virtual -Wformat=2 -Wno-error"
},
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "debug",
"displayName": "Debug Build",
"inherits": [
"root-config",
"debug-base-Linux"
]
},
{
"name": "release",
"displayName": "Release Build",
"inherits": [
"root-config",
"release-base-Linux"
]
}
]
}
32 changes: 32 additions & 0 deletions cmake/CMakeWindowsPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": 6,
"include": [
"CMakeGenericPresets.json"
],
"configurePresets": [
{
"name": "release",
"description": "Windows preset for library developers",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build",
"inherits": [
"root-config"
],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "cl"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "debug",
"description": "Windows preset for library developers",
"inherits": [
"release"
]
}
]
}
7 changes: 7 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# cmake/Config.cmake.in -*-makefile-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@TARGET_LIBRARY@")

0 comments on commit 071bde5

Please sign in to comment.