summaryrefslogtreecommitdiffstats
path: root/Tests/FindLibXslt
diff options
context:
space:
mode:
authorMarkus Rickert <rickert@fortiss.org>2020-04-22 19:27:25 (GMT)
committerMarkus Rickert <rickert@fortiss.org>2020-04-28 17:14:03 (GMT)
commit1aa7df411474cd183af7049f3a53c8ac6be75a61 (patch)
treef49f9ccf76b852b76da8578105302479195a20ec /Tests/FindLibXslt
parentdd506714f40c16d922ad5f78f3fcf0bdd78a5d02 (diff)
downloadCMake-1aa7df411474cd183af7049f3a53c8ac6be75a61.zip
CMake-1aa7df411474cd183af7049f3a53c8ac6be75a61.tar.gz
CMake-1aa7df411474cd183af7049f3a53c8ac6be75a61.tar.bz2
FindLibXslt: provide imported targets
Diffstat (limited to 'Tests/FindLibXslt')
-rw-r--r--Tests/FindLibXslt/CMakeLists.txt10
-rw-r--r--Tests/FindLibXslt/Test/CMakeLists.txt45
-rw-r--r--Tests/FindLibXslt/Test/libexslt.c16
-rw-r--r--Tests/FindLibXslt/Test/libxslt.c24
4 files changed, 95 insertions, 0 deletions
diff --git a/Tests/FindLibXslt/CMakeLists.txt b/Tests/FindLibXslt/CMakeLists.txt
new file mode 100644
index 0000000..8a550b2
--- /dev/null
+++ b/Tests/FindLibXslt/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLibXslt.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindLibXslt/Test"
+ "${CMake_BINARY_DIR}/Tests/FindLibXslt/Test"
+ ${build_generator_args}
+ --build-project TestFindLibXslt
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+)
diff --git a/Tests/FindLibXslt/Test/CMakeLists.txt b/Tests/FindLibXslt/Test/CMakeLists.txt
new file mode 100644
index 0000000..e932661
--- /dev/null
+++ b/Tests/FindLibXslt/Test/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindLibXslt C)
+include(CTest)
+
+find_package(Iconv)
+find_package(LibXml2 REQUIRED)
+find_package(LibXslt REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_LibXslt_VERSION="${LIBXSLT_VERSION_STRING}")
+
+add_executable(libxslt_tgt libxslt.c)
+if(Iconv_FOUND)
+ target_link_libraries(libxslt_tgt Iconv::Iconv)
+endif()
+target_link_libraries(libxslt_tgt LibXml2::LibXml2 LibXslt::LibXslt)
+add_test(NAME libxslt_tgt COMMAND libxslt_tgt)
+
+add_executable(libxslt_var libxslt.c)
+if(Iconv_FOUND)
+ target_include_directories(libxslt_var PRIVATE ${Iconv_INCLUDE_DIRS})
+ target_link_libraries(libxslt_var PRIVATE ${Iconv_LIBRARIES})
+endif()
+target_include_directories(libxslt_var PRIVATE ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIR})
+target_link_libraries(libxslt_var PRIVATE ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES})
+add_test(NAME libxslt_var COMMAND libxslt_var)
+
+add_executable(libexslt_tgt libexslt.c)
+if(Iconv_FOUND)
+ target_link_libraries(libexslt_tgt Iconv::Iconv)
+endif()
+target_link_libraries(libexslt_tgt LibXml2::LibXml2 LibXslt::LibXslt LibXslt::LibExslt)
+add_test(NAME libexslt_tgt COMMAND libexslt_tgt)
+
+add_executable(libexslt_var libexslt.c)
+if(Iconv_FOUND)
+ target_include_directories(libexslt_var PRIVATE ${Iconv_INCLUDE_DIRS})
+ target_link_libraries(libexslt_var PRIVATE ${Iconv_LIBRARIES})
+endif()
+target_include_directories(libexslt_var PRIVATE ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIR} ${LIBXSLT_EXSLT_INCLUDE_DIR})
+target_link_libraries(libexslt_var PRIVATE ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES})
+add_test(NAME libexslt_var COMMAND libexslt_var)
+
+add_test(NAME xsltproc_tgt COMMAND LibXslt::xsltproc --version)
+
+add_test(NAME xsltproc_var COMMAND ${LIBXSLT_XSLTPROC_EXECUTABLE} --version)
diff --git a/Tests/FindLibXslt/Test/libexslt.c b/Tests/FindLibXslt/Test/libexslt.c
new file mode 100644
index 0000000..ea6eb3d
--- /dev/null
+++ b/Tests/FindLibXslt/Test/libexslt.c
@@ -0,0 +1,16 @@
+#include <libexslt/exslt.h>
+#include <libxslt/xslt.h>
+#include <libxslt/xsltInternals.h>
+
+int main()
+{
+ xsltInit();
+
+ xsltStylesheet* style = xsltNewStylesheet();
+ exsltRegisterAll();
+ xsltFreeStylesheet(style);
+
+ xsltCleanupGlobals();
+
+ return 0;
+}
diff --git a/Tests/FindLibXslt/Test/libxslt.c b/Tests/FindLibXslt/Test/libxslt.c
new file mode 100644
index 0000000..5b3d766
--- /dev/null
+++ b/Tests/FindLibXslt/Test/libxslt.c
@@ -0,0 +1,24 @@
+#include <libxslt/xslt.h>
+#include <libxslt/xsltInternals.h>
+#include <libxslt/xsltconfig.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ xsltInit();
+
+ xsltStylesheet* style = xsltNewStylesheet();
+ xsltFreeStylesheet(style);
+
+ if (0 != strcmp(CMAKE_EXPECTED_LibXslt_VERSION, LIBXSLT_DOTTED_VERSION)) {
+ printf("CMAKE_EXPECTED_LibXslt_VERSION: '%s'\n",
+ CMAKE_EXPECTED_LibXslt_VERSION);
+ printf("LIBXSLT_DOTTED_VERSION: '%s'\n", LIBXSLT_DOTTED_VERSION);
+ return 1;
+ }
+
+ xsltCleanupGlobals();
+
+ return 0;
+}