summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-02-27 13:49:04 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-02-27 16:11:43 +0000
commit58bd86443c437e50dee3b4e115d95e984006ab58 (patch)
treefc197de7d63bf5fd642cfb02f9a0667cbee55c2a /cmake
parentc971d2d3593def66c5627f47c575c2ed7ce04fec (diff)
Fix usage of linker -no-undefined flag for macOS
Change-Id: I41c55871a8db3d860fc20ad17eb9a97b01d62448 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake21
1 files changed, 15 insertions, 6 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index a75c0165c9..4fc60400f5 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -200,6 +200,19 @@ function(qt_internal_add_link_flags target to_add)
set_target_properties("${target}" PROPERTIES LINK_FLAGS "${flags}")
endfunction()
+function(qt_internal_add_link_flags_no_undefined target)
+ if (GCC OR CLANG)
+ if(APPLE)
+ set(no_undefined_flag "-Wl,-undefined,error")
+ elseif(LINUX)
+ set(no_undefined_flag "-Wl,--no-undefined")
+ else()
+ message(FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\"${target}\".")
+ endif()
+ qt_internal_add_link_flags("${target}" "${no_undefined_flag}")
+ endif()
+endfunction()
+
function(qt_internal_add_linker_version_script target)
qt_parse_all_arguments(arg "qt_internal_add_linker" "INTERNAL" "" "PRIVATE_HEADERS" ${ARGN})
@@ -562,9 +575,7 @@ function(add_qt_module target)
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
- if (GCC OR CLANG)
- qt_internal_add_link_flags("${target}" "-Wl,--no-undefined")
- endif()
+ qt_internal_add_link_flags_no_undefined("${target}")
# When a public module depends on private, also make its private depend on the other's private
set(qt_libs_private "")
@@ -680,9 +691,7 @@ function(add_qt_plugin target)
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
- if (GCC OR CLANG)
- qt_internal_add_link_flags("${target}" "-Wl,--no-undefined")
- endif()
+ qt_internal_add_link_flags_no_undefined("${target}")
qt_internal_add_linker_version_script(${target})
endfunction()