CMake: Rewrite double-conversion find module
Rename FindWrapDoubleConversion.cmake into FindWrapSystemDoubleConversion.cmake. Merge contents of Finddouble-conversion.cmake into the one above. This allows users to provide their own Finddouble-conversion.cmake file (Conan can do it). Don't mark the system package as required, because we have a bundled one too. Add link to upstream. Make sure to show either Config file or library path when one is found. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-104541 Change-Id: I9ea2330697c6fc280328849ca11522291c4073d8 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
af56a6f0cb
commit
a310319a04
@ -1,22 +0,0 @@
|
|||||||
# 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 WrapDoubleConversion::WrapDoubleConversion)
|
|
||||||
set(WrapDoubleConversion_FOUND ON)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(WrapDoubleConversion_FOUND OFF)
|
|
||||||
|
|
||||||
find_package(double-conversion QUIET)
|
|
||||||
if (double-conversion_FOUND)
|
|
||||||
include(FeatureSummary)
|
|
||||||
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
|
|
||||||
add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
|
|
||||||
target_link_libraries(WrapDoubleConversion::WrapDoubleConversion
|
|
||||||
INTERFACE double-conversion::double-conversion)
|
|
||||||
set(WrapDoubleConversion_FOUND ON)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(WrapDoubleConversion DEFAULT_MSG WrapDoubleConversion_FOUND)
|
|
77
cmake/FindWrapSystemDoubleConversion.cmake
Normal file
77
cmake/FindWrapSystemDoubleConversion.cmake
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# 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 WrapSystemDoubleConversion::WrapSystemDoubleConversion)
|
||||||
|
set(WrapSystemDoubleConversion_FOUND ON)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WrapSystemDoubleConversion_REQUIRED_VARS "__double_conversion_found")
|
||||||
|
|
||||||
|
# Find either Config package or Find module.
|
||||||
|
# Upstream can be built either with CMake and then provides a Config file, or with Scons in which
|
||||||
|
# case there's no Config file.
|
||||||
|
# A Find module might be provided by a 3rd party, for example Conan might generate a Find module.
|
||||||
|
find_package(double-conversion ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
|
||||||
|
set(__double_conversion_target_name "double-conversion::double-conversion")
|
||||||
|
if(double-conversion_FOUND AND TARGET "${__double_conversion_target_name}")
|
||||||
|
set(__double_conversion_found TRUE)
|
||||||
|
# This ensures the Config file is shown in the fphsa message.
|
||||||
|
if(double-conversion_CONFIG)
|
||||||
|
list(PREPEND WrapSystemDoubleConversion_REQUIRED_VARS
|
||||||
|
double-conversion_CONFIG)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT __double_conversion_found)
|
||||||
|
list(PREPEND WrapSystemDoubleConversion_REQUIRED_VARS
|
||||||
|
DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR)
|
||||||
|
|
||||||
|
find_path(DOUBLE_CONVERSION_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
double-conversion.h
|
||||||
|
PATH_SUFFIXES
|
||||||
|
double-conversion
|
||||||
|
)
|
||||||
|
find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion)
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
select_library_configurations(DOUBLE_CONVERSION)
|
||||||
|
mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
|
||||||
|
|
||||||
|
if(DOUBLE_CONVERSION_LIBRARIES AND DOUBLE_CONVERSION_INCLUDE_DIRS)
|
||||||
|
set(__double_conversion_found TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
set(__double_conversion_fphsa_args "")
|
||||||
|
if(double-conversion_VERSION)
|
||||||
|
set(WrapSystemDoubleConversion_VERSION "${double-conversion_VERSION}")
|
||||||
|
list(APPEND __double_conversion_fphsa_args VERSION_VAR WrapSystemDoubleConversion_VERSION)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(WrapSystemDoubleConversion
|
||||||
|
REQUIRED_VARS ${WrapSystemDoubleConversion_REQUIRED_VARS}
|
||||||
|
${__double_conversion_fphsa_args})
|
||||||
|
|
||||||
|
if(WrapSystemDoubleConversion_FOUND)
|
||||||
|
add_library(WrapSystemDoubleConversion::WrapSystemDoubleConversion INTERFACE IMPORTED)
|
||||||
|
if(TARGET "${__double_conversion_target_name}")
|
||||||
|
target_link_libraries(WrapSystemDoubleConversion::WrapSystemDoubleConversion
|
||||||
|
INTERFACE "${__double_conversion_target_name}")
|
||||||
|
else()
|
||||||
|
target_link_libraries(WrapSystemDoubleConversion::WrapSystemDoubleConversion
|
||||||
|
INTERFACE ${DOUBLE_CONVERSION_LIBRARIES})
|
||||||
|
target_include_directories(WrapSystemDoubleConversion::WrapSystemDoubleConversion
|
||||||
|
INTERFACE ${DOUBLE_CONVERSION_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
unset(__double_conversion_target_name)
|
||||||
|
unset(__double_conversion_found)
|
||||||
|
unset(__double_conversion_fphsa_args)
|
||||||
|
|
||||||
|
include(FeatureSummary)
|
||||||
|
set_package_properties(WrapSystemDoubleConversion PROPERTIES
|
||||||
|
URL "https://github.com/google/double-conversion"
|
||||||
|
DESCRIPTION "double-conversion library")
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
# Fallback find module for double-conversion
|
|
||||||
# if double-conversion is built with CMake it'll install a config module, which we prefer
|
|
||||||
# if it's built with Scons (their default), we search ourselves
|
|
||||||
|
|
||||||
find_package(double-conversion CONFIG)
|
|
||||||
if (double-conversion_FOUND)
|
|
||||||
if(TARGET double-conversion::double-conversion)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_path(DOUBLE_CONVERSION_INCLUDE_DIR
|
|
||||||
NAMES
|
|
||||||
double-conversion.h
|
|
||||||
PATH_SUFFIXES
|
|
||||||
double-conversion
|
|
||||||
)
|
|
||||||
find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
|
||||||
double-conversion DEFAULT_MSG
|
|
||||||
DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR)
|
|
||||||
|
|
||||||
if(double-conversion_FOUND AND NOT TARGET double-conversion::double-conversion)
|
|
||||||
add_library(double-conversion::double-conversion UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(double-conversion::double-conversion PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${DOUBLE_CONVERSION_LIBRARY}"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${DOUBLE_CONVERSION_INCLUDE_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
|
|
@ -711,7 +711,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_backtrace
|
|||||||
|
|
||||||
qt_internal_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
|
qt_internal_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
WrapDoubleConversion::WrapDoubleConversion
|
WrapSystemDoubleConversion::WrapSystemDoubleConversion
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_internal_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
|
qt_internal_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
|
||||||
|
@ -19,7 +19,9 @@ if((UNIX AND NOT QNX) OR QT_FIND_ALL_PACKAGES_ALWAYS)
|
|||||||
# offerings
|
# offerings
|
||||||
qt_find_package(WrapBacktrace PROVIDED_TARGETS WrapBacktrace::WrapBacktrace MODULE_NAME core QMAKE_LIB backtrace)
|
qt_find_package(WrapBacktrace PROVIDED_TARGETS WrapBacktrace::WrapBacktrace MODULE_NAME core QMAKE_LIB backtrace)
|
||||||
endif()
|
endif()
|
||||||
qt_find_package(WrapDoubleConversion PROVIDED_TARGETS WrapDoubleConversion::WrapDoubleConversion MODULE_NAME core QMAKE_LIB doubleconversion)
|
qt_find_package(WrapSystemDoubleConversion
|
||||||
|
PROVIDED_TARGETS WrapSystemDoubleConversion::WrapSystemDoubleConversion
|
||||||
|
MODULE_NAME core QMAKE_LIB doubleconversion)
|
||||||
qt_find_package(GLIB2 PROVIDED_TARGETS GLIB2::GLIB2 MODULE_NAME core QMAKE_LIB glib)
|
qt_find_package(GLIB2 PROVIDED_TARGETS GLIB2::GLIB2 MODULE_NAME core QMAKE_LIB glib)
|
||||||
qt_find_package(ICU COMPONENTS i18n uc data PROVIDED_TARGETS ICU::i18n ICU::uc ICU::data MODULE_NAME core QMAKE_LIB icu)
|
qt_find_package(ICU COMPONENTS i18n uc data PROVIDED_TARGETS ICU::i18n ICU::uc ICU::data MODULE_NAME core QMAKE_LIB icu)
|
||||||
if(QT_FEATURE_dlopen)
|
if(QT_FEATURE_dlopen)
|
||||||
@ -548,7 +550,7 @@ qt_feature("doubleconversion" PUBLIC PRIVATE
|
|||||||
qt_feature_definition("doubleconversion" "QT_NO_DOUBLECONVERSION" NEGATE VALUE "1")
|
qt_feature_definition("doubleconversion" "QT_NO_DOUBLECONVERSION" NEGATE VALUE "1")
|
||||||
qt_feature("system-doubleconversion" PRIVATE
|
qt_feature("system-doubleconversion" PRIVATE
|
||||||
LABEL " Using system DoubleConversion"
|
LABEL " Using system DoubleConversion"
|
||||||
CONDITION QT_FEATURE_doubleconversion AND WrapDoubleConversion_FOUND
|
CONDITION QT_FEATURE_doubleconversion AND WrapSystemDoubleConversion_FOUND
|
||||||
ENABLE INPUT_doubleconversion STREQUAL 'system'
|
ENABLE INPUT_doubleconversion STREQUAL 'system'
|
||||||
DISABLE INPUT_doubleconversion STREQUAL 'qt'
|
DISABLE INPUT_doubleconversion STREQUAL 'qt'
|
||||||
)
|
)
|
||||||
|
@ -365,7 +365,8 @@ _library_map = [
|
|||||||
LibraryMapping("db2", "DB2", "DB2::DB2"),
|
LibraryMapping("db2", "DB2", "DB2::DB2"),
|
||||||
LibraryMapping("dbus", "WrapDBus1", "dbus-1", resultVariable="DBus1", extra=["1.2"]),
|
LibraryMapping("dbus", "WrapDBus1", "dbus-1", resultVariable="DBus1", extra=["1.2"]),
|
||||||
LibraryMapping(
|
LibraryMapping(
|
||||||
"doubleconversion", "WrapDoubleConversion", "WrapDoubleConversion::WrapDoubleConversion"
|
"doubleconversion", "WrapSystemDoubleConversion",
|
||||||
|
"WrapSystemDoubleConversion::WrapSystemDoubleConversion"
|
||||||
),
|
),
|
||||||
LibraryMapping("dlt", "DLT", "DLT::DLT"),
|
LibraryMapping("dlt", "DLT", "DLT::DLT"),
|
||||||
LibraryMapping("drm", "Libdrm", "Libdrm::Libdrm"),
|
LibraryMapping("drm", "Libdrm", "Libdrm::Libdrm"),
|
||||||
|
Loading…
Reference in New Issue
Block a user