summaryrefslogtreecommitdiffstats
path: root/Tests/FindPNG/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindPNG/Test')
-rw-r--r--Tests/FindPNG/Test/CMakeLists.txt16
-rw-r--r--Tests/FindPNG/Test/main.c20
2 files changed, 36 insertions, 0 deletions
diff --git a/Tests/FindPNG/Test/CMakeLists.txt b/Tests/FindPNG/Test/CMakeLists.txt
new file mode 100644
index 0000000..ad50011
--- /dev/null
+++ b/Tests/FindPNG/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindPNG C)
+include(CTest)
+
+find_package(PNG REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_PNG_VERSION="${PNG_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt PNG::PNG)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${PNG_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${PNG_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindPNG/Test/main.c b/Tests/FindPNG/Test/main.c
new file mode 100644
index 0000000..27e1478
--- /dev/null
+++ b/Tests/FindPNG/Test/main.c
@@ -0,0 +1,20 @@
+#include <assert.h>
+#include <string.h>
+#include <png.h>
+
+int main()
+{
+ png_uint_32 png_version;
+ char png_version_string[16];
+
+ png_version = png_access_version_number ();
+
+ snprintf (png_version_string, 16, "%i.%i.%i",
+ png_version / 10000,
+ (png_version % 10000) / 100,
+ png_version % 100);
+
+ assert (strcmp(png_version_string, CMAKE_EXPECTED_PNG_VERSION) == 0);
+
+ return 0;
+}