mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00

* 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>
20 lines
684 B
CMake
20 lines
684 B
CMake
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)
|
|
set_target_properties(main PROPERTIES CXX_STANDARD 11)
|
|
target_link_libraries(main PRIVATE ${YAML_CPP_LIBRARIES})
|