Skip to content

Commit 071bde5

Browse files
committed
Fix windows build and add CI for macos and windows
1 parent 4bbbe4e commit 071bde5

File tree

10 files changed

+368
-1
lines changed

10 files changed

+368
-1
lines changed

.github/workflows/macos.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# .github/workflows/macos.yml
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
name: Macos Build
5+
6+
on:
7+
push:
8+
branches: ["main", "develop"]
9+
pull_request:
10+
branches: ["main", "develop"]
11+
12+
jobs:
13+
build:
14+
runs-on: macos-15
15+
strategy:
16+
fail-fast: false
17+
18+
matrix:
19+
preset: [debug, release]
20+
# TODO: compiler: [g++, clang++-19]
21+
compiler: [g++, clang++-18]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Cpp
27+
# if: startsWith(matrix.compiler, 'clang')
28+
uses: aminya/setup-cpp@v1
29+
with:
30+
# TODO: compiler: llvm-19
31+
# clangtidy: true
32+
# cmake: true
33+
ninja: true
34+
35+
- name: Install llvm-19
36+
if: startsWith(matrix.compiler, 'clang')
37+
run: |
38+
brew install llvm@19 || echo ignored
39+
40+
- name: macos clang++-18 ${{ matrix.preset }}
41+
if: startsWith(matrix.compiler, 'clang')
42+
run: CXX=$(brew --prefix llvm@18)/bin/clang++ cmake --workflow --preset ${{ matrix.preset }}
43+
44+
- name: macos g++ ${{ matrix.preset }}
45+
if: startsWith(matrix.compiler, 'g++')
46+
run: CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }}

.github/workflows/windows.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# .github/workflows/windows.yml
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
name: Windows Build
5+
6+
on:
7+
push:
8+
branches: ["main", "develop"]
9+
pull_request:
10+
branches: ["main", "develop"]
11+
12+
jobs:
13+
build:
14+
runs-on: windows-latest
15+
strategy:
16+
fail-fast: false
17+
18+
matrix:
19+
preset: [debug, release]
20+
# TODO: compiler: [cl, clang-cl]
21+
compiler: [cl]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
# see https://github.com/marketplace/actions/enable-developer-command-prompt
27+
- uses: ilammy/msvc-dev-cmd@v1
28+
with:
29+
vsversion: 2022
30+
31+
# - name: build environment
32+
# run: pip install -r requirements.txt
33+
34+
- name: cmake workflow ${{ matrix.preset }}
35+
shell: bash
36+
run: |
37+
cmake --version
38+
ninja --version
39+
CXX=${{ matrix.compiler }} cmake --workflow --preset ${{ matrix.preset }}
40+
41+
# - name: configure
42+
# run: CXX=${{ matrix.compiler }} cmake --preset ${{ matrix.preset }}
43+
44+
# - name: build
45+
# run: cmake --build --preset ${{ matrix.preset }}
46+
47+
# - name: ctest
48+
# run: ctest --preset ${{ matrix.preset }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/stagedir
12
/build
23
/out
34
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ set_target_properties(
3737
beman_inplace_vector
3838
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON
3939
)
40+
target_compile_features(
41+
beman_inplace_vector
42+
INTERFACE
43+
"$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
44+
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
45+
)
4046

4147
include(GNUInstallDirs)
4248
include(CMakePackageConfigHelpers)
@@ -63,7 +69,7 @@ block()
6369
if(EXISTS cmake/Config.cmake.in)
6470
write_basic_package_version_file(
6571
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
66-
VERSION ${CMAKE_PROJECT_VERSION}
72+
VERSION ${PROJECT_VERSION}
6773
COMPATIBILITY AnyNewerVersion
6874
)
6975

