FindLibXml2: provide imported target LibXml2::xmllint

This commit is contained in:
Sylvain Joubert 2019-12-24 16:42:32 +01:00
parent a07134e339
commit a179cbf205
3 changed files with 19 additions and 2 deletions

View File

@ -0,0 +1,4 @@
xmllint-target
--------------
* The :module:`FindLibXml2` module now provides an imported target for the xmllint executable

View File

@ -10,8 +10,12 @@ Find the XML processing library (libxml2).
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if
libxml2 has been found.
The following :prop_tgt:`IMPORTED` targets may be defined:
``LibXml2::LibXml2``
If the libxml2 library has been found
``LibXml2::xmllint``
If the xmllint command-line executable has been found
Result variables
^^^^^^^^^^^^^^^^
@ -100,3 +104,8 @@ if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2)
set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
endif()
if(LIBXML2_XMLLINT_EXECUTABLE AND NOT TARGET LibXml2::xmllint)
add_executable(LibXml2::xmllint IMPORTED)
set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}")
endif()

View File

@ -14,3 +14,7 @@ add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${LIBXML2_INCLUDE_DIRS})
target_link_libraries(test_var PRIVATE ${LIBXML2_LIBRARIES})
add_test(NAME test_var COMMAND test_var)
add_test(NAME xmllint_tgt COMMAND LibXml2::xmllint --version)
add_test(NAME xmllint_var COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --version)