1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

Check if target exists when reading target properties

This commit is contained in:
Markus Rickert
2020-12-31 13:18:14 +01:00
parent ec11987592
commit c26e45259c

View File

@@ -31,6 +31,7 @@ set(LIBXML2_INCLUDE_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/libx
set(LIBXML2_LIBRARY_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)
macro(select_library_location target basename)
if(TARGET ${target})
foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
@@ -53,9 +54,11 @@ macro(select_library_location target basename)
set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
endif()
endforeach()
endif()
endmacro()
macro(select_executable_location target basename)
if(TARGET ${target})
get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG)
get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL)
get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE)
@@ -70,6 +73,7 @@ macro(select_executable_location target basename)
elseif(${basename}_IMPORTED_LOCATION_DEBUG)
set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG})
endif()
endif()
endmacro()
select_library_location(LibXml2::LibXml2 LIBXML2)