forked from jbeder/yaml-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Test the generated CMake package.
- Loading branch information
1 parent
0579ae3
commit f8de87b
Showing
4 changed files
with
126 additions
and
2 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,102 @@ | ||
name: Github PR | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
workflow_dispatch: | ||
permissions: read-all | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
cmake-build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
build: [static, shared] | ||
generator: ["Default Generator", "MinGW Makefiles"] | ||
exclude: | ||
- os: macos-latest | ||
build: shared | ||
- os: macos-latest | ||
generator: "MinGW Makefiles" | ||
- os: ubuntu-latest | ||
generator: "MinGW Makefiles" | ||
env: | ||
YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }} | ||
YAML_CPP_BUILD_TESTS: 'ON' | ||
CMAKE_GENERATOR: >- | ||
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}} | ||
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install-prefix" | ||
CMAKE_BUILD_TYPE: Debug | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Configure | ||
run: | | ||
cmake \ | ||
${{ env.CMAKE_GENERATOR }} \ | ||
-S "${{ github.workspace }}" \ | ||
-B build \ | ||
-D CMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_PREFIX }}" \ | ||
-D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \ | ||
-D YAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} \ | ||
-D YAML_CPP_BUILD_TESTS=${{ env.YAML_CPP_BUILD_TESTS }} | ||
- name: Build | ||
run: | | ||
cmake \ | ||
--build build \ | ||
--config ${{ env.CMAKE_BUILD_TYPE }} \ | ||
--verbose \ | ||
--parallel | ||
- name: Run Tests | ||
shell: bash | ||
run: | | ||
ctest \ | ||
--test-dir build \ | ||
--build-config ${{ env.CMAKE_BUILD_TYPE }} \ | ||
--output-on-failure \ | ||
--verbose | ||
- name: Install | ||
run: cmake --install build --config ${{ env.CMAKE_BUILD_TYPE }} | ||
|
||
- name: Configure CMake package test | ||
run: | | ||
cmake \ | ||
${{ env.CMAKE_GENERATOR }} \ | ||
-S "${{ github.workspace }}/test/cmake" \ | ||
-B consumer-build \ | ||
-D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \ | ||
-D CMAKE_PREFIX_PATH="${{ env.CMAKE_INSTALL_PREFIX }}" | ||
- name: Build CMake package test | ||
run: | | ||
cmake \ | ||
--build consumer-build \ | ||
--config ${{ env.CMAKE_BUILD_TYPE }} \ | ||
--verbose | ||
bazel-build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build | ||
run: | | ||
cd "${{ github.workspace }}" | ||
bazel build :all | ||
- name: Test | ||
run: | | ||
cd "${{ github.workspace }}" | ||
bazel test test | ||
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,19 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(yaml-cpp-consumer LANGUAGES CXX) | ||
|
||
find_package(yaml-cpp CONFIG REQUIRED) | ||
get_target_property(LIBRARY_TYPE yaml-cpp TYPE) | ||
|
||
if(LIBRARY_TYPE STREQUAL "SHARED_LIBRARY") | ||
if(NOT YAML_CPP_SHARED_LIBS_BUILT) | ||
message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}") | ||
endif() | ||
else() | ||
if(YAML_CPP_SHARED_LIBS_BUILT) | ||
message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}") | ||
endif() | ||
endif() | ||
|
||
add_executable(main main.cpp) | ||
set_target_properties(main PROPERTIES CXX_STANDARD 11) | ||
target_link_libraries(main PRIVATE ${YAML_CPP_LIBRARIES}) |
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,3 @@ | ||
#include "yaml-cpp/yaml.h" | ||
|
||
int main(int, char**) { YAML::Parser foo{}; } |
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