diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2018-03-05 22:42:35 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2018-03-08 17:31:12 (GMT) |
commit | 9ef3abd3f39542ecbdfda0014a7f1b4c3bea50a9 (patch) | |
tree | aff61661ec3b78f7b2ce0017b3e5f36c76636efd /Tests/FindLibXml2 | |
parent | 156a959410cfbd33c648e7b8993d32fd8f9af00a (diff) | |
download | CMake-9ef3abd3f39542ecbdfda0014a7f1b4c3bea50a9.zip CMake-9ef3abd3f39542ecbdfda0014a7f1b4c3bea50a9.tar.gz CMake-9ef3abd3f39542ecbdfda0014a7f1b4c3bea50a9.tar.bz2 |
FindLibXml2: provide imported target LibXml2::LibXml2
Diffstat (limited to 'Tests/FindLibXml2')
-rw-r--r-- | Tests/FindLibXml2/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindLibXml2/Test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/FindLibXml2/Test/main.c | 19 |
3 files changed, 45 insertions, 0 deletions
diff --git a/Tests/FindLibXml2/CMakeLists.txt b/Tests/FindLibXml2/CMakeLists.txt new file mode 100644 index 0000000..6c2464f --- /dev/null +++ b/Tests/FindLibXml2/CMakeLists.txt @@ -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> + ) diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt new file mode 100644 index 0000000..df5d8c3 --- /dev/null +++ b/Tests/FindLibXml2/Test/CMakeLists.txt @@ -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) diff --git a/Tests/FindLibXml2/Test/main.c b/Tests/FindLibXml2/Test/main.c new file mode 100644 index 0000000..264f07d --- /dev/null +++ b/Tests/FindLibXml2/Test/main.c @@ -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; +} |