CMake: rename imported yamlcpp library

- call it yamlcpp::yamlcpp

This is source-incompatible if targets link explicitly to yamlcpp
This commit is contained in:
Adriaan de Groot 2021-07-26 14:34:10 +02:00
parent 03e621f4a2
commit ce67712009

View File

@ -13,7 +13,7 @@
# YAMLCPP_LIBRARY, where to find yaml-cpp # YAMLCPP_LIBRARY, where to find yaml-cpp
# YAMLCPP_INCLUDE_DIR, where to find yaml.h # YAMLCPP_INCLUDE_DIR, where to find yaml.h
# There is also one IMPORTED library target, # There is also one IMPORTED library target,
# yamlcpp # yamlcpp::yamlcpp
# #
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead, # By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...). # you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...).
@ -21,6 +21,10 @@
# If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable # If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable
# to tell CMake where yaml-cpp is. # to tell CMake where yaml-cpp is.
if(TARGET yamlcpp::yamlcpp)
return()
endif()
# attempt to find static library first if this is set # attempt to find static library first if this is set
if(YAMLCPP_STATIC_LIBRARY) if(YAMLCPP_STATIC_LIBRARY)
set(YAMLCPP_STATIC libyaml-cpp.a) set(YAMLCPP_STATIC libyaml-cpp.a)
@ -61,9 +65,9 @@ mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
# Add an imported target # Add an imported target
if( YAMLCPP_LIBRARY ) if( YAMLCPP_LIBRARY )
add_library( yamlcpp UNKNOWN IMPORTED ) add_library( yamlcpp::yamlcpp UNKNOWN IMPORTED )
set_property( TARGET yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} ) set_property( TARGET yamlcpp::yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} )
if ( YAMLCPP_INCLUDE_DIR ) if ( YAMLCPP_INCLUDE_DIR )
set_property( TARGET yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} ) set_property( TARGET yamlcpp::yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} )
endif() endif()
endif() endif()