diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-04 17:24:17 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-08-10 11:56:54 +0200 |
commit | 3c52f8af9dbc125eee22115910c25510df8fede0 (patch) | |
tree | 3a3d7c60c53cb3c49b506ca721afcce249311c15 /cmake/FindWrapSystemHarfbuzz.cmake | |
parent | 7e7796fb006e616537a31112438232c124e8ce35 (diff) |
CMake: pro2cmake: Specify library versions for 3rd party libraries
If certain 3rd party libraries have a version that's not suitable for
Qt, the configure summary should say so, rather than use them and fail
at build time.
With the current situation, we have to duplicate the version
information from the configure.json files in helper.py, by assigning
the version number as an extra find_package variable.
Rerunning configurejson2cmake then embeds this version info into the
qt_find_package calls in configure.cmake.
Some of the Find modules are rewritten to take the specified version
into account when looking for the libraries.
This involves moving around the code for creating a target, after
calling find_package_handle_standard_args() so we know if a good
enough version was found.
Task-number: QTBUG-82917
Change-Id: I139748d8090e0630cda413362760034dc3483e11
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/FindWrapSystemHarfbuzz.cmake')
-rw-r--r-- | cmake/FindWrapSystemHarfbuzz.cmake | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/cmake/FindWrapSystemHarfbuzz.cmake b/cmake/FindWrapSystemHarfbuzz.cmake index 087c1b070b..3cb44aa766 100644 --- a/cmake/FindWrapSystemHarfbuzz.cmake +++ b/cmake/FindWrapSystemHarfbuzz.cmake @@ -1,13 +1,12 @@ # We can't create the same interface imported target multiple times, CMake will complain if we do # that. This can happen if the find_package call is done in multiple different subdirectories. if(TARGET WrapSystemHarfbuzz::WrapSystemHarfbuzz) - set(WrapSystemHarfbuzz_FOUND ON) + set(WrapSystemHarfbuzz_FOUND TRUE) return() endif() +set(WrapSystemHarfbuzz_REQUIRED_VARS __harfbuzz_found) -set(WrapSystemHarfbuzz_FOUND OFF) - -find_package(harfbuzz QUIET) +find_package(harfbuzz ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET) # Gentoo has some buggy version of a harfbuzz Config file. Check if include paths are valid. set(__harfbuzz_target_name "harfbuzz::harfbuzz") @@ -21,28 +20,43 @@ if(harfbuzz_FOUND AND TARGET "${__harfbuzz_target_name}") break() endif() endforeach() -endif() -if(__harfbuzz_broken_config_file) - find_package(PkgConfig QUIET) + set(__harfbuzz_found TRUE) + if(harfbuzz_VERSION) + set(WrapSystemHarfbuzz_VERSION "${harfbuzz_VERSION}") + endif() +endif() - pkg_check_modules(harfbuzz harfbuzz IMPORTED_TARGET) - set(__harfbuzz_target_name "PkgConfig::harfbuzz") +if(__harfbuzz_broken_config_file OR NOT __harfbuzz_found) + list(PREPEND WrapSystemHarfbuzz_REQUIRED_VARS HARFBUZZ_LIBRARIES HARFBUZZ_INCLUDE_DIRS) - if (NOT TARGET "${__harfbuzz_target_name}") - set(harfbuzz_FOUND 0) + find_package(PkgConfig QUIET) + pkg_check_modules(PC_HARFBUZZ harfbuzz IMPORTED_TARGET) + + find_path(HARFBUZZ_INCLUDE_DIRS + NAMES harfbuzz/hb.h + HINTS ${PC_HARFBUZZ_INCLUDEDIR}) + find_library(HARFBUZZ_LIBRARIES + NAMES harfbuzz + HINTS ${PC_HARFBUZZ_LIBDIR}) + + set(__harfbuzz_target_name "PkgConfig::PC_HARFBUZZ") + set(__harfbuzz_found TRUE) + if(PC_HARFBUZZ_VERSION) + set(WrapSystemHarfbuzz_VERSION "${PC_HARFBUZZ_VERSION}") endif() endif() -if(TARGET "${__harfbuzz_target_name}") - set(WrapSystemHarfbuzz_FOUND ON) - +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WrapSystemHarfbuzz + REQUIRED_VARS ${WrapSystemHarfbuzz_REQUIRED_VARS} + VERSION_VAR WrapSystemHarfbuzz_VERSION) +if(WrapSystemHarfbuzz_FOUND) add_library(WrapSystemHarfbuzz::WrapSystemHarfbuzz INTERFACE IMPORTED) - target_link_libraries(WrapSystemHarfbuzz::WrapSystemHarfbuzz INTERFACE ${__harfbuzz_target_name}) + target_link_libraries(WrapSystemHarfbuzz::WrapSystemHarfbuzz + INTERFACE "${__harfbuzz_target_name}") endif() unset(__harfbuzz_target_name) +unset(__harfbuzz_found) unset(__harfbuzz_include_dir) unset(__harfbuzz_broken_config_file) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WrapSystemHarfbuzz DEFAULT_MSG WrapSystemHarfbuzz_FOUND) |