summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-09 09:59:35 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-09 11:26:42 +0200
commit066e8a4557e7cbe98403bbf97b957f5f993f89c3 (patch)
treee62567f713a1088e892cb96a0c30c4c5db4163d7 /util/cmake/pro2cmake.py
parentc9b2528a9d60561e3050a3dadd86b893cd35349d (diff)
CMake: Handle missing packages in project compile tests
If a find_package() in a try_compile project doesn't find a package, and we then link against a non-existent target, the configuration failure of the compile test also fails the configuration of the project. To avoid that, separate library targets from non-targets, and make sure to only link against the targets if they exist. pro2cmake now outputs modified compile test project code which iterates over targets and non-target libraries, and links against them when needed. Change-Id: Ib0f4b5f07af13929c42d01a661df2cabdf9b926b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 87e2593d00..92b7597dcd 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -3948,7 +3948,13 @@ endforeach()
if(QT_CONFIG_COMPILE_TEST_LIBRARIES)
link_libraries(${QT_CONFIG_COMPILE_TEST_LIBRARIES})
endif()
-
+if(QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS)
+ foreach(lib ${QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS})
+ if(TARGET ${lib})
+ link_libraries(${lib})
+ endif()
+ endforeach()
+endif()
"""
)
cm_fh.write(f"{content}\n")