summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-08 13:45:53 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-09-08 13:46:00 (GMT)
commit8bd26d7eac2eb213f7359bf5638a758cf084431f (patch)
treecc27eaa8f0bf6019b934d55b45ac3b727cdff4aa /Tests
parente5c1a7dfb3ca419967511ac471c91ebc2c5d76a1 (diff)
parentb1d1c56cfd7146d03f30f0c16e3e724239f78b06 (diff)
downloadCMake-8bd26d7eac2eb213f7359bf5638a758cf084431f.zip
CMake-8bd26d7eac2eb213f7359bf5638a758cf084431f.tar.gz
CMake-8bd26d7eac2eb213f7359bf5638a758cf084431f.tar.bz2
Merge topic 'findfreetype-importedtargets'
b1d1c56c Help: Add notes for topic 'FindFreetype-importedtargets' 457c2021 FindFreetype: Add imported target, docs, and test Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1219
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/FindFreetype/CMakeLists.txt10
-rw-r--r--Tests/FindFreetype/Test/CMakeLists.txt16
-rw-r--r--Tests/FindFreetype/Test/main.c34
4 files changed, 64 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 1bce09b..640b542 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1435,6 +1435,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_subdirectory(FindEXPAT)
endif()
+ if(CMake_TEST_FindFreetype)
+ add_subdirectory(FindFreetype)
+ endif()
+
if(CMake_TEST_FindGSL)
add_subdirectory(FindGSL)
endif()
diff --git a/Tests/FindFreetype/CMakeLists.txt b/Tests/FindFreetype/CMakeLists.txt
new file mode 100644
index 0000000..490c25b
--- /dev/null
+++ b/Tests/FindFreetype/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindFreetype.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindFreetype/Test"
+ "${CMake_BINARY_DIR}/Tests/FindFreetype/Test"
+ ${build_generator_args}
+ --build-project TestFindFreetype
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindFreetype/Test/CMakeLists.txt b/Tests/FindFreetype/Test/CMakeLists.txt
new file mode 100644
index 0000000..bc869a1
--- /dev/null
+++ b/Tests/FindFreetype/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.9)
+project(TestFindFreetype C)
+include(CTest)
+
+find_package(Freetype REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_FREETYPE_VERSION="${FREETYPE_VERSION_STRING}")
+
+add_executable(testfreetype_tgt main.c)
+target_link_libraries(testfreetype_tgt Freetype::Freetype)
+add_test(NAME testfreetype_tgt COMMAND testfreetype_tgt)
+
+add_executable(testfreetype_var main.c)
+target_include_directories(testfreetype_var PRIVATE ${FREETYPE_INCLUDE_DIRS})
+target_link_libraries(testfreetype_var PRIVATE ${FREETYPE_LIBRARIES})
+add_test(NAME testfreetype_var COMMAND testfreetype_var)
diff --git a/Tests/FindFreetype/Test/main.c b/Tests/FindFreetype/Test/main.c
new file mode 100644
index 0000000..bb838a5
--- /dev/null
+++ b/Tests/FindFreetype/Test/main.c
@@ -0,0 +1,34 @@
+#include <ft2build.h>
+#include <stdlib.h>
+#include FT_FREETYPE_H
+#include <string.h>
+
+int main()
+{
+ FT_Library library;
+ FT_Error error;
+
+ error = FT_Init_FreeType(&library);
+ if (error) {
+ return EXIT_FAILURE;
+ }
+
+ FT_Int major = 0;
+ FT_Int minor = 0;
+ FT_Int patch = 0;
+ FT_Library_Version(library, &major, &minor, &patch);
+
+ char ft_version_string[16];
+ snprintf(ft_version_string, 16, "%i.%i.%i", major, minor, patch);
+
+ if (strcmp(ft_version_string, CMAKE_EXPECTED_FREETYPE_VERSION) != 0) {
+ return EXIT_FAILURE;
+ }
+
+ error = FT_Done_FreeType(library);
+ if (error) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}