Skip to content

Commit d295a78

Browse files
authored
Merge branch 'TheCherno:master' into master
2 parents 0cf48de + b5b07c8 commit d295a78

File tree

342 files changed

+20484
-24155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+20484
-24155
lines changed

.github/workflows/build.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Github PR
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
workflow_dispatch:
8+
permissions: read-all
9+
jobs:
10+
cmake-build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
build: [static, shared]
16+
generator: ["Default Generator", "MinGW Makefiles"]
17+
exclude:
18+
- os: macos-latest
19+
build: shared
20+
- os: macos-latest
21+
generator: "MinGW Makefiles"
22+
- os: ubuntu-latest
23+
generator: "MinGW Makefiles"
24+
env:
25+
YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }}
26+
YAML_CPP_BUILD_TESTS: 'ON'
27+
CMAKE_GENERATOR: >-
28+
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Get number of CPU cores
34+
uses: SimenB/github-actions-cpu-cores@v1
35+
36+
- name: Build
37+
shell: bash
38+
run: |
39+
cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }}
40+
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
41+
42+
- name: Build Tests
43+
shell: bash
44+
run: |
45+
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 }}
46+
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
47+
48+
- name: Run Tests
49+
shell: bash
50+
run: |
51+
cd build && ctest -C Debug --output-on-failure --verbose
52+
53+
bazel-build:
54+
strategy:
55+
matrix:
56+
os: [ubuntu-latest, windows-latest, macos-latest]
57+
runs-on: ${{ matrix.os }}
58+
steps:
59+
- uses: actions/checkout@v2
60+
61+
- name: Build
62+
shell: bash
63+
run: |
64+
cd "${{ github.workspace }}"
65+
bazel build :all
66+
67+
- name: Test
68+
shell: bash
69+
run: |
70+
cd "${{ github.workspace }}"
71+
bazel test test
72+

.travis.yml

-37
This file was deleted.

BUILD.bazel

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
yaml_cpp_defines = select({
2+
# On Windows, ensure static linking is used.
3+
"@platforms//os:windows": ["YAML_CPP_STATIC_DEFINE", "YAML_CPP_NO_CONTRIB"],
4+
"//conditions:default": [],
5+
})
6+
17
cc_library(
28
name = "yaml-cpp_internal",
39
visibility = ["//:__subpackages__"],
@@ -11,4 +17,5 @@ cc_library(
1117
includes = ["include"],
1218
hdrs = glob(["include/**/*.h"]),
1319
srcs = glob(["src/**/*.cpp", "src/**/*.h"]),
20+
defines = yaml_cpp_defines,
1421
)

CMakeLists.txt

+60-28
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,41 @@ if(POLICY CMP0091)
77
cmake_policy(SET CMP0091 NEW)
88
endif()
99

10-
project(YAML_CPP VERSION 0.6.3 LANGUAGES CXX)
10+
project(YAML_CPP VERSION 0.7.0 LANGUAGES CXX)
11+
12+
set(YAML_CPP_MAIN_PROJECT OFF)
13+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
14+
set(YAML_CPP_MAIN_PROJECT ON)
15+
endif()
1116

1217
include(CMakePackageConfigHelpers)
1318
include(CMakeDependentOption)
1419
include(CheckCXXCompilerFlag)
1520
include(GNUInstallDirs)
1621
include(CTest)
1722

18-
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
19-
2023
option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
2124
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
2225
option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
23-
26+
option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT})
27+
option(YAML_CPP_FORMAT_SOURCE "Format source" ON)
2428
cmake_dependent_option(YAML_CPP_BUILD_TESTS
25-
"Enable yaml-cpp tests" ON
26-
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
27-
cmake_dependent_option(YAML_CPP_INSTALL
28-
"Enable generation of yaml-cpp install targets" ON
29-
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
29+
"Enable yaml-cpp tests" OFF
30+
"BUILD_TESTING;YAML_CPP_MAIN_PROJECT" OFF)
3031
cmake_dependent_option(YAML_MSVC_SHARED_RT
3132
"MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
32-
"MSVC" OFF)
33+
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF)
34+
35+
if (YAML_CPP_FORMAT_SOURCE)
36+
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
37+
endif()
3338

34-
set(yaml-cpp-type STATIC)
35-
set(yaml-cpp-label-postfix "static")
3639
if (YAML_BUILD_SHARED_LIBS)
3740
set(yaml-cpp-type SHARED)
3841
set(yaml-cpp-label-postfix "shared")
42+
else()
43+
set(yaml-cpp-type STATIC)
44+
set(yaml-cpp-label-postfix "static")
3945
endif()
4046

4147
set(build-shared $<BOOL:${YAML_BUILD_SHARED_LIBS}>)
@@ -78,6 +84,10 @@ set_property(TARGET yaml-cpp
7884
PROPERTY
7985
CXX_STANDARD_REQUIRED ON)
8086

