mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 19:49:51 +00:00
FindLibXml2: provide imported target LibXml2::LibXml2
This commit is contained in:
parent
156a959410
commit
9ef3abd3f3
4
Help/release/dev/libxml2-target.rst
Normal file
4
Help/release/dev/libxml2-target.rst
Normal file
@ -0,0 +1,4 @@
|
||||
libxml2-target
|
||||
--------------
|
||||
|
||||
* The :module:`FindLibXml2` module now provides imported targets.
|
@ -7,6 +7,12 @@
|
||||
#
|
||||
# Find the XML processing library (libxml2).
|
||||
#
|
||||
# IMPORTED Targets
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if
|
||||
# libxml2 has been found.
|
||||
#
|
||||
# Result variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
@ -87,3 +93,9 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2
|
||||
VERSION_VAR LIBXML2_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_XMLLINT_EXECUTABLE)
|
||||
|
||||
if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2)
|
||||
add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
|
||||
set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
|
||||
set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
|
||||
endif()
|
||||
|
@ -1371,6 +1371,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||
add_subdirectory(FindLibUV)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindLibXml2)
|
||||
add_subdirectory(FindLibXml2)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindLTTngUST)
|
||||
add_subdirectory(FindLTTngUST)
|
||||
endif()
|
||||
|
10
Tests/FindLibXml2/CMakeLists.txt
Normal file
10
Tests/FindLibXml2/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_test(NAME FindLibXml2.Test COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindLibXml2/Test"
|
||||
"${CMake_BINARY_DIR}/Tests/FindLibXml2/Test"
|
||||
${build_generator_args}
|
||||
--build-project TestFindLibXml2
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
16
Tests/FindLibXml2/Test/CMakeLists.txt
Normal file
16
Tests/FindLibXml2/Test/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
project(TestFindLibXml2 C)
|
||||
include(CTest)
|
||||
|
||||
find_package(LibXml2 REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_LibXml2_VERSION="${LIBXML2_VERSION_STRING}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt LibXml2::LibXml2)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
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)
|
19
Tests/FindLibXml2/Test/main.c
Normal file
19
Tests/FindLibXml2/Test/main.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <assert.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
xmlDoc* doc;
|
||||
|
||||
xmlInitParser();
|
||||
|
||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
assert(strstr(CMAKE_EXPECTED_LibXml2_VERSION, LIBXML_DOTTED_VERSION));
|
||||
|
||||
xmlCleanupParser();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user