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>
This commit is contained in:
Alexandru Croitor 2020-06-04 11:53:38 +02:00
parent 6f8ecc2497
commit 3ffad972c1

View File

@ -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()