mirror of
https://github.com/reactos/CMake.git
synced 2025-01-21 02:45:05 +00:00
FindEXPAT: Add unit test of target and variables
This commit is contained in:
parent
78f166f873
commit
bfe51369a7
@ -1427,6 +1427,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||
add_subdirectory(FindDoxygen)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindEXPAT)
|
||||
add_subdirectory(FindEXPAT)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_FindGSL)
|
||||
add_subdirectory(FindGSL)
|
||||
endif()
|
||||
|
10
Tests/FindEXPAT/CMakeLists.txt
Normal file
10
Tests/FindEXPAT/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_test(NAME FindEXPAT.Test COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindEXPAT/Test"
|
||||
"${CMake_BINARY_DIR}/Tests/FindEXPAT/Test"
|
||||
${build_generator_args}
|
||||
--build-project TestFindEXPAT
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
16
Tests/FindEXPAT/Test/CMakeLists.txt
Normal file
16
Tests/FindEXPAT/Test/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(TestFindEXPAT C)
|
||||
include(CTest)
|
||||
|
||||
find_package(EXPAT REQUIRED)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_EXPAT_VERSION="${EXPAT_VERSION_STRING}")
|
||||
|
||||
add_executable(testexpat_tgt main.c)
|
||||
target_link_libraries(testexpat_tgt EXPAT::EXPAT)
|
||||
add_test(NAME testexpat_tgt COMMAND testexpat_tgt)
|
||||
|
||||
add_executable(testexpat_var main.c)
|
||||
target_include_directories(testexpat_var PRIVATE ${EXPAT_INCLUDE_DIRS})
|
||||
target_link_libraries(testexpat_var PRIVATE ${EXPAT_LIBRARIES})
|
||||
add_test(NAME testexpat_var COMMAND testexpat_var)
|
21
Tests/FindEXPAT/Test/main.c
Normal file
21
Tests/FindEXPAT/Test/main.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
XML_Expat_Version expat_version;
|
||||
char expat_version_string[16];
|
||||
|
||||
expat_version = XML_ExpatVersionInfo();
|
||||
|
||||
snprintf(expat_version_string, 16, "%i.%i.%i", expat_version.major,
|
||||
expat_version.minor, expat_version.micro);
|
||||
|
||||
if (strcmp(expat_version_string, CMAKE_EXPECTED_EXPAT_VERSION) != 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user