diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 5718b07b..c786e1f8 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,4 +1,4 @@ -name: CI +name: cmake on: workflow_dispatch: @@ -11,9 +11,80 @@ env: EM_VERSION: 3.1.35 EM_CACHE_FOLDER: 'emsdk-cache' CODECOV_TOKEN: 'f8197851-e753-4291-a835-2d76090f2c92' + CMAKE_INSTALL_VERSION: 3.14.7 jobs: + install: + strategy: + fail-fast: false + matrix: + platform: + - { name: Ubuntu GCC static, flags: "", test-flags: ""} + - { name: Ubuntu GCC header-only, flags: "-DSNITCH_HEADER_ONLY=1", test-flags: "-DHEADER_ONLY=yes"} + - { name: Ubuntu GCC shared, flags: "-DBUILD_SHARED_LIBS=1", test-flags: ""} + build-type: + - Release + + name: ${{matrix.platform.name}} ${{matrix.build-type}} + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Setup GCC + shell: bash + run: | + sudo apt install g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 + sudo update-alternatives --set gcc /usr/bin/gcc-11 + + - name: Setup CMake + shell: bash + run: | + wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz + tar -xvzf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz -C "${{github.workspace}}" + echo "${{github.workspace}}/cmake-${CMAKE_VERSION}-Linux-x86_64/bin" >> ${GITHUB_PATH} + + - name: Create Build Environment + shell: bash + run: | + cmake --version + cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + shell: bash + working-directory: ${{github.workspace}}/build + run: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install ${{matrix.platform.flags}} + + - name: Build + shell: bash + working-directory: ${{github.workspace}}/build + run: cmake --build . --parallel 2 + + - name: Install + shell: bash + working-directory: ${{github.workspace}}/build + run: make install + + - name: Build test + shell: bash + working-directory: ${{github.workspace}}/tests/install_tests + run: | + cmake -E make_directory build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{github.workspace}}/install ${{matrix.platform.test-flags}} + cmake --build . + + - name: Run test + shell: bash + working-directory: ${{github.workspace}}/tests/install_tests + run: ./build/standalone + build: + needs: install strategy: fail-fast: false matrix: diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index c004ae1b..6e8a013d 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -1,4 +1,4 @@ -name: CI_meson +name: meson on: workflow_dispatch: diff --git a/.gitignore b/.gitignore index 89ec2616..add3a21d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ doc/html/ snitch.sublime-workspace tests/approval_tests/data/actual tests/approval_tests/data/blanked +install/ diff --git a/tests/install_tests/CMakeLists.txt b/tests/install_tests/CMakeLists.txt new file mode 100644 index 00000000..16b003f0 --- /dev/null +++ b/tests/install_tests/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(snitch REQUIRED CONFIG) + +add_executable(standalone standalone.cpp) + +if (HEADER_ONLY) + target_compile_definitions(standalone PRIVATE HEADER_ONLY) + target_link_libraries(standalone PRIVATE snitch::snitch-header-only) +else() + target_link_libraries(standalone PRIVATE snitch::snitch) +endif() + +target_compile_features(standalone PRIVATE cxx_std_20) diff --git a/tests/install_tests/standalone.cpp b/tests/install_tests/standalone.cpp new file mode 100644 index 00000000..a338f8b0 --- /dev/null +++ b/tests/install_tests/standalone.cpp @@ -0,0 +1,11 @@ +#if defined(HEADER_ONLY) +# define SNITCH_IMPLEMENTATION +# include +#else +# include +# include +#endif + +TEST_CASE("compiles and runs") { + REQUIRE(true == !false); +}