diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-02 10:33:04 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-03 16:05:19 +0200 |
commit | d2931a2626eb67b8b39e25fc62501c01901ab1d3 (patch) | |
tree | f2245dbe7e98d0b56ca816a5a845938234b500fd /util/cmake/pro2cmake.py | |
parent | de78425ca0c508eb02aaac794ecbcda5ff09a5eb (diff) |
CMake: Handle standalone config.tests in configure libraries section
Some library entries in configure.json have a test entry.
An example is assimp in qtquick3d.
qmake tries to find the library via the sources section, and then tries
to compile the test found in config.tests/assimp/assimp.pro while
automagically passing it the include and link flags it found for assimp.
We didn't handle that in CMake, and now we kind of do.
configurejson2cmake will now create a corresponding
qt_config_compile_test call where it will pass a list of packages and
libraries to find and link against.
pro2cmake will in turn generate new code for the standalone
config.test project. This code will iterate over packages that need to
be found (like WrapAssimp) and then link against a list of passed-in
targets.
In this way the config.test/assimp/main.cpp file can successfully
use assimp code (due to propagated include headers).
qt_config_compile_test is augmented to take a new PACKAGES argument,
with an example as follows
PACKAGES PACKAGE Foo 6 COMPONENTS Bar
PACKAGE Baz REQUIRED
The arguments will be parsed and passed to the try_compile project,
to call find_package() on them.
We also need to pass the C/C++ standard values to the try_compile
project, as well as other try_compile specific flags, like the
toolchain, as given by qt_get_platform_try_compile_vars().
Change-Id: I4a3f76c75309c70c78e580b80114b33870b2cf79
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-x | util/cmake/pro2cmake.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index e496a2448d..8d1a62ddc9 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -3912,7 +3912,17 @@ def handle_config_test_project(scope: Scope, cm_fh: IO[str]): project_name = os.path.splitext(os.path.basename(scope.file_absolute_path))[0] content = ( f"cmake_minimum_required(VERSION 3.14.0)\n" - f"project(config_test_{project_name} LANGUAGES CXX)\n" + f"project(config_test_{project_name} LANGUAGES C CXX)\n" + """ +foreach(p ${QT_CONFIG_COMPILE_TEST_PACKAGES}) + find_package(${p}) +endforeach() + +if(QT_CONFIG_COMPILE_TEST_LIBRARIES) + link_libraries(${QT_CONFIG_COMPILE_TEST_LIBRARIES}) +endif() + +""" ) cm_fh.write(f"{content}\n") |