[libxml2] Check if variables exist when defining targets



commit 95519737af0d5c1835d074f61c468ff8da150f56
Author: Markus Rickert <rickert fortiss org>
Date:   Thu Dec 31 13:41:19 2020 +0100

    Check if variables exist when defining targets

 libxml2-config.cmake.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/libxml2-config.cmake.in b/libxml2-config.cmake.in
index 993bc1af..97bbcb51 100644
--- a/libxml2-config.cmake.in
+++ b/libxml2-config.cmake.in
@@ -90,7 +90,7 @@ set(LIBXML2_MODULES @WITH_MODULES@)
 
 mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
 
-if(NOT TARGET LibXml2::LibXml2)
+if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS)
   add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
   set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
   set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}")
@@ -98,12 +98,12 @@ if(NOT TARGET LibXml2::LibXml2)
   set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES 
"${LIBXML2_INTERFACE_LINK_LIBRARIES}")
 endif()
 
-if(NOT TARGET LibXml2::xmlcatalog)
+if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE)
   add_executable(LibXml2::xmlcatalog IMPORTED)
   set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}")
 endif()
 
-if(NOT TARGET LibXml2::xmllint)
+if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE)
   add_executable(LibXml2::xmllint IMPORTED)
   set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}")
 endif()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]