summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2019-12-24 15:42:32 (GMT)
committerSylvain Joubert <joubert.sy@gmail.com>2019-12-31 11:45:26 (GMT)
commita179cbf205501b6470d2f8e892876cc8672e7096 (patch)
treefe85ec5e17f16ba376fb31eb3fa0b160cb9b59c9
parenta07134e33934bdd4b50d2a4d3293fcd3f495a3d6 (diff)
downloadCMake-a179cbf205501b6470d2f8e892876cc8672e7096.zip
CMake-a179cbf205501b6470d2f8e892876cc8672e7096.tar.gz
CMake-a179cbf205501b6470d2f8e892876cc8672e7096.tar.bz2
FindLibXml2: provide imported target LibXml2::xmllint
-rw-r--r--Help/release/dev/xmllint-target.rst4
-rw-r--r--Modules/FindLibXml2.cmake13
-rw-r--r--Tests/FindLibXml2/Test/CMakeLists.txt4
3 files changed, 19 insertions, 2 deletions
diff --git a/Help/release/dev/xmllint-target.rst b/Help/release/dev/xmllint-target.rst
new file mode 100644
index 0000000..19c69bf
--- /dev/null
+++ b/Help/release/dev/xmllint-target.rst
@@ -0,0 +1,4 @@
+xmllint-target
+--------------
+
+* The :module:`FindLibXml2` module now provides an imported target for the xmllint executable
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index da8bfe0..9480cea 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -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()
diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt
index df5d8c3..041cc13 100644
--- a/Tests/FindLibXml2/Test/CMakeLists.txt
+++ b/Tests/FindLibXml2/Test/CMakeLists.txt
@@ -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)