summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-05-21 17:09:47 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-05-22 07:25:41 +0000
commit774088b677b03cd1857fd352f305a5fe15b9f5eb (patch)
tree9e2015cf4419a58e4664ee5374f1f986857f2e3a
parent4e7756a6cd48716ff37d071fe660bb0e9edfa89f (diff)
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>
-rw-r--r--cmake/FindWrapDoubleConversion.cmake20
-rw-r--r--src/3rdparty/CMakeLists.txt1
-rw-r--r--src/3rdparty/double-conversion/CMakeLists.txt21
-rw-r--r--src/corelib/CMakeLists.txt5
4 files changed, 40 insertions, 7 deletions
diff --git a/cmake/FindWrapDoubleConversion.cmake b/cmake/FindWrapDoubleConversion.cmake
index cfb70a0981..1164f6ba44 100644
--- a/cmake/FindWrapDoubleConversion.cmake
+++ b/cmake/FindWrapDoubleConversion.cmake
@@ -1,16 +1,17 @@
-include(CheckCXXSourceCompiles)
-
-add_library(WrapDoubleConversion INTERFACE IMPORTED)
+add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
find_package(double-conversion)
if (double-conversion_FOUND)
include(FeatureSummary)
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)
return()
endif()
+include(CheckCXXSourceCompiles)
+
check_cxx_source_compiles("
#include <stdio.h>
#include <locale.h>
@@ -36,8 +37,17 @@ int main(int argc, char *argv[]) {
return 0;
}" 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)
- 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)
else()
set(WrapDoubleConversion_FOUND 0)
diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt
index 77c4970f49..d3b30fea65 100644
--- a/src/3rdparty/CMakeLists.txt
+++ b/src/3rdparty/CMakeLists.txt
@@ -1,2 +1,3 @@
add_subdirectory(tinycbor)
add_subdirectory(harfbuzz)
+add_subdirectory(double-conversion)
diff --git a/src/3rdparty/double-conversion/CMakeLists.txt b/src/3rdparty/double-conversion/CMakeLists.txt
new file mode 100644
index 0000000000..7450bc48ec
--- /dev/null
+++ b/src/3rdparty/double-conversion/CMakeLists.txt
@@ -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
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 59ad7dcdd6..cae1e98111 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -2,7 +2,8 @@
# special case begin
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)
message(FATAL_ERROR "Your C library does not provide \
@@ -231,7 +232,7 @@ add_qt_module(Core
QtHarfBuzz # special case
Threads::Threads # special case
tinycbor # special case
- WrapDoubleConversion # special case
+ WrapDoubleConversion::WrapDoubleConversion # special case
PUBLIC_LIBRARIES # special case:
Qt::Platform # special case:
DISABLE_AUTOGEN_TOOLS # special case: