diff options
author | Brad King <brad.king@kitware.com> | 2016-01-22 14:25:33 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-01-22 14:25:33 (GMT) |
commit | ddb09ec8f91e7215d867c83d9229d3558bf2c166 (patch) | |
tree | 7294d7613a0727918b340743d2996522d8fbe7f0 /Tests | |
parent | dcf977ea1a97f41fe19a871235dc75e85891e478 (diff) | |
parent | 9b08c6233052fa1c3d393ee474c874f997491f7b (diff) | |
download | CMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.zip CMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.tar.gz CMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.tar.bz2 |
Merge topic 'FindPNG-imported-targets'
9b08c623 FindPNG: Create an imported PNG::PNG target (#15911)
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FindPNG/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindPNG/Test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/FindPNG/Test/main.c | 20 |
4 files changed, 50 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 240144f..7bb0721 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1375,6 +1375,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindOpenSSL) endif() + if(CMake_TEST_FindPNG) + add_subdirectory(FindPNG) + endif() + if(CMake_TEST_FindTIFF) add_subdirectory(FindTIFF) endif() diff --git a/Tests/FindPNG/CMakeLists.txt b/Tests/FindPNG/CMakeLists.txt new file mode 100644 index 0000000..c665b67 --- /dev/null +++ b/Tests/FindPNG/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindPNG.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPNG/Test" + "${CMake_BINARY_DIR}/Tests/FindPNG/Test" + ${build_generator_args} + --build-project TestFindPNG + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) 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; +} |