87+
if (NOT YAML_BUILD_SHARED_LIBS)
88+
set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ON)
89+
endif()
90+
8191
target_include_directories(yaml-cpp
8292
PUBLIC
8393
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
@@ -91,11 +101,15 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
91101
CXX_STANDARD 11)
92102
endif()
93103

104+
if(YAML_CPP_MAIN_PROJECT)
105+
target_compile_options(yaml-cpp
106+
PRIVATE
107+
$<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long>
108+
$<${not-msvc}:-pedantic -pedantic-errors>)
109+
endif()
110+
94111
target_compile_options(yaml-cpp
95112
PRIVATE
96-
$<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long>
97-
$<${not-msvc}:-pedantic -pedantic-errors>
98-
99113
$<$<AND:${backport-msvc-runtime},${msvc-rt-mtd-static}>:-MTd>
100114
$<$<AND:${backport-msvc-runtime},${msvc-rt-mt-static}>:-MT>
101115
$<$<AND:${backport-msvc-runtime},${msvc-rt-mtd-dll}>:-MDd>
@@ -108,6 +122,8 @@ target_compile_options(yaml-cpp
108122
$<$<CXX_COMPILER_ID:MSVC>:/W3 /wd4127 /wd4355>)
109123

110124
target_compile_definitions(yaml-cpp
125+
PUBLIC
126+
$<$<NOT:$<BOOL:${YAML_BUILD_SHARED_LIBS}>>:YAML_CPP_STATIC_DEFINE>
111127
PRIVATE
112128
$<${build-windows-dll}:${PROJECT_NAME}_DLL>
113129
$<$<NOT:$<BOOL:${YAML_CPP_BUILD_CONTRIB}>>:YAML_CPP_NO_CONTRIB>)
@@ -127,10 +143,14 @@ set_target_properties(yaml-cpp PROPERTIES
127143
PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}"
128144
DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
129145

146+
set(CONFIG_EXPORT_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/yaml-cpp")
147+
set(EXPORT_TARGETS yaml-cpp)
130148
configure_package_config_file(
131149
"${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in"
132150
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
133-
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
151+
INSTALL_DESTINATION "${CONFIG_EXPORT_DIR}"
152+
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR CONFIG_EXPORT_DIR YAML_BUILD_SHARED_LIBS)
153+
unset(EXPORT_TARGETS)
134154

135155
write_basic_package_version_file(
136156
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
@@ -139,36 +159,48 @@ write_basic_package_version_file(
139159
configure_file(yaml-cpp.pc.in yaml-cpp.pc @ONLY)
140160

141161
if (YAML_CPP_INSTALL)
142-
install(TARGETS yaml-cpp
162+
install(TARGETS yaml-cpp
143163
EXPORT yaml-cpp-targets
144164
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
145165
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
146166
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
147-
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
167+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
148168
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
149-
FILES_MATCHING PATTERN "*.h")
169+
FILES_MATCHING PATTERN "*.h")
150170
install(EXPORT yaml-cpp-targets
151-
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
152-
install(FILES
153-
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
154-
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
155-
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp")
171+
DESTINATION "${CONFIG_EXPORT_DIR}")
172+
install(FILES
173+
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
174+
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
175+
DESTINATION "${CONFIG_EXPORT_DIR}")
156176
install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc"
157-
DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig)
177+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
158178
endif()
179+
unset(CONFIG_EXPORT_DIR)
159180

160181
if(YAML_CPP_BUILD_TESTS)
161-
add_subdirectory(test)
182+
add_subdirectory(test)
162183
endif()
163184

164185
if(YAML_CPP_BUILD_TOOLS)
165-
add_subdirectory(util)
186+
add_subdirectory(util)
166187
endif()
167188

168-
if (YAML_CPP_CLANG_FORMAT_EXE)
189+
if (YAML_CPP_FORMAT_SOURCE AND YAML_CPP_CLANG_FORMAT_EXE)
169190
add_custom_target(format
170191
COMMAND clang-format --style=file -i $<TARGET_PROPERTY:yaml-cpp,SOURCES>
171192
COMMAND_EXPAND_LISTS
172193
COMMENT "Running clang-format"
173194
VERBATIM)
174195
endif()
196+
197+
# uninstall target
198+
if(NOT TARGET uninstall)
199+
configure_file(
200+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
201+
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
202+
IMMEDIATE @ONLY)
203+
204+
add_custom_target(uninstall
205+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
206+
endif()

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Commit messages should be in the imperative mood, as described in the [Git contr
1717

1818
# Tests
1919

20-
Please verify the tests pass by running the target `tests/run_tests`.
20+
Please verify the tests pass by running the target `test/yaml-cpp-tests`.
2121

2222
If you are adding functionality, add tests accordingly.
2323

README.md

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
1-
# yaml-cpp [![Build Status](https://travis-ci.org/jbeder/yaml-cpp.svg?branch=master)](https://travis-ci.org/jbeder/yaml-cpp) [![Documentation](https://codedocs.xyz/jbeder/yaml-cpp.svg)](https://codedocs.xyz/jbeder/yaml-cpp/)
1+
# yaml-cpp ![Build Status](https://github.com/jbeder/yaml-cpp/actions/workflows/build.yml/badge.svg) [![Documentation](https://codedocs.xyz/jbeder/yaml-cpp.svg)](https://codedocs.xyz/jbeder/yaml-cpp/)
22

3-
yaml-cpp is a [YAML](http://www.yaml.org/) parser and emitter in C++ matching the [YAML 1.2 spec](http://www.yaml.org/spec/1.2/spec.html).
3+
`yaml-cpp` is a [YAML](http://www.yaml.org/) parser and emitter in C++ matching the [YAML 1.2 spec](http://www.yaml.org/spec/1.2/spec.html).
44

5-
To get a feel for how it can be used, see the [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) or [How to Emit YAML](https://github.com/jbeder/yaml-cpp/wiki/How-To-Emit-YAML). For the old API (version < 0.5.0), see [How To Parse A Document](https://github.com/jbeder/yaml-cpp/wiki/How-To-Parse-A-Document-(Old-API)).
5+
## Usage
66

7-
# Problems? #
7+
See [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) and [How to Emit YAML](https://github.com/jbeder/yaml-cpp/wiki/How-To-Emit-YAML) for reference. For the old API (until 0.5.0), see [How To Parse A Document](https://github.com/jbeder/yaml-cpp/wiki/How-To-Parse-A-Document-(Old-API)).
88

9-
If you find a bug, post an [issue](https://github.com/jbeder/yaml-cpp/issues)! If you have questions about how to use yaml-cpp, please post it on http://stackoverflow.com and tag it [`yaml-cpp`](http://stackoverflow.com/questions/tagged/yaml-cpp).
9+
## Any Problems?
1010

11-
# How to Build #
11+
If you find a bug, post an [issue](https://github.com/jbeder/yaml-cpp/issues)! If you have questions about how to use yaml-cpp, please post it on http://stackoverflow.com and tag it [`yaml-cpp`](http://stackoverflow.com/questions/tagged/yaml-cpp).
1212

13-
yaml-cpp uses [CMake](http://www.cmake.org) to support cross-platform building. The basic steps to build are:
13+
## How to Build
1414

15-
1. Download and install [CMake](http://www.cmake.org) (Resources -> Download).
15+
`yaml-cpp` uses [CMake](http://www.cmake.org) to support cross-platform building. Install [CMake](http://www.cmake.org) _(Resources -> Download)_ before proceeding. The basic steps to build are:
1616

17-
**Note:** If you don't use the provided installer for your platform, make sure that you add CMake's bin folder to your path.
17+
**Note:** If you don't use the provided installer for your platform, make sure that you add `CMake`'s bin folder to your path.
1818

19-
2. Navigate into the source directory, and type:
19+
#### 1. Navigate into the source directory, create build folder and run `CMake`:
2020

21-
```
21+
```sh
2222
mkdir build
2323
cd build
24+
cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] ..
2425
```
2526

26-
3. Run CMake. The basic syntax is:
27-
28-
```
29-
cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=ON|OFF] ..
30-
```
31-
32-
* The `generator` is whatever type of build system you'd like to use. To see a full list of generators on your platform, just run `cmake` (with no arguments). For example:
33-
* On Windows, you might use "Visual Studio 12 2013" to generate a Visual Studio 2013 solution or "Visual Studio 14 2015 Win64" to generate a 64-bit Visual Studio 2015 solution.
34-
* On OS X, you might use "Xcode" to generate an Xcode project
35-
* On a UNIX-y system, simply omit the option to generate a makefile
27+
* The `generator` option is the build system you'd like to use. Run `cmake` without arguments to see a full list of available generators.
28+
* On Windows, you might use "Visual Studio 12 2013" (VS 2013 32-bits), or "Visual Studio 14 2015 Win64" (VS 2015 64-bits).
29+
* On OS X, you might use "Xcode".
30+
* On a UNIX-like system, omit the option (for a Makefile).
3631

37-
* yaml-cpp defaults to building a static library, but you may build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`.
32+
* `yaml-cpp` builds a static library by default, you may want to build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`.
3833

3934
* For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file.
4035

41-
4. Build it!
36+
#### 2. Build it!
37+
* The command you'll need to run depends on the generator you chose earlier.
4238

43-
5. To clean up, just remove the `build` directory.
39+
**Note:** To clean up, just remove the `build` directory.
4440

45-
# Recent Release #
41+
## Recent Releases
4642

47-
[yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) has been released! This release requires C++11, and no longer depends on Boost.
43+
[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.
4844

4945
[yaml-cpp 0.3.0](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.3.0) is still available if you want the old API.
5046

@@ -59,3 +55,4 @@ The autogenerated API reference is hosted on [CodeDocs](https://codedocs.xyz/jbe
5955
The following projects are not officially supported:
6056

6157
- [Qt wrapper](https://gist.github.com/brcha/d392b2fe5f1e427cc8a6)
58+
- [UnrealEngine Wrapper](https://github.com/jwindgassen/UnrealYAML)

0 commit comments

Comments
 (0)