diff options
author | Frederik Gladhorn <gladhorn@kde.org> | 2018-09-27 07:42:10 (GMT) |
---|---|---|
committer | Frederik Gladhorn <gladhorn@kde.org> | 2018-10-18 18:32:09 (GMT) |
commit | 84e7920b3ac9241cf73a468120ff0ea83f9a7c86 (patch) | |
tree | 476b19f8e18884a596ff6e97da07ced62fc1efdb /Tests/FindFontconfig | |
parent | 7bacb2295583f1a0e04a7312c370064310b1834b (diff) | |
download | CMake-84e7920b3ac9241cf73a468120ff0ea83f9a7c86.zip CMake-84e7920b3ac9241cf73a468120ff0ea83f9a7c86.tar.gz CMake-84e7920b3ac9241cf73a468120ff0ea83f9a7c86.tar.bz2 |
FindFontconfig: Add module to find Fontconfig
This module is inspired by one from KDE's KWin.
Diffstat (limited to 'Tests/FindFontconfig')
-rw-r--r-- | Tests/FindFontconfig/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindFontconfig/Test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/FindFontconfig/Test/main.c | 17 |
3 files changed, 43 insertions, 0 deletions
diff --git a/Tests/FindFontconfig/CMakeLists.txt b/Tests/FindFontconfig/CMakeLists.txt new file mode 100644 index 0000000..d683d87 --- /dev/null +++ b/Tests/FindFontconfig/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindFontconfig.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindFontconfig/Test" + "${CMake_BINARY_DIR}/Tests/FindFontconfig/Test" + ${build_generator_args} + --build-project TestFindFontconfig + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindFontconfig/Test/CMakeLists.txt b/Tests/FindFontconfig/Test/CMakeLists.txt new file mode 100644 index 0000000..81db3ba --- /dev/null +++ b/Tests/FindFontconfig/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindFontconfig C) +include(CTest) + +find_package(Fontconfig REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_FONTCONFIG_VERSION="${FONTCONFIG_VERSION}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt Fontconfig::Fontconfig) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${FONTCONFIG_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${FONTCONFIG_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindFontconfig/Test/main.c b/Tests/FindFontconfig/Test/main.c new file mode 100644 index 0000000..c5b5963 --- /dev/null +++ b/Tests/FindFontconfig/Test/main.c @@ -0,0 +1,17 @@ +#include <assert.h> +#include <fontconfig/fontconfig.h> +#include <stdio.h> +#include <string.h> + +int main() +{ + FcInit(); + printf("Found Fontconfig.\n"); + + char fontconfig_version_string[16]; + snprintf(fontconfig_version_string, 16, "%i.%i.%i", FC_MAJOR, FC_MINOR, + FC_REVISION); + assert( + strcmp(fontconfig_version_string, CMAKE_EXPECTED_FONTCONFIG_VERSION) == 0); + return 0; +} |