diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-04 11:53:38 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-04 23:21:18 +0200 |
commit | 3ffad972c11f420157b0d89260edad2d45f51f2b (patch) | |
tree | ea233fb8b78f54f2f885eae11f71f7e5e3d3779d /cmake/FindWrapDoubleConversion.cmake | |
parent | 6f8ecc24977a3631641b4512742ae78305284489 (diff) |
CMake: Fix double-conversion usage on macOS
We reported that double-conversion was found on macOS if the std
library supported sscanf_l and _snprintf_l, but that's different
from what qmake does.
This caused not to compile and link the bundled double-conversion
sources, and caused tst_qvariant to fail when doing double conversions
on macOS.
Remove the extra config tests, and make it work like in qmake, so that
the bundled code is used instead. This makes tst_qvariant pass.
Amends 729a73a9cfe774cb49251be8c99ba5b26d516e01
Change-Id: I7ddaed5fe6916f483fb3de1962657d7fb6fb40be
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/FindWrapDoubleConversion.cmake')
-rw-r--r-- | cmake/FindWrapDoubleConversion.cmake | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/cmake/FindWrapDoubleConversion.cmake b/cmake/FindWrapDoubleConversion.cmake index ed5c394ade..d2ae276f0e 100644 --- a/cmake/FindWrapDoubleConversion.cmake +++ b/cmake/FindWrapDoubleConversion.cmake @@ -5,6 +5,8 @@ if(TARGET WrapDoubleConversion::WrapDoubleConversion) return() endif() +set(WrapDoubleConversion_FOUND OFF) + find_package(double-conversion) if (double-conversion_FOUND) include(FeatureSummary) @@ -12,42 +14,6 @@ if (double-conversion_FOUND) add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED) target_link_libraries(WrapDoubleConversion::WrapDoubleConversion INTERFACE double-conversion::double-conversion) - set(WrapDoubleConversion_FOUND 1) + set(WrapDoubleConversion_FOUND ON) return() endif() - -include(CheckCXXSourceCompiles) - -check_cxx_source_compiles(" -#include <stdio.h> -#include <locale.h> - -int main(int argc, char *argv[]) { - _locale_t invalidLocale = NULL; - double a = 3.14; - const char *format = \"invalid format\"; - _sscanf_l(argv[0], invalidLocale, format, &a, &argc); - _snprintf_l(argv[0], 1, invalidLocale, format, a); -}" HAVE__SPRINTF_L) - -check_cxx_source_compiles(" -#include <stdio.h> -#include <xlocale.h> - -int main(int argc, char *argv[]) { - locale_t invalidLocale = NULL; - double a = 3.14; - const char *format = \"invalid format\"; - snprintf_l(argv[0], 1, invalidLocale, format, a); - sscanf_l(argv[0], invalidLocale, format, &a, &argc); - return 0; -}" HAVE_SPRINTF_L) - -if (HAVE__SPRINTF_L OR HAVE_SPRINTF_L) - add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED) - target_compile_definitions(WrapDoubleConversion::WrapDoubleConversion - INTERFACE QT_NO_DOUBLECONVERSION) - set(WrapDoubleConversion_FOUND 1) -else() - set(WrapDoubleConversion_FOUND 0) -endif() |