-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
ac144ed
commit c26e047
Showing
5 changed files
with
89 additions
and
22 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
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
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::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