Skip to content

Commit c67bcbd

Browse files
committed
Properly handling CMake before 3.28
1 parent d2e02f9 commit c67bcbd

3 files changed

Lines changed: 56 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
- { os: ubuntu-latest, compiler: gcc, version: 12 }
2626
- { os: ubuntu-latest, compiler: gcc, version: 13 }
2727
- { os: ubuntu-24.04, compiler: gcc, version: 14, module: true }
28-
#- { os: ubuntu-24.04, compiler: gcc, version: 15, module: true }
2928

3029
- { os: ubuntu-22.04, compiler: clang, version: 13 }
3130
- { os: ubuntu-22.04, compiler: clang ,version: 14 }
@@ -88,3 +87,47 @@ jobs:
8887
run: |
8988
cmake --build build --config Release --target run-test
9089
90+
container:
91+
runs-on: ubuntu-latest
92+
container: ${{ matrix.container }}
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
include:
97+
- {container: gcc:15.1, module: true}
98+
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v4
102+
103+
- name: System Setup
104+
shell: bash
105+
run: |
106+
apt-get update
107+
apt-get install -y python3-dev
108+
109+
export CMAKE_VERSION=3.28.6
110+
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
111+
-q -O /tmp/cmake-install.sh \
112+
&& chmod u+x /tmp/cmake-install.sh \
113+
&& /tmp/cmake-install.sh --skip-license --prefix=/usr \
114+
rm -f /tmp/cmake-install.sh
115+
116+
wget -qO- https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip | \
117+
gunzip > /usr/bin/ninja
118+
chmod a+x /usr/bin/ninja
119+
echo "CMAKE_GENERATOR=-GNinja" >> $GITHUB_ENV
120+
121+
if [[ '${{ matrix.module}}' == 'true' ]]; then
122+
echo "CMAKE_ARGS=-DISPTR_ENABLE_MODULE=ON" >> $GITHUB_ENV
123+
fi
124+
125+
- name: Configure
126+
shell: bash
127+
run: |
128+
cmake $CMAKE_GENERATOR -S . -B build $CMAKE_ARGS -DISPTR_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
129+
130+
- name: Build and Test
131+
shell: bash
132+
run: |
133+
cmake --build build --config Release --target run-test

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ add_library(${LIBNAME}::${LIBNAME} ALIAS ${LIBNAME})
5151
set(ISPTR_MODULES_BASE_DIRS ${SRCDIR}/modules)
5252
set(ISPTR_MODULES_FILES ${SRCDIR}/modules/isptr.cppm)
5353

54+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.28")
55+
5456
function(isptr_add_module target_name visibility)
5557
target_sources(${target_name} ${visibility}
5658
FILE_SET isptr_module TYPE CXX_MODULES BASE_DIRS ${ISPTR_MODULES_BASE_DIRS} FILES ${ISPTR_MODULES_FILES}
5759
)
5860
endfunction()
5961

62+
endif()
6063

6164
if (PROJECT_IS_TOP_LEVEL)
6265

test/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ set(CXX_STANDARD_20 20)
3131
set(CXX_STANDARD_23 23)
3232

3333
set(TEST_VARIANTS_17 "headers")
34+
set(TEST_VARIANTS_20 "headers")
35+
set(TEST_VARIANTS_23 "headers")
36+
3437
if (${ISPTR_ENABLE_MODULE})
35-
set(TEST_VARIANTS_20 "headers;module")
36-
set(TEST_VARIANTS_23 "headers;module")
37-
else()
38-
set(TEST_VARIANTS_20 "headers")
39-
set(TEST_VARIANTS_23 "headers")
38+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.28")
39+
list(APPEND TEST_VARIANTS_20 "module")
40+
list(APPEND TEST_VARIANTS_23 "module")
41+
else()
42+
message(WARNING "CMake version ${CMAKE_VERSION} doesn't support modules, ignoring ISPTR_ENABLE_MODULE")
43+
endif()
4044
endif()
4145

4246
set(TEST_COMMAND "")

0 commit comments

Comments
 (0)