summaryrefslogtreecommitdiff
path: root/builds
diff options
context:
space:
mode:
authorNikolaus Waxweiler <madigens@gmail.com>2018-04-07 21:34:24 +0100
committerNikolaus Waxweiler <madigens@gmail.com>2018-04-10 22:31:10 +0100
commit029721d69c8073fa4b5c78d19f6fa051a7ae3459 (patch)
tree795fb00b5179d4966a419da265ee95c1ba3b7739 /builds
parentbd9400bd464f6cd7c74f52ece1c1065fe2a87aab (diff)
downloadfreetype2-029721d69c8073fa4b5c78d19f6fa051a7ae3459.tar.gz
Modernize CMake build.
* CMakeLists.txt, builds/cmake/FindHarfBuzz.cmake: Extensive modernization measures. * .gitignore: Add build/, as that's the example directory used in CMakeLists.txt. This brings up the minimum required CMake version to 2.8.12. The installation paths follow the GNU defaults now, e.g. installing on a 64 bit host will place binaries into the lib64/ folder on e.g. Fedora. Symbols are hidden by default (e.g. `-fvisibility=hidden' on GCC). CMake will no longer look for a C++ compiler. Library and .so version now match the Autotools build. Comments in the build file and informational messages now use platform agnostic example commands. ftoption.h and ftconfig.h are written directly without a redundant `-new' copy. External dependencies are expressed as option()s and will turn up as such in cmake-gui. Internal: Properties such as dependencies and include directories are now privately set on the freetype library instead of globally. The CPack definitions have been cleaned up, the `make dist' has been removed. Source packages generated with CPack don't contain Autotools files and aren't used by the maintainters anyway. On Windows, src/base/ftver.rc is compiled to decorate the library with version and copyright information. A pkg-config file is now generated and installed.
Diffstat (limited to 'builds')
-rw-r--r--builds/cmake/FindHarfBuzz.cmake57
1 files changed, 33 insertions, 24 deletions
diff --git a/builds/cmake/FindHarfBuzz.cmake b/builds/cmake/FindHarfBuzz.cmake
index f394b82bf..ee0d52e36 100644
--- a/builds/cmake/FindHarfBuzz.cmake
+++ b/builds/cmake/FindHarfBuzz.cmake
@@ -31,42 +31,51 @@
# HARFBUZZ_LIBRARIES - containg the HarfBuzz library
include(FindPkgConfig)
+pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz)
-pkg_check_modules(PC_HARFBUZZ harfbuzz>=0.9.7)
-
-find_path(HARFBUZZ_INCLUDE_DIRS NAMES hb.h
- HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
+find_path(HARFBUZZ_INCLUDE_DIRS
+ NAMES hb.h
+ HINTS ${PC_HARFBUZZ_INCLUDEDIR}
+ ${PC_HARFBUZZ_INCLUDE_DIRS}
+ PATH_SUFFIXES harfbuzz
)
find_library(HARFBUZZ_LIBRARIES NAMES harfbuzz
- HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR}
+ HINTS ${PC_HARFBUZZ_LIBDIR}
+ ${PC_HARFBUZZ_LIBRARY_DIRS}
)
-# HarfBuzz 0.9.18 split ICU support into a separate harfbuzz-icu library.
-if ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "0.9.17")
- if (HarfBuzz_FIND_REQUIRED)
- set(_HARFBUZZ_REQUIRED REQUIRED)
- else ()
- set(_HARFBUZZ_REQUIRED "")
- endif ()
- pkg_check_modules(PC_HARFBUZZ_ICU harfbuzz-icu>=0.9.18 ${_HARFBUZZ_REQUIRED})
- find_library(HARFBUZZ_ICU_LIBRARIES NAMES harfbuzz-icu
- HINTS ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} ${PC_HARFBUZZ_ICU_LIBDIR}
- )
- if (HARFBUZZ_ICU_LIBRARIES)
- list(APPEND HARFBUZZ_LIBRARIES "${HARFBUZZ_ICU_LIBRARIES}")
+if (HARFBUZZ_INCLUDE_DIRS)
+ if (EXISTS "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h")
+ file(READ "${HARFBUZZ_INCLUDE_DIRS}/hb-version.h" _harfbuzz_version_content)
+
+ string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}")
+ set(HARFBUZZ_VERSION "${CMAKE_MATCH_1}")
endif ()
- set(_HARFBUZZ_EXTRA_REQUIRED_VAR "HARFBUZZ_ICU_LIBRARIES")
-else ()
- set(_HARFBUZZ_EXTRA_REQUIRED_VAR "")
+endif ()
+
+if ("${harfbuzz_FIND_VERSION}" VERSION_GREATER "${HARFBUZZ_VERSION}")
+ message(FATAL_ERROR "Required version (" ${harfbuzz_FIND_VERSION} ") is higher than found version (" ${HARFBUZZ_VERSION} ")")
endif ()
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(HarfBuzz DEFAULT_MSG HARFBUZZ_INCLUDE_DIRS
- HARFBUZZ_LIBRARIES ${_HARFBUZZ_EXTRA_REQUIRED_VAR})
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ harfbuzz
+ REQUIRED_VARS HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES
+ VERSION_VAR HARFBUZZ_VERSION)
mark_as_advanced(
- HARFBUZZ_ICU_LIBRARIES
HARFBUZZ_INCLUDE_DIRS
HARFBUZZ_LIBRARIES
)
+
+# Allows easy linking as in
+# target_link_libraries(freetype PRIVATE Harfbuzz::Harfbuzz)
+if (NOT CMAKE_VERSION VERSION_LESS 3.1)
+ if (HARFBUZZ_FOUND AND NOT TARGET Harfbuzz::Harfbuzz)
+ add_library(Harfbuzz::Harfbuzz INTERFACE IMPORTED)
+ set_target_properties(
+ Harfbuzz::Harfbuzz PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIRS}")
+ endif ()
+endif ()