Compare commits

..

No commits in common. "master" and "0.8.0" have entirely different histories.

19 changed files with 55 additions and 254 deletions

View File

@ -1 +0,0 @@
test/gtest-1.11.0

View File

@ -1,11 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"

View File

@ -6,18 +6,13 @@ on:
branches: [ master ] branches: [ master ]
workflow_dispatch: workflow_dispatch:
permissions: read-all permissions: read-all
defaults:
run:
shell: bash
jobs: jobs:
cmake-build: cmake-build:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
cxx_standard: [11, 17, 20]
build: [static, shared] build: [static, shared]
googletest: [build, system]
generator: ["Default Generator", "MinGW Makefiles"] generator: ["Default Generator", "MinGW Makefiles"]
exclude: exclude:
- os: macos-latest - os: macos-latest
@ -26,78 +21,34 @@ jobs:
generator: "MinGW Makefiles" generator: "MinGW Makefiles"
- os: ubuntu-latest - os: ubuntu-latest
generator: "MinGW Makefiles" generator: "MinGW Makefiles"
- os: macos-latest
googletest: system
- os: windows-latest
googletest: system
env: env:
YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }} YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }}
YAML_USE_SYSTEM_GTEST: ${{ matrix.googletest == 'system' && 'ON' || 'OFF' }} YAML_CPP_BUILD_TESTS: 'ON'
CMAKE_GENERATOR: >- CMAKE_GENERATOR: >-
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}} ${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install-prefix"
CMAKE_BUILD_TYPE: Debug
CMAKE_CXX_FLAGS_DEBUG: ${{ matrix.googletest == 'build' && '-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' || '-g' }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2
- uses: awalsh128/cache-apt-pkgs-action@latest - name: Get number of CPU cores
if: matrix.os == 'ubuntu-latest' uses: SimenB/github-actions-cpu-cores@v1
with:
packages: googletest libgmock-dev libgtest-dev
version: 1.0
- uses: actions/checkout@v4
- name: Configure
run: |
cmake \
${{ env.CMAKE_GENERATOR }} \
-S "${{ github.workspace }}" \
-B build \
-D CMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \
-D CMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_PREFIX }}" \
-D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
-D CMAKE_CXX_FLAGS_DEBUG="${{ env.CMAKE_CXX_FLAGS_DEBUG }}" \
-D YAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} \
-D YAML_USE_SYSTEM_GTEST=${{ env.YAML_USE_SYSTEM_GTEST }} \
-D YAML_CPP_BUILD_TESTS=ON
- name: Build - name: Build
shell: bash
run: | run: |
cmake \ cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }}
--build build \ cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
--config ${{ env.CMAKE_BUILD_TYPE }} \
--verbose \ - name: Build Tests
--parallel shell: bash
run: |
cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} -DYAML_CPP_BUILD_TESTS=${{ env.YAML_CPP_BUILD_TESTS }}
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
- name: Run Tests - name: Run Tests
shell: bash shell: bash
run: | run: |
ctest \ cd build && ctest -C Debug --output-on-failure --verbose
--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: bazel-build:
strategy: strategy:
@ -105,34 +56,17 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: Build - name: Build
shell: bash
run: | run: |
cd "${{ github.workspace }}" cd "${{ github.workspace }}"
bazel build :all bazel build :all
- name: Test - name: Test
shell: bash
run: | run: |
cd "${{ github.workspace }}" cd "${{ github.workspace }}"
bazel test test bazel test test
bzlmod-build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Build
shell: bash
run: |
cd "${{ github.workspace }}"
bazel build --enable_bzlmod :all
- name: Test
shell: bash
run: |
cd "${{ github.workspace }}"
bazel test --enable_bzlmod test

View File

@ -1,19 +0,0 @@
name: Bazel Release
on:
release:
types: [published]
jobs:
# A release archive is required for bzlmod
# See: https://blog.bazel.build/2023/02/15/github-archive-checksum.html
bazel-release-archive:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: git archive $GITHUB_REF -o "yaml-cpp-${GITHUB_REF:10}.tar.gz"
- run: gh release upload ${GITHUB_REF:10} "yaml-cpp-${GITHUB_REF:10}.tar.gz"
env:
GH_TOKEN: ${{ github.token }}

View File

