Commit Graph

139 Commits

Author SHA1 Message Date
Gianfranco Costamagna
145eec5f3e
Add CMake option YAML_USE_SYSTEM_GTEST to use system googletest if available. (#1035)
There is no need to use the embedded gtest code copy in Linux systems, if they already provide the googletest framework system-wide.
Search for it, and fallback to the embedded one if the system one is not detected.

This patch has been also contributed by Simon Quigley <tsimonq2@debian.org>
2023-10-22 00:06:39 -05:00
Pierre Wendling
c26e047223
CMake: Fixes for generated config (#1212)
* CMake: Add option to set the package install dir.

* CMake: Fix generated config.

- `YAML_CPP_SHARED_LIBS_BUILT` should not be set with a `PATH_VAR` as it
would always evaluate to true.
- `YAML_CPP_LIBRARIES` should used the exported target name including
the namespace, but `check_required_components` shouldn't.
- Use `CMAKE_CURRENT_LIST_DIR` to find the target file, instead of a
`PATH_VAR`. Package managers such as vcpkg move CMake configs after
installing.

* CI: Test the generated CMake package.

* CMake: Create add a deprecated yaml-cpp target.

This target is meant to provide compatibility with versions prior to
0.8.0.

* CMake: mark the yaml-cpp target as IMPORTED.

---------

Co-authored-by: Jesse Beder <jbeder+github@gmail.com>
2023-10-12 11:48:16 -04:00
Megamouse
ac144ed46c
Hide uninstall target unless YAML_CPP_INSTALL is set, and allow it to be disabled by YAML_CPP_DISABLE_UNINSTALL
add_custom_target uninstall causes a clash with the same target in rtmidi (https://github.com/thestk/rtmidi).
"add_custom_target cannot create target "uninstall" because another target with the same name already exists.  The existing target is a custom target created in source directory"

Adds new option YAML_CPP_DISABLE_UNINSTALL 

fixes #1151

---------

Co-authored-by: Megamouse <studienricky89@googlemail.de>
Co-authored-by: Jesse Beder <jbeder+github@gmail.com>
2023-10-11 00:02:33 -04:00
Alfi Maulana
4c061a5058
Disable format target when not building as the main project (#1231) 2023-10-10 23:40:09 -04:00
Craig Scott
c268020048
Specify CMake policy range to avoid deprecation warning (#1211) 2023-08-16 17:54:05 -05:00
Jesse Beder
f732014112 Bump version to 0.8.0. 2023-08-10 14:27:56 -05:00
Ryan
b8882652fc
Add namespace for the exported targets (#1196)
This matches the name for the ALIAS targets, and fixes #1025.
2023-06-28 11:37:09 -05:00
Jesse Beder
0e6e28d1a3
Revert "Move CTest to test entry (#1181)" (#1182)
This reverts commit 74f63c1181.
2023-03-22 19:14:49 -05:00
Jelin
74f63c1181
Move CTest to test entry (#1181) 2023-03-21 11:24:19 -05:00
Matthijs van der Burgh
3ff7ab07ac
Make sure tests are run in CI (#1170)
* Test(CMake) set NAME and COMMAND in add_test

* (CMake) add enable_testing()

* (CMake) move cmake_dependent_option up, before using them

* (CMake) use YAML_CPP_MAIN_PROJECT in cmake_dependent_option

* (CMake) log values regarding tests

* (CMake) always find CTest, but don't enable tests

* (CMAKE)(temp) fix logging

* (actions) set YAML_CPP_BUILD_TESTS for tests

* (actions) provide YAML_CPP_BUILD_TESTS to ctest

* (actions) set -DYAML_CPP_BUILD_TESTS at build

* (actions) don't fail false

* (actions) build tests in Test step

* (actions) run tests verbose

* (CMake) remove temp logging

* (actions) split building from running tests

* (actions) ctest Debug

* (actions) ctest Debug

* Remove enable_testing
2023-03-04 14:06:01 -06:00
Derzsi Dániel
97ebcf035a
Export library directory and shared libs to CMake config (#1113)
This pull request adds two new exported variables to the CMake config:

YAML_CPP_LIBRARY_DIR - points to the directory containing the built library files
YAML_CPP_SHARED_LIBS_BUILT - boolean value, lets users know whether shared libraries were built or not
2022-09-20 00:26:59 -05:00
stephematician
85ad599d79
Basic update to CMakeLists.txt to address #1116 (#1117)
Add definitions to static yaml-cpp target (fixes #1116)

Also updates CONTRIBUTING instructions for tests
2022-09-20 00:24:35 -05:00
Baruch
c86a9e424c
Minimize warnings when not the top-level project (#1124)
Minimize warnings when not the top-level project

Should fix #970 and #764 when trying to add yaml-cpp to other project
2022-09-20 00:22:11 -05:00
Timo Gurr
255bf1f9bc
Install pkgconfig and cmake files into arch-dependent locations (#1055) 2022-09-20 00:17:13 -05:00
Skywol
e87ed7e5b1
Add the "make uninstall" target (#1130) 2022-09-20 00:03:40 -05:00
SpaceIm
7d06655611
Allow yaml-cpp to be installed from another project (#1007)
Changes YAML_CPP_INSTALL from a cmake_dependent_option to an option.

Fixes #756, #847, and #1011.
2022-04-03 16:57:28 -05:00
xiaozhuai, Weihang Ding
0e6e98e8fb
Extend options that disable testing and formatting to looking for dependencies also. (#1039)
The option `YAML_CPP_BUILD_TESTS` currently enables or disables building of tests; but unconditionally the CMake file includes CTest; this PR makes that conditional on the option.

Also, there is no option for enabling formatting, but it does check whether it can find the `clang-format` executable; this PR adds an option (default to true) that skips even looking for the executable if disabled.
2022-03-31 22:36:43 -05:00
Felix Schwitzer
4aad2b1666
Fix CMake export files (#1077)
After configuring the file `yaml-cpp-config.cmake.in`, the result ends up with
empty variables.  (see also the discussion in #774).

Rework this file and the call to `configure_package_config_file` according the
cmake documentation
(https://cmake.org/cmake/help/v3.22/module/CMakePackageConfigHelpers.html?highlight=configure_package_config#command:configure_package_config_file)
to overcome this issue and allow a simple `find_package` after install.

As there was some discussion about the place where to install the
`yaml-cpp-config.cmake` file, e.g. #1055, factor out the install location into
an extra variable to make it easier changing this location in the future.

Also untabify CMakeLists.txt in some places to align with the other code parts in this file.
2022-03-31 22:26:47 -05:00
Michael Martz
669af4eb55
Make YAML_MSVC_SHARED_RT depend on "CMAKE_SYSTEM_NAME MATCHES Windows" instead of "MSVC".
Fixes issue #1053.
2022-03-31 22:13:19 -05:00
Christian Rauch
cdf89fa352
set POSITION_INDEPENDENT_CODE if BUILD_SHARED_LIBS=OFF (#1076) 2022-01-27 17:03:10 -06:00
Pavel Karelin
2b65c65e1b
Partially revert commit 0733aeb4 to make dll.h a non-generated file (#1064)
Partial revert of "Revert "Revert "Hide most of non-public symbols by default (#984)" (#1038)" (#1045)"

This reverts commit 0733aeb451.
2021-11-22 22:40:08 -06:00
Pino Toscano
0733aeb451
Revert "Revert "Hide most of non-public symbols by default (#984)" (#1038)" (#1045) 2021-10-09 21:48:05 -05:00
Jesse Beder
0d9dbcfe8c
Revert "Hide most of non-public symbols by default (#984)" (#1038)
This reverts commit da1c8d360e. and fixes #1036.
2021-09-28 08:41:55 -05:00
Pino Toscano
da1c8d360e
Hide most of non-public symbols by default (#984)
* Export YAML::detail::node::m_amount

The internal header node/detail/node.h is included by public headers;
YAML::detail::node is implemented in the header itself, and thus it gets
inlined... except for its static m_amount class member, which is
instantiated in the library only. Right now all the symbols of yaml-cpp
are exported (nothing is hidden), so the linker will find node::m_amount
in the yaml-cpp library.

As solution/workaround, explicitly export YAML::detail::node::m_amount.

* CMake: use GenerateExportHeader

Make use of the GenerateExportHeader CMake module to generate the dll.h
header with export macros.

While the produced dll.h is different, the result should be the same,
i.e. nothing changes for yaml-cpp or its users.

* CMake: hide all the symbols by default

Hide all the symbols that are not explicitly exported with YAML_CPP_API.
This way the ABI will be way smaller, and only actually exposing the
public classes/functions.
2021-09-25 12:10:58 -05:00
Jesse Beder
0579ae3d97 Update version to 0.7.0. 2021-07-10 10:53:22 -05:00
Tom Collins
370aceeaf8
Enable CMP0091 to use MSVC_RUNTIME_LIBRARY (#913)
Per https://cmake.org/cmake/help/latest/policy/CMP0091.html, we need to
enable policy CMP0091 if we want to make use of MSVC_RUNTIME_LIBRARY
and/or CMAKE_MSVC_RUNTIME_LIBRARY.  Fixes issue #912.
2020-07-07 20:38:10 -05:00
Hans-Peter Gygax
cb7bb9821d
Change CMakeLists to honor option "MSVC shared Runtimes" (#867) 2020-05-24 12:55:52 -05:00
deflinhec
513ee81fbf
Make debug postfix optional (#856)
Library debug postfix might not be suitable for cross platform project, and usually require extra work of link against prebuilt yaml-cpp.

Generally, Xcode project output library to these directories:
    Debug
    Release
    Debug-iphoneos
    Release-iphoneos
    Debug-iphonesimulator
    Release-iphonesimulator

Another Xcode project usually configured its build setting as follow, and expects library name to be same between Release and Debug
    LIBRARY_SEARCH_PATHS=$(CONFIGURATION)$(EFFECT_PLATFORM_NAME)
    OTHER_LDFLAGS= $(inherited) -lyaml-cpp
2020-04-29 09:58:05 -05:00
Ian Taylor
9f2781b527
Fix clang format (#854)
Fix invocation of clang-format in CMakeLists and apply clang-format.
2020-04-29 09:40:33 -05:00
Carlos Gomes Martinho
587b24e2ee Use de-facto standard CMake namespace convention (#792)
Change the namespace from yaml::yaml to yaml-cpp::yaml-cpp.
2019-11-29 17:02:21 -06:00
Mike Egger
a8ba6a8dca Adapt label postfix to fix build with Visual Studio (#782) 2019-10-31 09:35:12 -05:00
Isabella Muerte
52a1378e48 Default YAML_BUILD_SHARED_LIBS to BUILD_SHARED_LIBS
🐛 Fixes #748 (#770)
2019-10-13 15:50:40 -05:00
Fatih YAZICI
21d75fa4cd Fix CMake 3.10 and below compatibility (#763)
Add empty list of sources to add_library and add_executable.
2019-10-04 14:46:18 -05:00
Andy Maloney
47d32aadf0 CMake: Remove unused option YAML_APPLE_UNIVERSAL_BIN (#744) 2019-09-27 12:26:35 -05:00
Isabella Muerte
9d7e556ed5 Fix DEBUG_POSTFIX property (#746)
The generator expressions here are actually unnecessary, now that I think about it.

This should fix #745
2019-09-27 12:25:27 -05:00
Isabella Muerte
5e9cb0128d Refactor CMake to use more modern paradigms (#741)
Remove 2.6-isms
Remove 2.8-isms
Bump CMake minimum version to 3.4

Disable some options when used as a subdirectory

Use `CONFIGURE_DEPENDS` with `file(GLOB)` when possible

Backport CMake 3.15's MSVC_RUNTIME_LIBRARY setting.
Set all compile options as generator expressions.
Set all find-package files to be installed to the correct file.

Remove `export(PACKAGE)`, as this has been deprecated.
Remove fat binary support
Remove manual setting of iPhone settings. These should be set by parent
projects.
Remove use of ExternalProject for a local use
Conditionally remove format target unless clang-format is found
2019-09-27 09:59:53 -05:00
Jesse Beder
9a3624205e
Update version to 0.6.3. 2019-09-25 09:56:00 -07:00
Andy Maloney
968e0c1f02 Fix shared lib build with new YAML_BUILD_SHARED_LIBS option (#737) 2019-09-14 21:21:35 -04:00
Andy Maloney
6cdf363625 CMake: Prefix options with "YAML" and hide platform-specific options (#734)
* CMake: Prefix options with "YAML" and hide platform-specific options

When including yaml-cpp as a subproject, some option names can conflict with other projects.

(1) Make sure the yaml-cpp options are prefixed with YAML
(2) Hide platform-specific options when possible to avoid cluttering the cmake option list

* Update docs for change from BUILD_SHARED_LIBS to YAML_BUILD_SHARED_LIBS
2019-09-10 10:00:07 -07:00
Andy Maloney
d638508d33 Set C++ standard options in CMake per-target instead of globally (#735)
Setting CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED directly is problematic when including yaml-cpp as a subproject.

The proper way is to set these per-target.
2019-09-10 07:51:13 -07:00
Andy Maloney
90350662c9 Use VERSION on the CMake project (#733)
This sets the other variables:

 https://cmake.org/cmake/help/latest/command/project.html
2019-09-10 07:50:10 -07:00
Ted Lyngmo
0d5c57150c Apply formatting/style tweaks to comply with compile time diagnostics for g++ and clang++ (#686)
* Add compilation flags: -Wshadow -Weffc++ -pedantic -pedantic-errors
* Delete implicit copy & move constructors & assignment operators
  in classes with pointer data members.
* An exception to the above: Add default copy & move constructors &
  assignment operators for the Binary class.
* Convert boolean RegEx operators to binary operators.
* Initialize all members in all classes in ctors.
* Let default ctor delegate to the converting ctor in
  Binary and RegEx
* Don't change any tests except regex_test (as a result of the change
  to binary operators).

Note: https://bugzilla.redhat.com/show_bug.cgi?id=1544675 makes
-Weffc++ report a false positive in "include/yaml-cpp/node/impl.h".
2019-03-13 15:18:34 -07:00
Olli Wang
a2a113c6ff Fix ninja build error. (#677)
NDK now uses ninja for building but yaml-cpp would emit the “ninja: error: build.ninja:326: bad $-escape (literal $ must be written as $$)” error due to syntax error in the generated build.ninja file. Related issue: https://github.com/jbeder/yaml-cpp/issues/630
2019-02-27 14:58:45 -06:00
pent0
b87c76a2ef Fix GCC-types flags appended on Clang-cl (#659) 2019-01-06 00:23:52 -06:00
Joel Frederico
2443da5224 Don't stomp on build flags (#635)
Let CMake handle the default optimizations for various configurations. We don't need to override them. In fact, overriding them makes it impossible for users to override them themselves.
2018-11-19 09:10:10 -06:00
Lassi Hämäläinen
54fc4dadbb Add YAML_CPP_INSTALL option for disabling install target (#624) (#625)
- Option defaults to ON and setting it to OFF, disables install
  target generation
2018-11-18 11:27:15 -06:00
Azamat H. Hackimov
5e79f5eed3 Improvements to CMake buildsystem
Roll-forward of c90c08ccc9 "Revert "Improvements to CMake buildsystem (#563)""

NEW:

* Replace CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR

Fixes #612 when yaml-cpp is used as a git submodule.

ORIGINAL:

* Move enable_testing() into proper place

* Added CMake's checks for C++11 standards

Raised minimal version of CMake to 3.1, since on old systems there no
decent compilers that supports c++11.

Closes #377.

* Externalize googletest project

Externalize gtest to avoid installation, fixes #539.

* Remove defined cmake_policies

CMP0012 - OLD marked as deprecated for >=cmake-3.1 and will be removed
CMP0015 - does not affect to build process
CMP0042 - already NEW for >=cmake-3.1

Fixes #505

* Fix compiling in Windows MSVC
2018-09-03 10:37:06 -05:00
Jesse Beder
c90c08ccc9 Revert "Improvements to CMake buildsystem (#563)"
This reverts commit 3e33bb3166.

The original commit broke the build (#612) when yaml-cpp is used as a git submodule.
2018-08-09 10:05:07 -05:00
Azamat H. Hackimov
3e33bb3166 Improvements to CMake buildsystem (#563)
* Move enable_testing() into proper place

* Added CMake's checks for C++11 standards

Raised minimal version of CMake to 3.1, since on old systems there no
decent compilers that supports c++11.

Closes #377.

* Externalize googletest project

Externalize gtest to avoid installation, fixes #539.

* Remove defined cmake_policies

CMP0012 - OLD marked as deprecated for >=cmake-3.1 and will be removed
CMP0015 - does not affect to build process
CMP0042 - already NEW for >=cmake-3.1

Fixes #505

* Fix compiling in Windows MSVC
2018-08-09 07:11:50 -05:00
Patrick Stotko
ab5f9259a4 Use target-based include_directories to enable modern CMake usage (#583) 2018-05-05 11:03:13 -05:00