2019-06-05 12:28:31 +00:00
|
|
|
# We can't create the same interface imported target multiple times, CMake will complain if we do
|
|
|
|
# that. This can happen if the find_package call is done in multiple different subdirectories.
|
|
|
|
if(TARGET WrapDoubleConversion::WrapDoubleConversion)
|
|
|
|
set(WrapDoubleConversion_FOUND ON)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-05-21 15:09:47 +00:00
|
|
|
add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
|
2019-01-07 14:22:24 +00:00
|
|
|
|
|
|
|
find_package(double-conversion)
|
|
|
|
if (double-conversion_FOUND)
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
include(FeatureSummary)
|
2019-01-07 14:22:24 +00:00
|
|
|
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
|
2019-05-21 15:09:47 +00:00
|
|
|
target_link_libraries(WrapDoubleConversion::WrapDoubleConversion
|
|
|
|
INTERFACE double-conversion::double-conversion)
|
2019-01-07 14:22:24 +00:00
|
|
|
set(WrapDoubleConversion_FOUND 1)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-05-21 15:09:47 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
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)
|
|
|
|
|
2019-05-21 15:09:47 +00:00
|
|
|
# In a static build, we need to find the package to bring the target into scope.
|
|
|
|
find_package(QtDoubleConversion QUIET)
|
|
|
|
|
2019-01-07 14:22:24 +00:00
|
|
|
if (HAVE__SPRINTF_L OR HAVE_SPRINTF_L)
|
2019-05-21 15:09:47 +00:00
|
|
|
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)
|
2019-01-07 14:22:24 +00:00
|
|
|
set(WrapDoubleConversion_FOUND 1)
|
|
|
|
else()
|
|
|
|
set(WrapDoubleConversion_FOUND 0)
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|