@ -1,6 +1,5 @@
# 3.5 is actually available almost everywhere, but this a good minimum. # 3.5 is actually available almost everywhere, but this a good minimum
# 3.14 as the upper policy limit avoids CMake deprecation warnings. cmake_minimum_required(VERSION 3.4)
cmake_minimum_required(VERSION 3.4...3.14)
# enable MSVC_RUNTIME_LIBRARY target property # enable MSVC_RUNTIME_LIBRARY target property
# see https://cmake.org/cmake/help/latest/policy/CMP0091.html # see https://cmake.org/cmake/help/latest/policy/CMP0091.html
@ -25,19 +24,13 @@ option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON) option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS}) option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT}) option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT})
option(YAML_CPP_FORMAT_SOURCE "Format source" ${YAML_CPP_MAIN_PROJECT}) option(YAML_CPP_FORMAT_SOURCE "Format source" ON)
option(YAML_CPP_DISABLE_UNINSTALL "Disable uninstallation of yaml-cpp" OFF)
option(YAML_USE_SYSTEM_GTEST "Use system googletest if found" OFF)
option(YAML_ENABLE_PIC "Use Position-Independent Code " ON)
cmake_dependent_option(YAML_CPP_BUILD_TESTS cmake_dependent_option(YAML_CPP_BUILD_TESTS
"Enable yaml-cpp tests" OFF "Enable yaml-cpp tests" OFF
"BUILD_TESTING;YAML_CPP_MAIN_PROJECT" OFF) "BUILD_TESTING;YAML_CPP_MAIN_PROJECT" OFF)
cmake_dependent_option(YAML_MSVC_SHARED_RT cmake_dependent_option(YAML_MSVC_SHARED_RT
"MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON "MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF) "CMAKE_SYSTEM_NAME MATCHES Windows" OFF)
set(YAML_CPP_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/yaml-cpp"
CACHE STRING "Path to install the CMake package to")
if (YAML_CPP_FORMAT_SOURCE) if (YAML_CPP_FORMAT_SOURCE)
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format) find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
@ -92,7 +85,7 @@ set_property(TARGET yaml-cpp
CXX_STANDARD_REQUIRED ON) CXX_STANDARD_REQUIRED ON)
if (NOT YAML_BUILD_SHARED_LIBS) if (NOT YAML_BUILD_SHARED_LIBS)
set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ${YAML_ENABLE_PIC}) set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ON)
endif() endif()
target_include_directories(yaml-cpp target_include_directories(yaml-cpp
@ -150,12 +143,13 @@ set_target_properties(yaml-cpp PROPERTIES
PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}" PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}"
DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
set(EXPORT_TARGETS yaml-cpp::yaml-cpp) set(CONFIG_EXPORT_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/yaml-cpp")
set(EXPORT_TARGETS yaml-cpp)
configure_package_config_file( configure_package_config_file(
"${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in" "${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in"
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
INSTALL_DESTINATION "${YAML_CPP_INSTALL_CMAKEDIR}" INSTALL_DESTINATION "${CONFIG_EXPORT_DIR}"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR) PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR CONFIG_EXPORT_DIR YAML_BUILD_SHARED_LIBS)
unset(EXPORT_TARGETS) unset(EXPORT_TARGETS)
write_basic_package_version_file( write_basic_package_version_file(
@ -175,14 +169,15 @@ if (YAML_CPP_INSTALL)
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(EXPORT yaml-cpp-targets install(EXPORT yaml-cpp-targets
NAMESPACE yaml-cpp:: NAMESPACE yaml-cpp::
DESTINATION "${YAML_CPP_INSTALL_CMAKEDIR}") DESTINATION "${CONFIG_EXPORT_DIR}")
install(FILES install(FILES
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
DESTINATION "${YAML_CPP_INSTALL_CMAKEDIR}") DESTINATION "${CONFIG_EXPORT_DIR}")
install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc" install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif() endif()
unset(CONFIG_EXPORT_DIR)
if(YAML_CPP_BUILD_TESTS) if(YAML_CPP_BUILD_TESTS)
add_subdirectory(test) add_subdirectory(test)
@ -201,7 +196,7 @@ if (YAML_CPP_FORMAT_SOURCE AND YAML_CPP_CLANG_FORMAT_EXE)
endif() endif()
# uninstall target # uninstall target
if(YAML_CPP_INSTALL AND NOT YAML_CPP_DISABLE_UNINSTALL AND NOT TARGET uninstall) if(NOT TARGET uninstall)
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"

View File

@ -1,14 +0,0 @@
"""
yaml-cpp is a YAML parser and emitter in c++ matching the YAML specification.
"""
module(
name = "yaml-cpp",
compatibility_level = 1,
version = "0.8.0",
)
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)

View File

@ -31,17 +31,6 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] ..
* `yaml-cpp` builds a static library by default, you may want to build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`. * `yaml-cpp` builds a static library by default, you may want to build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`.
* [Debug mode of the GNU standard C++
library](https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html)
can be used when both `yaml-cpp` and client code is compiled with the
`_GLIBCXX_DEBUG` flag (e.g. by calling CMake with `-D
CMAKE_CXX_FLAGS_DEBUG='-g -D_GLIBCXX_DEBUG'` option).
Note that for `yaml-cpp` unit tests to run successfully, the _GoogleTest_
library also must be built with this flag, i.e. the system one cannot be
used (the _YAML_USE_SYSTEM_GTEST_ CMake option must be _OFF_, which is the
default).
* For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file. * For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file.
#### 2. Build it! #### 2. Build it!
@ -49,29 +38,6 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] ..
**Note:** To clean up, just remove the `build` directory. **Note:** To clean up, just remove the `build` directory.
## How to Integrate it within your project using CMake
You can use for example FetchContent :
```cmake
include(FetchContent)
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG <tag_name> # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master)
)
FetchContent_GetProperties(yaml-cpp)
if(NOT yaml-cpp_POPULATED)
message(STATUS "Fetching yaml-cpp...")
FetchContent_Populate(yaml-cpp)
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR})
endif()
target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library
```
## Recent Releases ## Recent Releases
[yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) released! This release requires C++11, and no longer depends on Boost. [yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) released! This release requires C++11, and no longer depends on Boost.

View File

@ -155,9 +155,15 @@ produces
We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like: We overload `operator <<` for `std::vector`, `std::list`, and `std::map`, so you can write stuff like:
```cpp ```cpp
std::vector <int> squares = {1, 4, 9, 16}; std::vector <int> squares;
squares.push_back(1);
squares.push_back(4);
squares.push_back(9);
squares.push_back(16);
std::map <std::string, int> ages = {{"Daniel", 26}, {"Jesse", 24}}; std::map <std::string, int> ages;
ages["Daniel"] = 26;
ages["Jesse"] = 24;
YAML::Emitter out; YAML::Emitter out;
out << YAML::BeginSeq; out << YAML::BeginSeq;

View File

@ -23,7 +23,6 @@ class Emitter;
class EmitFromEvents : public EventHandler { class EmitFromEvents : public EventHandler {
public: public:
EmitFromEvents(Emitter& emitter); EmitFromEvents(Emitter& emitter);
~EmitFromEvents() override = default;
void OnDocumentStart(const Mark& mark) override; void OnDocumentStart(const Mark& mark) override;
void OnDocumentEnd() override; void OnDocumentEnd() override;

View File

@ -18,7 +18,7 @@
#include <valarray> #include <valarray>
#include <vector> #include <vector>
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __cplusplus >= 201703L
#include <string_view> #include <string_view>
#endif #endif
@ -93,7 +93,7 @@ struct convert<char[N]> {
static Node encode(const char* rhs) { return Node(rhs); } static Node encode(const char* rhs) { return Node(rhs); }
}; };
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __cplusplus >= 201703L
template <> template <>
struct convert<std::string_view> { struct convert<std::string_view> {
static Node encode(std::string_view rhs) { return Node(std::string(rhs)); } static Node encode(std::string_view rhs) { return Node(std::string(rhs)); }

View File

@ -97,7 +97,7 @@ struct as_if {
if (!node.m_pNode) if (!node.m_pNode)
return fallback; return fallback;
T t = fallback; T t;
if (convert<T>::decode(node, t)) if (convert<T>::decode(node, t))
return t; return t;
return fallback; return fallback;

View File

@ -213,8 +213,7 @@ void Emitter::EmitEndSeq() {
if (m_pState->CurGroupFlowType() == FlowType::Flow) { if (m_pState->CurGroupFlowType() == FlowType::Flow) {
if (m_stream.comment()) if (m_stream.comment())
m_stream << "\n"; m_stream << "\n";
if (originalType == FlowType::Block || m_pState->HasBegunNode()) m_stream << IndentTo(m_pState->CurIndent());
m_stream << IndentTo(m_pState->CurIndent());
if (originalType == FlowType::Block) { if (originalType == FlowType::Block) {
m_stream << "["; m_stream << "[";
} else { } else {

View File

@ -4,17 +4,11 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_MOCK ON CACHE BOOL "" FORCE) set(BUILD_MOCK ON CACHE BOOL "" FORCE)
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
if(YAML_USE_SYSTEM_GTEST) add_subdirectory(
find_package(GTest) "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.11.0"
if (NOT GTEST_FOUND) "${CMAKE_CURRENT_BINARY_DIR}/prefix")
message(FATAL_ERROR "system googletest was requested but not found")
endif() include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.11.0/googletest/include")
else()
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.11.0"
"${CMAKE_CURRENT_BINARY_DIR}/prefix")
include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.11.0/googletest/include")
endif()
set(test-new-api-pattern "new-api/*.cpp") set(test-new-api-pattern "new-api/*.cpp")
set(test-source-pattern "*.cpp" "integration/*.cpp" "node/*.cpp") set(test-source-pattern "*.cpp" "integration/*.cpp" "node/*.cpp")
@ -39,12 +33,11 @@ target_include_directories(yaml-cpp-tests
target_compile_options(yaml-cpp-tests target_compile_options(yaml-cpp-tests
PRIVATE PRIVATE
$<$<CXX_COMPILER_ID:Clang>:-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare> $<$<CXX_COMPILER_ID:Clang>:-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare>
$<$<CXX_COMPILER_ID:GNU>:-Wno-variadic-macros -Wno-sign-compare -Wno-narrowing>) $<$<CXX_COMPILER_ID:GNU>:-Wno-variadic-macros -Wno-sign-compare>)
target_link_libraries(yaml-cpp-tests target_link_libraries(yaml-cpp-tests
PRIVATE PRIVATE
Threads::Threads Threads::Threads
yaml-cpp yaml-cpp
gtest
gmock) gmock)
set_property(TARGET yaml-cpp-tests PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET yaml-cpp-tests PROPERTY CXX_STANDARD_REQUIRED ON)

View File

@ -1,21 +0,0 @@
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::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)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set_target_properties(main PROPERTIES CXX_STANDARD 11)
endif()
target_link_libraries(main PRIVATE ${YAML_CPP_LIBRARIES})

View File

@ -1,3 +0,0 @@
#include "yaml-cpp/yaml.h"
int main(int, char**) { YAML::Parser foo{}; }

View File

@ -176,17 +176,6 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) {
]])"); ]])");
} }
TEST_F(EmitterTest, EmptyFlowSeqInMap) {
out << BeginMap;
out << Key << Flow << BeginSeq << EndSeq;
out << Value << 1;
out << Key << 2;
out << Value << Flow << BeginSeq << EndSeq;
out << EndMap;
ExpectEmit("[]: 1\n2: []");
}
TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) { TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) {
out << Flow; out << Flow;
out << BeginSeq; out << BeginSeq;

View File

@ -20,10 +20,10 @@ class NullEventHandler : public YAML::EventHandler {
void OnScalar(const Mark&, const std::string&, anchor_t, void OnScalar(const Mark&, const std::string&, anchor_t,
const std::string&) override {} const std::string&) override {}
void OnSequenceStart(const Mark&, const std::string&, anchor_t, void OnSequenceStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value) override {} YAML::EmitterStyle::value style) override {}
void OnSequenceEnd() override {} void OnSequenceEnd() override {}
void OnMapStart(const Mark&, const std::string&, anchor_t, void OnMapStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value) override {} YAML::EmitterStyle::value style) override {}
void OnMapEnd() override {} void OnMapEnd() override {}
}; };

