-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for the cmake package (#54)
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Test CMake package | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v**.** | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-test: | ||
env: | ||
build_profile: clang20d | ||
conan_preset: clang-20-debug | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
simd: [True, False] | ||
include: | ||
- simd: True | ||
cmake_extra: "-DMATHTER_ENABLE_SIMD:BOOL=ON" | ||
- simd: False | ||
cmake_extra: "-DMATHTER_ENABLE_SIMD:BOOL=OFF" | ||
|
||
name: SIMD=${{matrix.simd}} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: seanmiddleditch/gha-setup-ninja@v4 | ||
|
||
- run: pip install conan | ||
|
||
- name: Install native compilers | ||
run: | | ||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | ||
sudo apt update | ||
sudo apt install gcc-13 g++-13 | ||
sudo update-alternatives --remove-all gcc || true | ||
sudo update-alternatives --remove-all g++ || true | ||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 --slave /usr/bin/g++ g++ /usr/bin/g++-13 | ||
wget https://apt.llvm.org/llvm.sh | ||
chmod +x llvm.sh | ||
sudo ./llvm.sh 17 clang | ||
sudo update-alternatives --remove-all clang || true | ||
sudo update-alternatives --remove-all clang++ || true | ||
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 10 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-17 | ||
- name: Cache conan packages | ||
id: cache-conan | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.conan2/p | ||
key: conan-cache-packages-${{env.build_profile}} | ||
|
||
- name: Create Build Environment | ||
run: cmake -E make_directory ${{github.workspace}}/build | ||
|
||
- name: Configure CMake | ||
shell: bash | ||
env: | ||
PR: "${{github.workspace}}/.github/build_profiles/${{env.build_profile}}" | ||
run: | | ||
cmake -E make_directory "${{github.workspace}}/build" | ||
conan install "${{github.workspace}}" --build=missing -pr $PR -pr:b $PR | ||
conan cache clean | ||
cmake -S "${{github.workspace}}" --preset conan-${{env.conan_preset}} ${{matrix.cmake_extra}} -DMATHTER_BUILD_TESTS:BOOL=OFF -DMATHTER_BUILD_BENCHMARKS:BOOL=OFF -DMATHTER_BUILD_EXAMPLES:BOOL=OFF -DMATHTER_VERSION:STRING=99.0.0 | ||
- name: Build & install | ||
run: | | ||
cmake --build --preset conan-${{ env.conan_preset }} | ||
cmake -E make_directory "${{github.workspace}}/install" | ||
cmake --install ${{github.workspace}}/build/${{env.conan_preset}} --prefix "${{github.workspace}}/install" | ||
- name: Test package | ||
shell: bash | ||
env: | ||
PR: "${{github.workspace}}/.github/build_profiles/${{env.build_profile}}" | ||
CMAKE_PREFIX_PATH: "${{github.workspace}}/install" | ||
run: | | ||
cmake -E make_directory "${{github.workspace}}/test_package/build" | ||
conan install "${{github.workspace}}/test_package" --build=missing -pr $PR -pr:b $PR | ||
conan cache clean | ||
cmake -S "${{github.workspace}}/test_package" --preset conan-${{env.conan_preset}} | ||
cmake --build "${{github.workspace}}/test_package/build/${{env.conan_preset}}" | ||
${{github.workspace}}/test_package/build/${{env.conan_preset}}/bin/TestMathterPackage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
|
||
project(TestMathterPackage) | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
||
add_executable(TestMathterPackage) | ||
|
||
target_sources(TestMathterPackage | ||
PRIVATE | ||
main.cpp | ||
) | ||
|
||
find_package(Mathter 99.0.0) | ||
target_link_libraries(TestMathterPackage Mathter::Mathter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[requires] | ||
xsimd/13.0.0 | ||
|
||
[generators] | ||
CMakeDeps | ||
CMakeToolchain | ||
|
||
[layout] | ||
cmake_layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <Mathter/Geometry.hpp> | ||
#include <Mathter/IoStream.hpp> | ||
#include <Mathter/Matrix.hpp> | ||
#include <Mathter/Quaternion.hpp> | ||
#include <Mathter/Transforms.hpp> | ||
#include <Mathter/Utility.hpp> | ||
#include <Mathter/Vector.hpp> | ||
|
||
#include <iostream> | ||
|
||
using namespace mathter; | ||
|
||
|
||
int main() { | ||
const auto u = Vector(1, 2, 3); | ||
const auto v = Vector(4, 6, 8); | ||
const auto r = u + v; | ||
if (r[0] != 5) { | ||
std::cout << "Mathter installation failing." << std::endl; | ||
return 1; | ||
} | ||
else { | ||
std::cout << "Mathter installation works." << std::endl; | ||
std::cout << "Options:" << std::endl; | ||
#ifdef MATHTER_ENABLE_SIMD | ||
std::cout << " with_xsimd = True" << std::endl; | ||
#else | ||
std::cout << " with_xsimd = False" << std::endl; | ||
#endif | ||
return 0; | ||
} | ||
} |