3c52f8af9d
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>
54 lines
1.7 KiB
CMake
54 lines
1.7 KiB
CMake
if(TARGET WrapSystemPCRE2::WrapSystemPCRE2)
|
|
set(WrapSystemPCRE2_FOUND TRUE)
|
|
return()
|
|
endif()
|
|
set(WrapSystemPCRE2_REQUIRED_VARS __pcre2_found)
|
|
|
|
find_package(PCRE2 ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG QUIET)
|
|
|
|
set(__pcre2_target_name "PCRE2::pcre2-16")
|
|
if(PCRE2_FOUND AND TARGET "${__pcre2_target_name}")
|
|
# Hunter case.
|
|
set(__pcre2_found TRUE)
|
|
if(PCRE2_VERSION)
|
|
set(WrapSystemPCRE2_VERSION "${PCRE2_VERSION}")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT __pcre2_found)
|
|
list(PREPEND WrapSystemPCRE2_REQUIRED_VARS PCRE2_LIBRARIES PCRE2_INCLUDE_DIRS)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
pkg_check_modules(PC_PCRE2 QUIET libpcre2-16)
|
|
|
|
find_path(PCRE2_INCLUDE_DIRS
|
|
NAMES pcre2.h
|
|
HINTS ${PC_PCRE2_INCLUDEDIR})
|
|
find_library(PCRE2_LIBRARIES
|
|
NAMES pcre2-16
|
|
HINTS ${PC_PCRE2_LIBDIR})
|
|
if(PC_PCRE2_VERSION)
|
|
set(WrapSystemPCRE2_VERSION "${PC_PCRE2_VERSION}")
|
|
endif()
|
|
|
|
if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
|
|
set(__pcre2_found TRUE)
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(WrapSystemPCRE2
|
|
REQUIRED_VARS ${WrapSystemPCRE2_REQUIRED_VARS}
|
|
VERSION_VAR WrapSystemPCRE2_VERSION)
|
|
if(WrapSystemPCRE2_FOUND)
|
|
add_library(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE IMPORTED)
|
|
if(TARGET "${__pcre2_target_name}")
|
|
target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE "${__pcre2_target_name}")
|
|
else()
|
|
target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_LIBRARIES})
|
|
target_include_directories(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
|
|
endif()
|
|
endif()
|
|
unset(__pcre2_target_name)
|
|
unset(__pcre2_found)
|