View File

@ -18,10 +18,10 @@ class NullEventHandler : public YAML::EventHandler {
void OnScalar(const Mark&, const std::string&, anchor_t, void OnScalar(const Mark&, const std::string&, anchor_t,
const std::string&) override {} const std::string&) override {}
void OnSequenceStart(const Mark&, const std::string&, anchor_t, void OnSequenceStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value) override {} YAML::EmitterStyle::value style) override {}
void OnSequenceEnd() override {} void OnSequenceEnd() override {}
void OnMapStart(const Mark&, const std::string&, anchor_t, void OnMapStart(const Mark&, const std::string&, anchor_t,
YAML::EmitterStyle::value) override {} YAML::EmitterStyle::value style) override {}
void OnMapEnd() override {} void OnMapEnd() override {}
}; };

View File

@ -11,23 +11,12 @@ set_and_check(YAML_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set_and_check(YAML_CPP_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") set_and_check(YAML_CPP_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
# Are we building shared libraries? # Are we building shared libraries?
set(YAML_CPP_SHARED_LIBS_BUILT @YAML_BUILD_SHARED_LIBS@) set(YAML_CPP_SHARED_LIBS_BUILT "@PACKAGE_YAML_BUILD_SHARED_LIBS@")
# Our library dependencies (contains definitions for IMPORTED targets) # Our library dependencies (contains definitions for IMPORTED targets)
include("${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-targets.cmake") include(@PACKAGE_CONFIG_EXPORT_DIR@/yaml-cpp-targets.cmake)
# These are IMPORTED targets created by yaml-cpp-targets.cmake # These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@")
# Protect against multiple inclusion, which would fail when already imported targets are added once more. check_required_components(@EXPORT_TARGETS@)
if(NOT TARGET yaml-cpp)
add_library(yaml-cpp INTERFACE IMPORTED)
target_link_libraries(yaml-cpp INTERFACE yaml-cpp::yaml-cpp)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
set_target_properties(yaml-cpp PROPERTIES
DEPRECATION "The target yaml-cpp is deprecated and will be removed in version 0.10.0. Use the yaml-cpp::yaml-cpp target instead."
)
endif()
endif()
check_required_components(yaml-cpp)