Skip to content

Commit 56b6ff1

Browse files
committed
Add GHA CMake install/subdir tests
1 parent 44722ea commit 56b6ff1

File tree

5 files changed

+280
-0
lines changed

5 files changed

+280
-0
lines changed

.github/workflows/ci.yml

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