Skip to content

Commit 9688afb

Browse files
committed
Add GHA CMake install/subdir tests
1 parent aaa0dd8 commit 9688afb

File tree

5 files changed

+288
-0
lines changed

5 files changed

+288
-0
lines changed

.github/workflows/ci.yml

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
- feature/**
10+
11+
env:
12+
UBSAN_OPTIONS: print_stacktrace=1
13+
14+
jobs:
15+
posix-cmake-subdir:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-20.04
21+
- os: ubuntu-22.04
22+
- os: macos-11
23+
- os: macos-12
24+
- os: macos-13
25+
26+
runs-on: ${{matrix.os}}
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
31+
- name: Install packages
32+
if: matrix.install
33+
run: sudo apt-get -y install ${{matrix.install}}
34+
35+
- name: Setup Boost
36+
run: |
37+
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
38+
LIBRARY=${GITHUB_REPOSITORY#*/}
39+
echo LIBRARY: $LIBRARY
40+
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
41+
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
42+
echo GITHUB_REF: $GITHUB_REF
43+
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
44+
REF=${REF#refs/heads/}
45+
echo REF: $REF
46+
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
47+
echo BOOST_BRANCH: $BOOST_BRANCH
48+
cd ..
49+
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
50+
cd boost-root
51+
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
52+
git submodule update --init tools/boostdep
53+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" -X test $LIBRARY
54+
55+
- name: Use library with add_subdirectory
56+
run: |
57+
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
58+
mkdir __build__ && cd __build__
59+
cmake ..
60+
cmake --build .
61+
ctest --output-on-failure --no-tests=error
62+
63+
posix-cmake-install:
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
include:
68+
- os: ubuntu-20.04
69+
- os: ubuntu-22.04
70+
- os: macos-11
71+
- os: macos-12
72+
- os: macos-13
73+
74+
runs-on: ${{matrix.os}}
75+
76+
steps:
77+
- uses: actions/checkout@v3
78+
79+
- name: Install packages
80+
if: matrix.install
81+
run: sudo apt-get -y install ${{matrix.install}}
82+
83+
- name: Setup Boost
84+
run: |
85+
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
86+
LIBRARY=${GITHUB_REPOSITORY#*/}
87+
echo LIBRARY: $LIBRARY
88+
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
89+
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
90+
echo GITHUB_REF: $GITHUB_REF
91+
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
92+
REF=${REF#refs/heads/}
93+
echo REF: $REF
94+
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
95+
echo BOOST_BRANCH: $BOOST_BRANCH
96+
cd ..
97+
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
98+
cd boost-root
99+
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
100+
git submodule update --init tools/boostdep
101+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" -X test $LIBRARY
102+
103+
- name: Configure
104+
run: |
105+
cd ../boost-root
106+
mkdir __build__ && cd __build__
107+
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
108+
109+
- name: Install
110+
run: |
111+
cd ../boost-root/__build__
112+
cmake --build . --target install
113+
114+
- name: Use the installed library
115+
run: |
116+
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
117+
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
118+
cmake --build .
119+
ctest --output-on-failure --no-tests=error
120+
121+
windows-cmake-subdir:
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
include:
126+
- os: windows-2019
127+
- os: windows-2022
128+
129+
runs-on: ${{matrix.os}}
130+
131+
steps:
132+
- uses: actions/checkout@v3
133+
134+
- name: Setup Boost
135+
shell: cmd
136+
run: |
137+
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
138+
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
139+
echo LIBRARY: %LIBRARY%
140+
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
141+
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
142+
echo GITHUB_REF: %GITHUB_REF%
143+
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
144+
set BOOST_BRANCH=develop
145+
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
146+
echo BOOST_BRANCH: %BOOST_BRANCH%
147+
cd ..
148+
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
149+
cd boost-root
150+
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
151+
git submodule update --init tools/boostdep
152+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" -X test %LIBRARY%
153+
154+
- name: Use library with add_subdirectory (Debug)
155+
shell: cmd
156+
run: |
157+
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
158+
mkdir __build__ && cd __build__
159+
cmake ..
160+
cmake --build . --config Debug
161+
ctest --output-on-failure --no-tests=error -C Debug
162+
163+
- name: Use library with add_subdirectory (Release)
164+
shell: cmd
165+
run: |
166+
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
167+
cmake --build . --config Release
168+
ctest --output-on-failure --no-tests=error -C Release
169+
170+
windows-cmake-install:
171+
strategy:
172+
fail-fast: false
173+
matrix:
174+
include:
175+
- os: windows-2019
176+
- os: windows-2022
177+
178+
runs-on: ${{matrix.os}}
179+
180+
steps:
181+
- uses: actions/checkout@v3
182+
183+
- name: Setup Boost
184+
shell: cmd
185+
run: |
186+
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
187+
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
188+
echo LIBRARY: %LIBRARY%
189+
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
190+
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
191+
echo GITHUB_REF: %GITHUB_REF%
192+
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
193+
set BOOST_BRANCH=develop
194+
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
195+
echo BOOST_BRANCH: %BOOST_BRANCH%
196+
cd ..
197+
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
198+
cd boost-root
199+
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
200+
git submodule update --init tools/boostdep
201+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" -X test %LIBRARY%
202+
203+
- name: Configure
204+
shell: cmd
205+
run: |
206+
cd ../boost-root
207+
mkdir __build__ && cd __build__
208+
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
209+
210+
- name: Install (Debug)
211+
shell: cmd
212+
run: |
213+
cd ../boost-root/__build__
214+
cmake --build . --target install --config Debug
215+
216+
- name: Install (Release)
217+
shell: cmd
218+
run: |
219+
cd ../boost-root/__build__
220+
cmake --build . --target install --config Release
221+
222+
- name: Use the installed library (Debug)
223+
shell: cmd
224+
run: |
225+
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
226+
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
227+
cmake --build . --config Debug
228+
ctest --output-on-failure --no-tests=error -C Debug
229+
230+
- name: Use the installed library (Release)
231+
shell: cmd
232+
run: |
233+
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
234+
cmake --build . --config Release
235+
ctest --output-on-failure --no-tests=error -C Release
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2018 Peter Dimov
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
cmake_minimum_required(VERSION 3.5...3.16)
6+
7+
project(cmake_install_test LANGUAGES CXX)
8+
9+
find_package(boost_asio REQUIRED)
10+
11+
add_executable(main main.cpp)
12+
target_link_libraries(main Boost::asio)
13+
14+
enable_testing()
15+
add_test(NAME main COMMAND main)
16+
17+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

test/cmake_install_test/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2019 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/asio.hpp>
6+
7+
int main()
8+
{
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2018 Peter Dimov
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
cmake_minimum_required(VERSION 3.5...3.16)
6+
7+
project(cmake_subdir_test LANGUAGES CXX)
8+
9+
set(BOOST_INCLUDE_LIBRARIES asio)
10+
add_subdirectory(../../../.. boostorg/boost)
11+
12+
add_executable(main main.cpp)
13+
target_link_libraries(main Boost::asio)
14+
15+
enable_testing()
16+
add_test(NAME main COMMAND main)
17+
18+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

test/cmake_subdir_test/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2019 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/asio.hpp>
6+
7+
int main()
8+
{
9+
}

0 commit comments

Comments
 (0)