Skip to content

Commit c5332a9

Browse files
committed
Add CMake tests to ci.yml
1 parent b0d108e commit c5332a9

File tree

5 files changed

+205
-1
lines changed

5 files changed

+205
-1
lines changed

.github/workflows/ci.yml

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: GitHub Actions CI
1+
name: CI
22

33
on:
44
pull_request:
@@ -64,3 +64,156 @@ jobs:
6464
run: |
6565
cd ../boost-root
6666
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
67+
68+
posix-cmake-subdir:
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- os: ubuntu-latest
74+
- os: macos-latest
75+
76+
runs-on: ${{matrix.os}}
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Install packages
82+
if: matrix.install
83+
run: sudo apt install ${{matrix.install}}
84+
85+
- name: Setup Boost
86+
run: |
87+
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
88+
LIBRARY=${GITHUB_REPOSITORY#*/}
89+
echo LIBRARY: $LIBRARY
90+
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
91+
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
92+
echo GITHUB_REF: $GITHUB_REF
93+
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
94+
REF=${REF#refs/heads/}
95+
echo REF: $REF
96+
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
97+
echo BOOST_BRANCH: $BOOST_BRANCH
98+
cd ..
99+
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
100+
cd boost-root
101+
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
102+
git submodule update --init tools/boostdep
103+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
104+
105+
- name: Use library with add_subdirectory
106+
run: |
107+
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
108+
mkdir __build__ && cd __build__
109+
cmake ..
110+
cmake --build .
111+
ctest --output-on-failure --no-tests=error
112+
113+
posix-cmake-install:
114+
strategy:
115+
fail-fast: false
116+
matrix:
117+
include:
118+
- os: ubuntu-latest
119+
- os: macos-latest
120+
121+
runs-on: ${{matrix.os}}
122+
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- name: Install packages
127+
if: matrix.install
128+
run: sudo apt install ${{matrix.install}}
129+
130+
- name: Setup Boost
131+
run: |
132+
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
133+
LIBRARY=${GITHUB_REPOSITORY#*/}
134+
echo LIBRARY: $LIBRARY
135+
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
136+
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
137+
echo GITHUB_REF: $GITHUB_REF
138+
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
139+
REF=${REF#refs/heads/}
140+
echo REF: $REF
141+
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
142+
echo BOOST_BRANCH: $BOOST_BRANCH
143+
cd ..
144+
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
145+
cd boost-root
146+
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
147+
git submodule update --init tools/boostdep
148+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
149+
150+
- name: Configure
151+
run: |
152+
cd ../boost-root
153+
mkdir __build__ && cd __build__
154+
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
155+
156+
- name: Install
157+
run: |
158+
cd ../boost-root/__build__
159+
cmake --build . --target install
160+
161+
- name: Use the installed library
162+
run: |
163+
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
164+
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
165+
cmake --build .
166+
ctest --output-on-failure --no-tests=error
167+
168+
posix-cmake-test:
169+
strategy:
170+
fail-fast: false
171+
matrix:
172+
include:
173+
- os: ubuntu-latest
174+
- os: macos-latest
175+
176+
runs-on: ${{matrix.os}}
177+
178+
steps:
179+
- uses: actions/checkout@v4
180+
181+
- name: Install packages
182+
if: matrix.install
183+
run: sudo apt install ${{matrix.install}}
184+
185+
- name: Setup Boost
186+
run: |
187+
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
188+
LIBRARY=${GITHUB_REPOSITORY#*/}
189+
echo LIBRARY: $LIBRARY
190+
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
191+
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
192+
echo GITHUB_REF: $GITHUB_REF
193+
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
194+
REF=${REF#refs/heads/}
195+
echo REF: $REF
196+
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
197+
echo BOOST_BRANCH: $BOOST_BRANCH
198+
cd ..
199+
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
200+
cd boost-root
201+
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
202+
git submodule update --init tools/boostdep
203+
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
204+
205+
- name: Configure
206+
run: |
207+
cd ../boost-root
208+
mkdir __build__ && cd __build__
209+
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
210+
211+
- name: Build tests
212+
run: |
213+
cd ../boost-root/__build__
214+
cmake --build . --target tests
215+
216+
- name: Run tests
217+
run: |
218+
cd ../boost-root/__build__
219+
ctest --output-on-failure --no-tests=error
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2018, 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+
cmake_minimum_required(VERSION 3.5...3.16)
6+
7+
project(cmake_install_test LANGUAGES CXX)
8+
9+
find_package(boost_sort REQUIRED)
10+
11+
add_executable(main main.cpp)
12+
target_link_libraries(main Boost::sort)
13+
14+
enable_testing()
15+
add_test(main main)
16+
17+
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

test/cmake_install_test/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <boost/sort/spreadsort/integer_sort.hpp>
2+
3+
int main()
4+
{
5+
int v[] = { 1, 2, 3, 0 };
6+
boost::sort::spreadsort::integer_sort( v + 0, v + 4 );
7+
return v[ 0 ];
8+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2018, 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+
cmake_minimum_required(VERSION 3.5...3.16)
6+
7+
project(cmake_subdir_test LANGUAGES CXX)
8+
9+
set(BOOST_INCLUDE_LIBRARIES sort)
10+
add_subdirectory(../../../.. boostorg/boost)
11+
12+
add_executable(main main.cpp)
13+
target_link_libraries(main Boost::sort)
14+
15+
enable_testing()
16+
add_test(main main)
17+
18+
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

test/cmake_subdir_test/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <boost/sort/spreadsort/integer_sort.hpp>
2+
3+
int main()
4+
{
5+
int v[] = { 1, 2, 3, 0 };
6+
boost::sort::spreadsort::integer_sort( v + 0, v + 4 );
7+
return v[ 0 ];
8+
}

0 commit comments

Comments
 (0)