qt5base-lts/cmake/FindWrapDoubleConversion.cmake
Simon Hausmann e9c45bbddd Begin port of qtbase to CMake
Done-by: Alexandru Croitor <alexandru.croitor@qt.io>
Done-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Done-by: Kevin Funk <kevin.funk@kdab.com>
Done-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Done-by: Simon Hausmann <simon.hausmann@qt.io>
Done-by: Tobias Hunger <tobias.hunger@qt.io>
Done-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Done-by: Volker Krause <volker.krause@kdab.com>
Change-Id: Ida4f8bd190f9a4849a1af7b5b7981337a5df5310
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-11-01 11:48:46 +00:00

37 lines
1.0 KiB
CMake

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)
add_library(WrapDoubleConversion INTERFACE)
if (NOT HAVE__SPRINTF_L AND NOT HAVE_SPRINTF_L)
find_package(double-conversion)
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
target_link_libraries(WrapDoubleConversion INTERFACE double-conversion::double-conversion)
endif()
set(WrapDoubleConversion_FOUND 1)