mirror of
https://github.com/reactos/CMake.git
synced 2025-02-23 13:32:49 +00:00
FindGIF: Add test
This tests whether GIFLIB can be found and the linker works. For newer versions (>=5) it also tests if the version was parsed correctly.
This commit is contained in:
parent
5bc64fe6c2
commit
6962a41e6b
@ -1388,6 +1388,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||
add_subdirectory(FindGDAL)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindGIF)
|
||||
add_subdirectory(FindGIF)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindGSL)
|
||||
add_subdirectory(FindGSL)
|
||||
endif()
|
||||
|
10
Tests/FindGIF/CMakeLists.txt
Normal file
10
Tests/FindGIF/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_test(NAME FindGIF.Test COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindGIF/Test"
|
||||
"${CMake_BINARY_DIR}/Tests/FindGIF/Test"
|
||||
${build_generator_args}
|
||||
--build-project TestFindGIF
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
16
Tests/FindGIF/Test/CMakeLists.txt
Normal file
16
Tests/FindGIF/Test/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
project(TestFindGIF C)
|
||||
include(CTest)
|
||||
|
||||
find_package(GIF REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_GIF_VERSION="${GIF_VERSION}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt GIF::GIF)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
add_executable(test_var main.c)
|
||||
target_include_directories(test_var PRIVATE ${GIF_INCLUDE_DIRS})
|
||||
target_link_libraries(test_var PRIVATE ${GIF_LIBRARIES})
|
||||
add_test(NAME test_var COMMAND test_var)
|
35
Tests/FindGIF/Test/main.c
Normal file
35
Tests/FindGIF/Test/main.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gif_lib.h>
|
||||
|
||||
// GIFLIB before version 5 didn't know this macro
|
||||
#ifndef GIFLIB_MAJOR
|
||||
# define GIFLIB_MAJOR 4
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
// because of the API changes we have to test different functions depending
|
||||
// on the version of GIFLIB
|
||||
#if GIFLIB_MAJOR >= 5
|
||||
// test the linker
|
||||
GifErrorString(D_GIF_SUCCEEDED);
|
||||
|
||||
// check the version
|
||||
char gif_version_string[16];
|
||||
snprintf(gif_version_string, 16, "%i.%i.%i", GIFLIB_MAJOR, GIFLIB_MINOR,
|
||||
GIFLIB_RELEASE);
|
||||
|
||||
assert(strcmp(gif_version_string, CMAKE_EXPECTED_GIF_VERSION) == 0);
|
||||
#else
|
||||
// test the linker
|
||||
GifLastError();
|
||||
|
||||
// unfortunately there is no way to check the version in older version of
|
||||
// GIFLIB
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user