1# test.cmake.in
2
3# Copyright (C) 2016 Glenn Randers-Pehrson
4# Written by Roger Leigh, 2016
5
6# This code is released under the libpng license.
7# For conditions of distribution and use, see the disclaimer
8# and license in png.h
9
10set(TEST_OPTIONS "@TEST_OPTIONS@")
11set(TEST_FILES "@TEST_FILES@")
12
13foreach(file ${TEST_FILES})
14  file(TO_NATIVE_PATH "${file}" native_file)
15  list(APPEND NATIVE_TEST_FILES "${native_file}")
16endforeach()
17
18# Add the directory containing libpng to the PATH (Windows only)
19if(WIN32)
20  get_filename_component(LIBPNG_DIR "${LIBPNG}" PATH)
21  file(TO_NATIVE_PATH "${LIBPNG_DIR}" LIBPNG_DIR)
22  set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}")
23endif()
24
25execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
26
27execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}
28                RESULT_VARIABLE TEST_STATUS)
29if(TEST_STATUS)
30  message(FATAL_ERROR "Returned failed status ${TEST_STATUS}!")
31endif()
32