Skip to content

Commit 5ee099a

Browse files
authored
Merge pull request #71 from Perlmint/fix/gha
Fix GHA build test
2 parents 49490b1 + 8522535 commit 5ee099a

File tree

1 file changed

+78
-68
lines changed

1 file changed

+78
-68
lines changed

.github/workflows/cmake.yml

Lines changed: 78 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ env:
1818

1919
jobs:
2020
build:
21-
# The CMake configure and build commands are platform agnostic and should work equally
22-
# well on Windows or Mac. You can convert this to a matrix build if you need
23-
# cross-platform coverage.
24-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
2521
runs-on: ubuntu-latest
2622
container: ubuntu:latest
2723

@@ -91,91 +87,105 @@ jobs:
9187
cmake .
9288
cmake --build .
9389
94-
build_2_8:
95-
# The CMake configure and build commands are platform agnostic and should work equally
96-
# well on Windows or Mac. You can convert this to a matrix build if you need
97-
# cross-platform coverage.
98-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
90+
build_linux:
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
cmake:
95+
- 2.8.12.2
96+
- 3.10.3
97+
- latest
9998
runs-on: ubuntu-latest
100-
container: ubuntu:14.04
99+
container: ubuntu:latest
101100

102101
steps:
103102
- uses: actions/checkout@v2
104-
105-
- name: Install dependencies
106-
run: apt update && apt install -y cmake gcc libgl1-mesa-dev libx11-dev libxext-dev
107-
108-
- name: Configure CMake
109-
shell: bash
110-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
111-
112-
- name: Build test
113-
shell: bash
114-
run: cmake --build .
115-
116-
- name: Check alias
117-
shell: bash
118-
run: test -e lib/libGLEW.a
119103

120-
build_3_10:
121-
# The CMake configure and build commands are platform agnostic and should work equally
122-
# well on Windows or Mac. You can convert this to a matrix build if you need
123-
# cross-platform coverage.
124-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
125-
runs-on: ubuntu-latest
126-
container: ubuntu:18.04
104+
- name: Restore cached cmake
105+
uses: actions/cache/restore@v4
106+
with:
107+
path: /opt/cmake
108+
key: cmake-${{ matrix.cmake }}
127109

128-
steps:
129-
- uses: actions/checkout@v2
130-
131110
- name: Install dependencies
132-
run: apt update && apt install -y cmake gcc libgl1-mesa-dev libx11-dev libxext-dev
111+
shell: bash
112+
run: |
113+
cmake=${{ matrix.cmake }}
114+
apt update
115+
apt install -y gcc make libgl1-mesa-dev libx11-dev libxext-dev
116+
if [ "${cmake}" == "latest" ]; then
117+
apt install -y git
118+
cmake=$(git ls-remote --tags https://gitlab.kitware.com/cmake/cmake | cut -f 2 | sed -E "s/^refs\/tags\/v//" | tr -d "^{}" | sort -t '.' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | tr -d "\n")
119+
echo "Latest version: ${cmake}"
120+
fi
121+
if [ -x /opt/cmake/bin/cmake ]; then
122+
echo "Found cached cmake"
123+
if [ -n "$(/opt/cmake/bin/cmake --version | grep ${cmake})" ]; then
124+
exit 0
125+
fi
126+
/opt/cmake/bin/cmake --version
127+
echo "CMake version is mismatched"
128+
rm -rf /opt/cmake
129+
fi
130+
131+
apt install -y g++ wget
132+
short_version=$(echo "${cmake}" | sed -E "s/^([0-9]+\\.[0-9]+)\\..+$/\\1/" | tr -d "\n")
133+
wget https://cmake.org/files/v${short_version}/cmake-${cmake}.tar.gz
134+
tar -xf cmake-${cmake}.tar.gz
135+
cd cmake-${cmake}
136+
if [ "${cmake}" == "2.8.12.2" ]; then
137+
apt -y install patch
138+
patch -p1 << 'EOF'
139+
--- cmake-2.8.12.2-org/CMakeLists.txt 2014-01-16 17:15:07.000000000 +0000
140+
+++ cmake-2.8.12.2-patch/CMakeLists.txt 2025-04-13 10:37:28.359021847 +0000
141+
@@ -616 +616 @@
142+
-add_subdirectory(Tests)
143+
+# add_subdirectory(Tests)
144+
--- cmake-2.8.12.2-org/Source/CMakeLists.txt 2014-01-16 17:15:08.000000000 +0000
145+
+++ cmake-2.8.12.2-patch/Source/CMakeLists.txt 2025-04-13 10:37:13.584956375 +0000
146+
@@ -481,2 +481,2 @@
147+
-add_library(CTestLib ${CTEST_SRCS})
148+
-target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
149+
+# add_library(CTestLib ${CTEST_SRCS})
150+
+# target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
151+
@@ -562,2 +562,2 @@
152+
-add_executable(ctest ctest.cxx)
153+
-target_link_libraries(ctest CTestLib)
154+
+# add_executable(ctest ctest.cxx)
155+
+# target_link_libraries(ctest CTestLib)
156+
@@ -583 +583 @@
157+
-install(TARGETS cmake ctest cpack DESTINATION bin)
158+
+install(TARGETS cmake cpack DESTINATION bin)
159+
EOF
160+
fi
161+
./configure --prefix=/opt/cmake -- -DCMAKE_USE_OPENSSL=OFF
162+
make -j $(nproc) install
163+
164+
- name: Save cmake
165+
uses: actions/cache/save@v4
166+
with:
167+
path: /opt/cmake
168+
key: cmake-${{ matrix.cmake }}
133169

134170
- name: Configure CMake
135171
shell: bash
136-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
172+
run: /opt/cmake/bin/cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
137173

138174
- name: Build test
139175
shell: bash
140-
run: cmake --build .
141-
142-
- name: Check alias
143-
shell: bash
144-
run: test -e lib/libGLEW.a
145-
146-
build_latest:
147-
runs-on: ubuntu-latest
148-
container: ubuntu:latest
176+
run: /opt/cmake/bin/cmake --build .
149177

150-
steps:
151-
- uses: actions/checkout@v2
152-
153-
- name: Install dependencies
154-
run: apt update && apt install -y python3 python3-pip gcc libgl1-mesa-dev libx11-dev libxext-dev && pip install cmake
155-
156-
- name: Configure CMake
157-
shell: bash
158-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
159-
160-
- name: Build test
161-
shell: bash
162-
run: cmake --build .
163-
164178
- name: Check alias
165179
shell: bash
166180
run: test -e lib/libGLEW.a
167181

168182
build_mingw:
169-
# The CMake configure and build commands are platform agnostic and should work equally
170-
# well on Windows or Mac. You can convert this to a matrix build if you need
171-
# cross-platform coverage.
172-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
173183
runs-on: ubuntu-latest
174-
container: ubuntu:18.04
184+
container: ubuntu:latest
175185

176186
steps:
177187
- uses: actions/checkout@v2
178-
188+
179189
- name: Install dependencies
180190
run: apt update && apt install -y cmake g++-mingw-w64-x86-64 make libgl1-mesa-dev libx11-dev libxext-dev
181191

@@ -193,7 +203,7 @@ jobs:
193203

194204
steps:
195205
- uses: actions/checkout@v2
196-
206+
197207
- name: Configure CMake
198208
shell: bash
199209
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
@@ -207,7 +217,7 @@ jobs:
207217

208218
steps:
209219
- uses: actions/checkout@v2
210-
220+
211221
- name: Configure CMake
212222
shell: bash
213223
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE

0 commit comments

Comments
 (0)