Build and use double-conversion library shipped by Qt when needed
Some Linux distros might not have a double-conversion library. Because it is such an essential library for QtCore, compile and use the the copy of the library bundled with Qt. Also change library name to be a proper target with double colons, so that in case the library is not found for some reason, the CMake configure step would fail, instead of failing at link time. Task-number: QTBUG-74133 Change-Id: I9f3b4298ae6e952891a7a89541d46878176bf1ce Fixes: QTBUG-75891 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
4e7756a6cd
commit
774088b677
@ -1,16 +1,17 @@
|
|||||||
include(CheckCXXSourceCompiles)
|
add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
|
||||||
|
|
||||||
add_library(WrapDoubleConversion INTERFACE IMPORTED)
|
|
||||||
|
|
||||||
find_package(double-conversion)
|
find_package(double-conversion)
|
||||||
if (double-conversion_FOUND)
|
if (double-conversion_FOUND)
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
|
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
|
||||||
target_link_libraries(WrapDoubleConversion INTERFACE double-conversion::double-conversion)
|
target_link_libraries(WrapDoubleConversion::WrapDoubleConversion
|
||||||
|
INTERFACE double-conversion::double-conversion)
|
||||||
set(WrapDoubleConversion_FOUND 1)
|
set(WrapDoubleConversion_FOUND 1)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
check_cxx_source_compiles("
|
check_cxx_source_compiles("
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
@ -36,8 +37,17 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}" HAVE_SPRINTF_L)
|
}" HAVE_SPRINTF_L)
|
||||||
|
|
||||||
|
# In a static build, we need to find the package to bring the target into scope.
|
||||||
|
find_package(QtDoubleConversion QUIET)
|
||||||
|
|
||||||
if (HAVE__SPRINTF_L OR HAVE_SPRINTF_L)
|
if (HAVE__SPRINTF_L OR HAVE_SPRINTF_L)
|
||||||
target_compile_definitions(WrapDoubleConversion INTERFACE QT_NO_DOUBLECONVERSION)
|
target_compile_definitions(WrapDoubleConversion::WrapDoubleConversion
|
||||||
|
INTERFACE QT_NO_DOUBLECONVERSION)
|
||||||
|
set(WrapDoubleConversion_FOUND 1)
|
||||||
|
elseif(TARGET QtDoubleConversion)
|
||||||
|
# If a Config package wasn't found, and the C++ library doesn't contain the necessary functions,
|
||||||
|
# use the library bundled with Qt.
|
||||||
|
target_link_libraries(WrapDoubleConversion::WrapDoubleConversion INTERFACE QtDoubleConversion)
|
||||||
set(WrapDoubleConversion_FOUND 1)
|
set(WrapDoubleConversion_FOUND 1)
|
||||||
else()
|
else()
|
||||||
set(WrapDoubleConversion_FOUND 0)
|
set(WrapDoubleConversion_FOUND 0)
|
||||||
|
1
src/3rdparty/CMakeLists.txt
vendored
1
src/3rdparty/CMakeLists.txt
vendored
@ -1,2 +1,3 @@
|
|||||||
add_subdirectory(tinycbor)
|
add_subdirectory(tinycbor)
|
||||||
add_subdirectory(harfbuzz)
|
add_subdirectory(harfbuzz)
|
||||||
|
add_subdirectory(double-conversion)
|
||||||
|
21
src/3rdparty/double-conversion/CMakeLists.txt
vendored
Normal file
21
src/3rdparty/double-conversion/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# special case begin
|
||||||
|
|
||||||
|
add_library(QtDoubleConversion STATIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/bignum.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/bignum-dtoa.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cached-powers.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/diy-fp.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/double-conversion.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/fast-dtoa.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/fixed-dtoa.cc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/strtod.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(QtDoubleConversion PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/double-conversion>
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_install_3rdparty_library(QtDoubleConversion)
|
||||||
|
# special case end
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
# special case begin
|
# special case begin
|
||||||
qt_find_package(Threads PROVIDED_TARGETS Threads::Threads)
|
qt_find_package(Threads PROVIDED_TARGETS Threads::Threads)
|
||||||
qt_find_package(WrapDoubleConversion REQUIRED PROVIDED_TARGETS WrapDoubleConversion)
|
qt_find_package(WrapDoubleConversion REQUIRED
|
||||||
|
PROVIDED_TARGETS WrapDoubleConversion::WrapDoubleConversion)
|
||||||
|
|
||||||
if (NOT WrapDoubleConversion_FOUND)
|
if (NOT WrapDoubleConversion_FOUND)
|
||||||
message(FATAL_ERROR "Your C library does not provide \
|
message(FATAL_ERROR "Your C library does not provide \
|
||||||
@ -231,7 +232,7 @@ add_qt_module(Core
|
|||||||
QtHarfBuzz # special case
|
QtHarfBuzz # special case
|
||||||
Threads::Threads # special case
|
Threads::Threads # special case
|
||||||
tinycbor # special case
|
tinycbor # special case
|
||||||
WrapDoubleConversion # special case
|
WrapDoubleConversion::WrapDoubleConversion # special case
|
||||||
PUBLIC_LIBRARIES # special case:
|
PUBLIC_LIBRARIES # special case:
|
||||||
Qt::Platform # special case:
|
Qt::Platform # special case:
|
||||||
DISABLE_AUTOGEN_TOOLS # special case:
|
DISABLE_AUTOGEN_TOOLS # special case:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user