CMakePresets.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"version": 9,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 30,
6+
"patch": 0
7+
},
8+
"include": [
9+
"cmake/CMake${hostSystemName}Presets.json"
10+
],
11+
"buildPresets": [
12+
{
13+
"name": "debug",
14+
"configurePreset": "debug",
15+
"configuration": "Debug",
16+
"targets": [
17+
"install"
18+
]
19+
},
20+
{
21+
"name": "release",
22+
"configurePreset": "release",
23+
"configuration": "Release",
24+
"targets": [
25+
"all_verify_interface_header_sets",
26+
"install"
27+
]
28+
}
29+
],
30+
"testPresets": [
31+
{
32+
"name": "test_base",
33+
"hidden": true,
34+
"output": {
35+
"outputOnFailure": true
36+
},
37+
"execution": {
38+
"noTestsAction": "error",
39+
"stopOnFailure": false
40+
}
41+
},
42+
{
43+
"name": "debug",
44+
"inherits": "test_base",
45+
"configuration": "Debug",
46+
"configurePreset": "debug"
47+
},
48+
{
49+
"name": "release",
50+
"inherits": "test_base",
51+
"configuration": "Release",
52+
"configurePreset": "release"
53+
}
54+
],
55+
"packagePresets": [
56+
{
57+
"name": "release",
58+
"configurePreset": "release",
59+
"configurations": [
60+
"Release"
61+
],
62+
"generators": [
63+
"TGZ"
64+
]
65+
}
66+
],
67+
"workflowPresets": [
68+
{
69+
"name": "debug",
70+
"steps": [
71+
{
72+
"type": "configure",
73+
"name": "debug"
74+
},
75+
{
76+
"type": "build",
77+
"name": "debug"
78+
},
79+
{
80+
"type": "test",
81+
"name": "debug"
82+
}
83+
]
84+
},
85+
{
86+
"name": "release",
87+
"steps": [
88+
{
89+
"type": "configure",
90+
"name": "release"
91+
},
92+
{
93+
"type": "build",
94+
"name": "release"
95+
},
96+
{
97+
"type": "test",
98+
"name": "release"
99+
},
100+
{
101+
"type": "package",
102+
"name": "release"
103+
}
104+
]
105+
}
106+
]
107+
}

cmake/CMakeDarwinPresets.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "debug-base-Darwin",
9+
"hidden": true,
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug"
12+
},
13+
"condition": {
14+
"type": "equals",
15+
"lhs": "${hostSystemName}",
16+
"rhs": "Darwin"
17+
}
18+
},
19+
{
20+
"name": "release-base-Darwin",
21+
"hidden": true,
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
24+
},
25+
"condition": {
26+
"type": "equals",
27+
"lhs": "${hostSystemName}",
28+
"rhs": "Darwin"
29+
}
30+
},
31+
{
32+
"name": "debug",
33+
"displayName": "Debug Build",
34+
"inherits": [
35+
"root-config",
36+
"debug-base-Darwin"
37+
]
38+
},
39+
{
40+
"name": "release",
41+
"displayName": "Release Build",
42+
"inherits": [
43+
"root-config",
44+
"release-base-Darwin"
45+
]
46+
}
47+
]
48+
}

cmake/CMakeGenericPresets.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "root-config",
6+
"hidden": true,
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/build/${presetName}",
9+
"installDir": "${sourceDir}/stagedir",
10+
"cacheVariables": {
11+
"CMAKE_PREFIX_PATH": {
12+
"type": "path",
13+
"value": "${sourceDir}/stagedir"
14+
},
15+
"CMAKE_CXX_EXTENSIONS": false,
16+
"CMAKE_CXX_STANDARD": "23",
17+
"CMAKE_CXX_STANDARD_REQUIRED": true,
18+
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
19+
"CMAKE_SKIP_TEST_ALL_DEPENDENCY": false
20+
}
21+
}
22+
]
23+
}

cmake/CMakeLinuxPresets.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "debug-base-Linux",
9+
"hidden": true,
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug"
12+
},
13+
"condition": {
14+
"type": "equals",
15+
"lhs": "${hostSystemName}",
16+
"rhs": "Linux"
17+
}
18+
},
19+
{
20+
"name": "release-base-Linux",
21+
"hidden": true,
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
24+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wno-shadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Woverloaded-virtual -Wformat=2 -Wno-error"
25+
},
26+
"condition": {
27+
"type": "notEquals",
28+
"lhs": "${hostSystemName}",
29+
"rhs": "Windows"
30+
}
31+
},
32+
{
33+
"name": "debug",
34+
"displayName": "Debug Build",
35+
"inherits": [
36+
"root-config",
37+
"debug-base-Linux"
38+
]
39+
},
40+
{
41+
"name": "release",
42+
"displayName": "Release Build",
43+
"inherits": [
44+
"root-config",
45+
"release-base-Linux"
46+
]
47+
}
48+
]
49+
}

cmake/CMakeWindowsPresets.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "release",
9+
"description": "Windows preset for library developers",
10+
"generator": "Ninja Multi-Config",
11+
"binaryDir": "${sourceDir}/build",
12+
"inherits": [
13+
"root-config"
14+
],
15+
"cacheVariables": {
16+
"CMAKE_CXX_COMPILER": "cl"
17+
},
18+
"condition": {
19+
"type": "equals",
20+
"lhs": "${hostSystemName}",
21+
"rhs": "Windows"
22+
}
23+
},
24+
{
25+
"name": "debug",
26+
"description": "Windows preset for library developers",
27+
"inherits": [
28+
"release"
29+
]
30+
}
31+
]
32+
}

cmake/Config.cmake.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# cmake/Config.cmake.in -*-makefile-*-
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
@PACKAGE_INIT@
5+
6+
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
7+
check_required_components("@TARGET_LIBRARY@")

0 commit comments

Comments
 (0)