2018-12-17 19:57:18 +00:00
|
|
|
defineTest(qtToolchainError) {
|
|
|
|
msg = \
|
|
|
|
$$1 \
|
|
|
|
"===================" \
|
|
|
|
$$2 \
|
|
|
|
"===================" \
|
|
|
|
$$3
|
|
|
|
error($$join(msg, $$escape_expand(\\n)))
|
|
|
|
}
|
|
|
|
|
2018-12-17 20:18:18 +00:00
|
|
|
defineTest(qtCompilerError) {
|
2017-08-04 09:01:25 +00:00
|
|
|
!cross_compile: \
|
|
|
|
what =
|
|
|
|
else: host_build: \
|
|
|
|
what = " host"
|
|
|
|
else: \
|
|
|
|
what = " target"
|
2018-12-17 19:57:18 +00:00
|
|
|
qtToolchainError("Cannot run$$what compiler '$$1'. Output:", $$2, \
|
|
|
|
"Maybe you forgot to setup the environment?")
|
2017-08-04 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 19:58:45 +00:00
|
|
|
cross_compile:host_build: \
|
determine QMAKE_DEFAULT_{INC,LIB}DIRS separately for host and target
note that in principle this leaves room for a race condition, as the
first project to determine the host config is not going to be the
top-level one.
in qtbase and qtdeclarative, this is naturally serialized via the common
bootstrapped libraries (bootstrap resp. qmldevtools). activeqt, qt3d,
qtscxml, and qtwayland all build only one bootstrapped tool each.
qtwebengine makes a fake host build to create files for gyp/gn; the
convert_dict tool is declared a host tool, but isn't actually built when
x-building anyway, and even if, it's serialized on the former. qttools
needs explicit serialization, though. no other host builds exist within
qt as of now.
Task-number: QTBUG-58126
Change-Id: I81a02a2d98f2bfe5d6aaa51119d5e7919549f119
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-01-12 19:52:51 +00:00
|
|
|
target_prefix = QMAKE_HOST_CXX
|
|
|
|
else: \
|
|
|
|
target_prefix = QMAKE_CXX
|
|
|
|
|
2018-12-17 20:16:27 +00:00
|
|
|
#
|
|
|
|
# Determine and cache the compiler version
|
|
|
|
#
|
|
|
|
|
|
|
|
defineReplace(qtVariablesFromMSVC) {
|
|
|
|
ret = $$system("$$1 -nologo -E $$2 $$system_quote($$PWD/data/macros.cpp) 2>NUL", lines, ec)
|
|
|
|
!equals(ec, 0): qtCompilerError($$1, $$ret)
|
|
|
|
return($$ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
defineReplace(qtVariablesFromGCC) {
|
|
|
|
ret = $$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) \
|
|
|
|
2>$$QMAKE_SYSTEM_NULL_DEVICE", lines, ec)
|
|
|
|
!equals(ec, 0): qtCompilerError($$1, $$ret)
|
|
|
|
return($$ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
isEmpty($${target_prefix}.COMPILER_MACROS) {
|
|
|
|
msvc {
|
|
|
|
clang_cl {
|
|
|
|
# We need to obtain the cl.exe version first
|
|
|
|
vars = $$qtVariablesFromMSVC(cl)
|
|
|
|
for (v, vars) {
|
|
|
|
isEmpty(v)|contains(v, $${LITERAL_HASH}.*): next()
|
|
|
|
eval($$v)
|
|
|
|
}
|
|
|
|
isEmpty(QMAKE_MSC_FULL_VER): error("Could not determine the Visual Studio version")
|
|
|
|
|
|
|
|
QMAKE_CFLAGS_MSVC_COMPAT = $$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", \
|
|
|
|
"-fms-compatibility-version=\\1.\\2.\\3")
|
|
|
|
cache($${target_prefix}.QMAKE_CFLAGS_MSVC_COMPAT, set stash, QMAKE_CFLAGS_MSVC_COMPAT)
|
|
|
|
$${target_prefix}.COMPILER_MACROS += QMAKE_CFLAGS_MSVC_COMPAT
|
|
|
|
vars = $$qtVariablesFromMSVC($$QMAKE_CXX, $$QMAKE_CFLAGS_MSVC_COMPAT)
|
|
|
|
} else {
|
|
|
|
vars = $$qtVariablesFromMSVC($$QMAKE_CXX)
|
|
|
|
}
|
|
|
|
} else: gcc|ghs {
|
|
|
|
vars = $$qtVariablesFromGCC($$QMAKE_CXX)
|
|
|
|
}
|
|
|
|
for (v, vars) {
|
|
|
|
!contains(v, "[A-Z_]+ = .*"): next()
|
|
|
|
# Set both <varname> for the outer scope ...
|
|
|
|
eval($$v)
|
|
|
|
v ~= s/ .*//
|
|
|
|
isEmpty($$v): error("Compiler produced empty value for $${v}.")
|
|
|
|
# ... and save QMAKE_(HOST_)?CXX.<varname> in the cache.
|
|
|
|
cache($${target_prefix}.$$v, set stash, $$v)
|
|
|
|
$${target_prefix}.COMPILER_MACROS += $$v
|
|
|
|
}
|
|
|
|
cache($${target_prefix}.COMPILER_MACROS, set stash)
|
|
|
|
} else {
|
|
|
|
# load from the cache
|
|
|
|
for (i, $${target_prefix}.COMPILER_MACROS): \
|
|
|
|
$$i = $$eval($${target_prefix}.$$i)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Populate QMAKE_COMPILER_DEFINES and some compatibility variables.
|
|
|
|
# The $$format_number() calls strip leading zeros to avoid misinterpretation as octal.
|
|
|
|
QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX
|
|
|
|
!isEmpty(QMAKE_MSC_VER): \
|
|
|
|
QMAKE_COMPILER_DEFINES += _MSC_VER=$$QMAKE_MSC_VER _MSC_FULL_VER=$$QMAKE_MSC_FULL_VER
|
|
|
|
!isEmpty(QMAKE_ICC_VER): \
|
|
|
|
QMAKE_COMPILER_DEFINES += __INTEL_COMPILER=$$QMAKE_ICC_VER __INTEL_COMPILER_UPDATE=$$QMAKE_ICC_UPDATE_VER
|
|
|
|
!isEmpty(QMAKE_APPLE_CC): \
|
|
|
|
QMAKE_COMPILER_DEFINES += __APPLE_CC__=$$QMAKE_APPLE_CC
|
|
|
|
!isEmpty(QMAKE_APPLE_CLANG_MAJOR_VERSION): \
|
|
|
|
QMAKE_COMPILER_DEFINES += __clang__ \
|
|
|
|
__clang_major__=$$QMAKE_APPLE_CLANG_MAJOR_VERSION \
|
|
|
|
__clang_minor__=$$QMAKE_APPLE_CLANG_MINOR_VERSION \
|
|
|
|
__clang_patchlevel__=$$QMAKE_APPLE_CLANG_PATCH_VERSION
|
|
|
|
!isEmpty(QMAKE_CLANG_MAJOR_VERSION): \
|
|
|
|
QMAKE_COMPILER_DEFINES += __clang__ \
|
|
|
|
__clang_major__=$$QMAKE_CLANG_MAJOR_VERSION \
|
|
|
|
__clang_minor__=$$QMAKE_CLANG_MINOR_VERSION \
|
|
|
|
__clang_patchlevel__=$$QMAKE_CLANG_PATCH_VERSION
|
|
|
|
!isEmpty(QMAKE_GCC_MAJOR_VERSION): \
|
|
|
|
QMAKE_COMPILER_DEFINES += \
|
|
|
|
__GNUC__=$$QMAKE_GCC_MAJOR_VERSION \
|
|
|
|
__GNUC_MINOR__=$$QMAKE_GCC_MINOR_VERSION \
|
|
|
|
__GNUC_PATCHLEVEL__=$$QMAKE_GCC_PATCH_VERSION
|
|
|
|
!isEmpty(QMAKE_GHS_VERSION): \
|
|
|
|
QMAKE_COMPILER_DEFINES += __ghs__ __GHS_VERSION_NUMBER=$$QMAKE_GHS_VERSION
|
|
|
|
|
|
|
|
QMAKE_CFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT
|
|
|
|
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT
|
|
|
|
|
|
|
|
clang_cl|intel_icl {
|
|
|
|
include(../common/msvc-based-version.conf)
|
|
|
|
} else: msvc {
|
|
|
|
include(../common/msvc-version.conf)
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine and cache the default search paths
|
|
|
|
#
|
|
|
|
|
|
|
|
defineReplace(qtMakeExpand) {
|
|
|
|
out = "$$1"
|
|
|
|
for(ever) {
|
|
|
|
m = $$replace(out, ".*\\$\\(EXPORT_([^)]+)\\).*", \\1)
|
|
|
|
equals(m, $$out): \
|
|
|
|
return($$out)
|
|
|
|
out = $$replace(out, "\\$\\(EXPORT_$$m\\)", $$eval($$m))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-17 19:57:18 +00:00
|
|
|
defineReplace(qtSplitPathList) {
|
|
|
|
paths = $$split(1, $$QMAKE_DIRLIST_SEP)
|
|
|
|
ret =
|
|
|
|
for (p, paths): \
|
|
|
|
ret += $$clean_path($$p)
|
|
|
|
return($$ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
defineReplace(qtNmakePathList) {
|
|
|
|
paths =
|
|
|
|
for (p, 1): \
|
|
|
|
paths += $$shell_path($$p)
|
|
|
|
paths ~= s,$${LITERAL_HASH},^$${LITERAL_HASH},g
|
|
|
|
paths ~= s,\\$,\$\$,g
|
|
|
|
return($$join(paths, $$QMAKE_DIRLIST_SEP))
|
|
|
|
}
|
|
|
|
|
|
|
|
msvc {
|
|
|
|
arch = $$lower($$VCPROJ_ARCH)
|
|
|
|
equals(arch, x64): \ # may be "win32" or undefined
|
|
|
|
arch = amd64
|
|
|
|
else: !equals(arch, arm):!equals(arch, arm64): \ # may be "win32" or undefined
|
|
|
|
arch = x86
|
2020-06-05 07:24:37 +00:00
|
|
|
# Consider only ARM64 desktop builds to be cross-builds -
|
2018-12-17 19:57:18 +00:00
|
|
|
# the host is assumed to be Intel and capable of running the target
|
|
|
|
# executables (so building for x64 on x86 will break).
|
2020-06-05 07:24:37 +00:00
|
|
|
equals(arch, arm64): \
|
2018-12-17 19:57:18 +00:00
|
|
|
CONFIG += msvc_cross
|
|
|
|
}
|
|
|
|
|
determine QMAKE_DEFAULT_{INC,LIB}DIRS separately for host and target
note that in principle this leaves room for a race condition, as the
first project to determine the host config is not going to be the
top-level one.
in qtbase and qtdeclarative, this is naturally serialized via the common
bootstrapped libraries (bootstrap resp. qmldevtools). activeqt, qt3d,
qtscxml, and qtwayland all build only one bootstrapped tool each.
qtwebengine makes a fake host build to create files for gyp/gn; the
convert_dict tool is declared a host tool, but isn't actually built when
x-building anyway, and even if, it's serialized on the former. qttools
needs explicit serialization, though. no other host builds exist within
qt as of now.
Task-number: QTBUG-58126
Change-Id: I81a02a2d98f2bfe5d6aaa51119d5e7919549f119
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-01-12 19:52:51 +00:00
|
|
|
isEmpty($${target_prefix}.INCDIRS) {
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
#
|
|
|
|
# Get default include and library paths from compiler
|
|
|
|
#
|
2018-06-01 13:13:30 +00:00
|
|
|
wasm {
|
|
|
|
# wasm compiler does not work here, just use defaults
|
|
|
|
} else: gcc {
|
2017-09-24 05:26:30 +00:00
|
|
|
cmd_suffix = "<$$QMAKE_SYSTEM_NULL_DEVICE >$$QMAKE_SYSTEM_NULL_DEVICE"
|
|
|
|
equals(QMAKE_HOST.os, Windows): \
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
cmd_prefix = "set LC_ALL=C&"
|
2017-09-24 05:26:30 +00:00
|
|
|
else: \
|
|
|
|
cmd_prefix = "LC_ALL=C"
|
2017-01-26 02:52:22 +00:00
|
|
|
|
|
|
|
cxx_flags = $$QMAKE_CXXFLAGS
|
|
|
|
|
|
|
|
# Manually inject the sysroot for Apple Platforms because its resolution
|
|
|
|
# normally does not happen until default_post.prf. This is especially
|
|
|
|
# important for moc to gain the correct default include directory list.
|
|
|
|
# While technically incorrect but without any likely practical effect,
|
|
|
|
# UIKit simulator platforms will see the device SDK's sysroot in
|
|
|
|
# QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass.
|
2017-06-28 16:01:37 +00:00
|
|
|
darwin {
|
macOS: Don't hard-code x86_64 as the architecture when using qmake
The qmake variable QMAKE_APPLE_DEVICE_ARCHS was added for iOS,
to support universal builds, as the QT_ARCH is a single value.
Since the qmake macOS builds are non-universal (at the moment),
we remove the hard-coded value for QMAKE_APPLE_DEVICE_ARCHS on
macOS, and let the normal architecture test resolve the arch,
like on other platforms.
To ensure that the following configuration tests are run with
an -arch argument, we trigger a commit of the preliminary Qt
configuration after running the architecture test. This is not
strictly necessary, but makes it clearer what's going on during
configure.
The device_and_simulator configuration option was used by the
iOS toolchain, and needed to be moved up in the configuration
test order to not break later tests.
The logic in mac/default_post.prf for both Xcode and Makefiles
to add -arch flags was kept as is, based on the existing
variable, to avoid too many changes to this logic.
The logic in toolchain.prf was amended to make it clear and
ensure that it only applies to iOS builds. macOS builds do
not have this issue.
Pick-to: 6.0
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I70db7e4c27f0d3da5d0af33cb491d72c312d3fa8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-04 16:29:06 +00:00
|
|
|
uikit {
|
|
|
|
# Clang doesn't automatically pick up the architecture, just because
|
|
|
|
# we're passing the iOS sysroot below, and we will end up building the
|
|
|
|
# test for the host architecture, resulting in linker errors when
|
|
|
|
# linking against the iOS libraries. We work around this by passing
|
|
|
|
# the architecture explicitly.
|
|
|
|
cxx_flags += -arch $$first(QMAKE_APPLE_DEVICE_ARCHS)
|
|
|
|
}
|
2020-09-21 13:16:21 +00:00
|
|
|
|
2017-06-28 16:01:37 +00:00
|
|
|
uikit:macx-xcode: \
|
|
|
|
cxx_flags += -isysroot $$sdk_path_device.value
|
|
|
|
else: \
|
|
|
|
cxx_flags += -isysroot $$QMAKE_MAC_SDK_PATH
|
|
|
|
}
|
2017-01-26 02:52:22 +00:00
|
|
|
|
2017-06-06 19:34:56 +00:00
|
|
|
rim_qcc: \
|
|
|
|
# Need the cc1plus and ld command lines to pick up the paths
|
2017-09-24 05:26:30 +00:00
|
|
|
cxx_flags += $$QMAKE_LFLAGS_SHLIB -o $$QMAKE_SYSTEM_NULL_DEVICE -v
|
2017-07-07 11:48:21 +00:00
|
|
|
else: darwin:clang: \
|
2017-05-30 12:43:08 +00:00
|
|
|
# Need to link to pick up library paths
|
2020-05-27 11:55:33 +00:00
|
|
|
cxx_flags += -g0 $$QMAKE_LFLAGS_SHLIB -o /dev/null -v -Wl,-v
|
2017-05-30 12:43:08 +00:00
|
|
|
else: \
|
2017-07-07 11:48:21 +00:00
|
|
|
# Just preprocess, might not pick up library paths
|
2017-05-30 12:43:08 +00:00
|
|
|
cxx_flags += -E -v
|
|
|
|
|
2017-06-08 12:39:05 +00:00
|
|
|
output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ - 2>&1 $$cmd_suffix", lines, ec)
|
2018-12-17 20:18:18 +00:00
|
|
|
!equals(ec, 0): qtCompilerError($$QMAKE_CXX, $$output)
|
2017-06-06 19:34:56 +00:00
|
|
|
|
|
|
|
rim_qcc {
|
|
|
|
for (line, output) {
|
|
|
|
contains(line, "^[^ ]*cc1plus .*") {
|
|
|
|
take_next = false
|
|
|
|
for (parameter, $$list($$line)) {
|
|
|
|
$$take_next {
|
|
|
|
QMAKE_DEFAULT_INCDIRS += $$clean_path($$parameter)
|
|
|
|
take_next = false
|
|
|
|
} else: equals(parameter, "-isystem") {
|
|
|
|
take_next = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else: contains(line, "^[^ ]*-ld .*") {
|
|
|
|
for (parameter, $$list($$line)) {
|
|
|
|
contains(parameter, "^-L.*") {
|
|
|
|
parameter ~= s/^-L//
|
|
|
|
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$parameter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
add_includes = false
|
|
|
|
add_libraries = false
|
|
|
|
for (line, output) {
|
|
|
|
line ~= s/^[ \\t]*// # remove leading spaces
|
|
|
|
contains(line, "LIBRARY_PATH=.*") {
|
|
|
|
line ~= s/^LIBRARY_PATH=// # remove leading LIBRARY_PATH=
|
2019-02-03 13:42:27 +00:00
|
|
|
equals(QMAKE_HOST.os, Windows): \
|
|
|
|
paths = $$split(line, ;)
|
|
|
|
else: \
|
|
|
|
paths = $$split(line, $$QMAKE_DIRLIST_SEP)
|
2017-06-06 19:34:56 +00:00
|
|
|
for (path, paths): \
|
|
|
|
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$path)
|
|
|
|
} else: contains(line, "Library search paths:") {
|
|
|
|
add_libraries = true
|
|
|
|
} else: contains(line, "$${LITERAL_HASH}include <.*") { # #include <...> search starts here:
|
|
|
|
add_includes = true
|
|
|
|
} else: contains(line, "End of search.*") {
|
|
|
|
add_includes = false
|
|
|
|
} else: $$add_libraries {
|
|
|
|
# We assume all library search paths are absolute
|
|
|
|
!contains(line, "^/.*") {
|
|
|
|
add_libraries = false
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$line)
|
|
|
|
} else: $$add_includes {
|
|
|
|
!contains(line, ".* \\(framework directory\\)"): \
|
|
|
|
QMAKE_DEFAULT_INCDIRS += $$clean_path($$line)
|
2017-05-30 12:43:08 +00:00
|
|
|
}
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-26 21:24:31 +00:00
|
|
|
if(!darwin:clang)|intel_icc {
|
Fix detection of QMAKE_DEFAULT_LIBDIRS with Clang under Linux
With 4183475080d334d7d17d02e6ad4eb53c01205c54, Qt fails to build if
qmake is unable to detect the compiler's default include and
library search paths. Clang on non-Darwin systems was missing working
code for the detection.
Unlike GCC, Clang on its own does not print the library search paths
when called with the -v option.
On Darwin, the -Wl,-v option will reach ld64, which will print those paths.
However, neither GNU ld nor gold will print anything useful with just
-v. GNU ld has a --verbose option that does print some search paths, but
those are not the ones used when ld is invoked (via collect2) by GCC or
Clang, so it can't be used.
To make Clang print its library search paths one can use
-print-search-dirs, which however doesn't print include search paths. So
amend the existing code in order to make a second call to clang on
non-Darwin systems. This second call is used for library path detection,
and fixes the build on non-Darwin (tested on Linux).
Change-Id: Ic858f908ee1a2e0eb307abb074daee0ded38abd5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 22:56:38 +00:00
|
|
|
# Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld
|
|
|
|
# or gold under Linux) will not print any library search path. Need to use another
|
|
|
|
# invocation with different options (which in turn doesn't print include search
|
|
|
|
# paths, so it can't just be used in place of the above code).
|
|
|
|
# What's more, -print-search-dirs can't be used on clang on Apple because it
|
|
|
|
# won't print all the library paths (only the clang-internal ones).
|
2018-10-12 12:41:41 +00:00
|
|
|
output = $$system("$$cmd_prefix $$QMAKE_LINK $$QMAKE_LFLAGS -print-search-dirs", lines, ec)
|
2018-12-17 20:18:18 +00:00
|
|
|
!equals(ec, 0): qtCompilerError($$QMAKE_LINK, $$output)
|
Fix detection of QMAKE_DEFAULT_LIBDIRS with Clang under Linux
With 4183475080d334d7d17d02e6ad4eb53c01205c54, Qt fails to build if
qmake is unable to detect the compiler's default include and
library search paths. Clang on non-Darwin systems was missing working
code for the detection.
Unlike GCC, Clang on its own does not print the library search paths
when called with the -v option.
On Darwin, the -Wl,-v option will reach ld64, which will print those paths.
However, neither GNU ld nor gold will print anything useful with just
-v. GNU ld has a --verbose option that does print some search paths, but
those are not the ones used when ld is invoked (via collect2) by GCC or
Clang, so it can't be used.
To make Clang print its library search paths one can use
-print-search-dirs, which however doesn't print include search paths. So
amend the existing code in order to make a second call to clang on
non-Darwin systems. This second call is used for library path detection,
and fixes the build on non-Darwin (tested on Linux).
Change-Id: Ic858f908ee1a2e0eb307abb074daee0ded38abd5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 22:56:38 +00:00
|
|
|
|
|
|
|
for (line, output) {
|
|
|
|
contains(line, "^libraries: .*") {
|
|
|
|
line ~= s,^libraries: ,,
|
2019-04-25 09:13:13 +00:00
|
|
|
equals(QMAKE_HOST.os, Windows) {
|
|
|
|
# clang (7.x) on Windows uses the wrong path list separator ...
|
|
|
|
line ~= s,:(?![/\\\\]),;,
|
|
|
|
paths = $$split(line, ;)
|
|
|
|
} else {
|
|
|
|
paths = $$split(line, $$QMAKE_DIRLIST_SEP)
|
|
|
|
}
|
Fix detection of QMAKE_DEFAULT_LIBDIRS with Clang under Linux
With 4183475080d334d7d17d02e6ad4eb53c01205c54, Qt fails to build if
qmake is unable to detect the compiler's default include and
library search paths. Clang on non-Darwin systems was missing working
code for the detection.
Unlike GCC, Clang on its own does not print the library search paths
when called with the -v option.
On Darwin, the -Wl,-v option will reach ld64, which will print those paths.
However, neither GNU ld nor gold will print anything useful with just
-v. GNU ld has a --verbose option that does print some search paths, but
those are not the ones used when ld is invoked (via collect2) by GCC or
Clang, so it can't be used.
To make Clang print its library search paths one can use
-print-search-dirs, which however doesn't print include search paths. So
amend the existing code in order to make a second call to clang on
non-Darwin systems. This second call is used for library path detection,
and fixes the build on non-Darwin (tested on Linux).
Change-Id: Ic858f908ee1a2e0eb307abb074daee0ded38abd5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 22:56:38 +00:00
|
|
|
for (path, paths): \
|
|
|
|
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$replace(path, ^=, $$[SYSROOT]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-11 15:01:52 +00:00
|
|
|
isEmpty(QMAKE_DEFAULT_INCDIRS): \
|
2017-06-06 19:34:56 +00:00
|
|
|
!integrity: \
|
2023-09-11 15:01:52 +00:00
|
|
|
error("failed to parse default include paths from compiler output")
|
|
|
|
isEmpty(QMAKE_DEFAULT_LIBDIRS): \
|
|
|
|
!integrity:!darwin: \
|
|
|
|
error("failed to parse default library paths from compiler output")
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
|
2018-08-09 14:05:51 +00:00
|
|
|
} else: ghs {
|
|
|
|
cmd = $$QMAKE_CXX $$QMAKE_CXXFLAGS -$${LITERAL_HASH} -o /tmp/fake_output /tmp/fake_input.cpp
|
|
|
|
output = $$system("$$cmd", blob, ec)
|
2018-12-17 20:18:18 +00:00
|
|
|
!equals(ec, 0): qtCompilerError($$QMAKE_CXX, $$output)
|
2018-08-09 14:05:51 +00:00
|
|
|
output ~= s/\\\\\\n {8}//g
|
|
|
|
output = $$split(output, $$escape_expand(\\n))
|
|
|
|
for (line, output) {
|
|
|
|
contains(line, "^[^ ]+/ecom[^ ]+ .* /tmp/fake_input\\.cpp") {
|
|
|
|
for (parameter, $$list($$line)) {
|
|
|
|
contains(parameter, "^(-I|--include_no_mmd=|--sys_include=).*") {
|
|
|
|
parameter ~= s/^(-I|--include_no_mmd=|--sys_include=)//
|
|
|
|
QMAKE_DEFAULT_INCDIRS += $$clean_path($$parameter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else: contains(line, "^[^ ]+/elxr .*") {
|
|
|
|
for (parameter, $$list($$line)) {
|
|
|
|
contains(parameter, "^-L.*") {
|
|
|
|
parameter ~= s/^-L//
|
|
|
|
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$parameter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-17 19:57:18 +00:00
|
|
|
} else: msvc_cross {
|
|
|
|
# Use a batch file, because %VAR% in the system() call expands to
|
|
|
|
# the pre-script-call value, and !VAR! cannot be enabled outside
|
|
|
|
# a batch file without invoking another shell instance.
|
|
|
|
cmd = $$system_quote($$system_path($$PWD/data/dumpvcvars.bat))
|
|
|
|
|
|
|
|
hostArch = $$QMAKE_HOST.arch
|
|
|
|
equals(hostArch, x86_64): \
|
|
|
|
hostArch = amd64
|
|
|
|
!equals(arch, $$hostArch): \
|
|
|
|
arch = $${hostArch}_$$arch
|
|
|
|
|
|
|
|
isEmpty(MSVC_VER): \
|
|
|
|
error("Mkspec does not specify MSVC_VER. Cannot continue.")
|
|
|
|
versionAtLeast(MSVC_VER, 15.0) {
|
|
|
|
dir = $$(VSINSTALLDIR)
|
2020-10-26 07:52:46 +00:00
|
|
|
isEmpty(dir) {
|
|
|
|
version_parts = $$split(MSVC_VER, .)
|
|
|
|
MSVC_NEXT_MAJOR = $$num_add($$first(version_parts), 1)
|
|
|
|
vswhere = "$$getenv(ProgramFiles\(x86\))/Microsoft Visual Studio/Installer/vswhere.exe"
|
|
|
|
!exists($$vswhere): \
|
|
|
|
error("Could not find $$vswhere")
|
|
|
|
vswhere = $$system_quote($$system_path($$vswhere))
|
|
|
|
# -version parameter: A version range for instances to find. 15.0 will get all versions >= 15.0
|
|
|
|
# Example: [15.0,16.0) will find versions 15.*.
|
|
|
|
dir = $$system("$$vswhere -latest -version [$$MSVC_VER,$${MSVC_NEXT_MAJOR}.0] -property installationPath")
|
|
|
|
}
|
2018-12-17 19:57:18 +00:00
|
|
|
isEmpty(dir): \
|
|
|
|
error("Failed to find the Visual Studio installation directory.")
|
|
|
|
cmd += $$system_quote($$dir\\VC\\Auxiliary\\Build\\vcvarsall.bat) $$arch
|
|
|
|
} else {
|
|
|
|
dir = $$(VCINSTALLDIR)
|
|
|
|
isEmpty(dir): \
|
|
|
|
dir = $$read_registry(HKLM, \
|
|
|
|
"Software\\Microsoft\\VisualStudio\\$$MSVC_VER\\Setup\\VC\\ProductDir", 32)
|
|
|
|
isEmpty(dir): \
|
|
|
|
error("Failed to find the Visual C installation directory.")
|
|
|
|
cmd += $$system_quote($$dir\\vcvarsall.bat) $$arch
|
|
|
|
}
|
|
|
|
|
|
|
|
isEmpty(WINSDK_VER): \
|
|
|
|
error("Mkspec does not specify WINSDK_VER. Cannot continue.")
|
|
|
|
# We prefer the environment variable, because that may work around
|
|
|
|
# a broken registry entry after uninstalling a newer SDK.
|
|
|
|
# However, we do that only if the major+minor SDK version matches
|
|
|
|
# the one requested by the mkspec, as we might be building for a
|
|
|
|
# newer target than the host.
|
|
|
|
winsdk_ver = $$(WindowsSDKVersion)
|
|
|
|
!isEmpty(winsdk_ver) {
|
|
|
|
winsdk_ver ~= s,\\\\$,, # Work around SDK breakage.
|
|
|
|
!equals(WINSDK_VER, $$replace(winsdk_ver, ^(\\d+\\.\\d+).*$, \\1)): \
|
|
|
|
winsdk_ver =
|
|
|
|
}
|
|
|
|
!isEmpty(winsdk_ver) {
|
|
|
|
cmd += $$winsdk_ver
|
|
|
|
} else {
|
|
|
|
winsdk_ver = $$read_registry(HKLM, \
|
|
|
|
"Software\\Microsoft\\Microsoft SDKs\\Windows\\v$$WINSDK_VER\\ProductVersion", 32)
|
|
|
|
isEmpty(winsdk_ver): \
|
|
|
|
error("Windows SDK $$WINSDK_VER requested by mkspec is not installed. Cannot continue.")
|
|
|
|
cmd += $${winsdk_ver}.0
|
|
|
|
}
|
|
|
|
|
|
|
|
output = $$system("$$cmd 2>&1", lines, ec)
|
|
|
|
!equals(ec, 0): \
|
|
|
|
qtToolchainError("SDK setup script failed. Output:", $$output, \
|
|
|
|
"Command was: $$cmd")
|
|
|
|
lines = $$output
|
|
|
|
for(ever) {
|
|
|
|
isEmpty(lines): \
|
|
|
|
break()
|
|
|
|
line = $$take_first(lines)
|
|
|
|
equals(line, "=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+="): \
|
|
|
|
break()
|
|
|
|
}
|
|
|
|
!count(lines, 3): \
|
|
|
|
qtToolchainError("SDK setup script returned unexpected output:", $$output, \
|
|
|
|
"Command was: $$cmd")
|
|
|
|
|
|
|
|
# These contain only paths for the target.
|
|
|
|
QMAKE_DEFAULT_INCDIRS = $$qtSplitPathList($$member(lines, 0))
|
|
|
|
QMAKE_DEFAULT_LIBDIRS = $$qtSplitPathList($$member(lines, 1))
|
|
|
|
# PATH is inherently for the host, and paths that are not shadowed
|
|
|
|
# by vcvarsall.bat are assumed to contain only tools that work for
|
|
|
|
# both host and target builds.
|
|
|
|
QMAKE_DEFAULT_PATH = $$qtSplitPathList($$member(lines, 2))
|
|
|
|
# We de-duplicate, because the script just prepends to the paths for
|
|
|
|
# the host, some of which are identical to the ones for the target.
|
|
|
|
QMAKE_DEFAULT_PATH = $$unique(QMAKE_DEFAULT_PATH)
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
} else: msvc {
|
|
|
|
LIB = $$getenv("LIB")
|
|
|
|
QMAKE_DEFAULT_LIBDIRS = $$split(LIB, $$QMAKE_DIRLIST_SEP)
|
|
|
|
INCLUDE = $$getenv("INCLUDE")
|
|
|
|
QMAKE_DEFAULT_INCDIRS = $$split(INCLUDE, $$QMAKE_DIRLIST_SEP)
|
|
|
|
}
|
|
|
|
|
2023-09-11 15:01:52 +00:00
|
|
|
unix:!darwin:if(!cross_compile|host_build) {
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
isEmpty(QMAKE_DEFAULT_INCDIRS): QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include
|
|
|
|
isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib
|
|
|
|
}
|
|
|
|
|
2018-12-13 16:53:38 +00:00
|
|
|
# cache() complains about undefined variables and doesn't persist empty ones.
|
|
|
|
!isEmpty(QMAKE_DEFAULT_INCDIRS): \
|
|
|
|
cache($${target_prefix}.INCDIRS, set stash, QMAKE_DEFAULT_INCDIRS)
|
|
|
|
!isEmpty(QMAKE_DEFAULT_LIBDIRS): \
|
|
|
|
cache($${target_prefix}.LIBDIRS, set stash, QMAKE_DEFAULT_LIBDIRS)
|
2018-12-17 19:57:18 +00:00
|
|
|
!isEmpty(QMAKE_DEFAULT_PATH): \
|
|
|
|
cache($${target_prefix}.PATH, set stash, QMAKE_DEFAULT_PATH)
|
determine QMAKE_DEFAULT_{INC,LIB}DIRS separately for host and target
note that in principle this leaves room for a race condition, as the
first project to determine the host config is not going to be the
top-level one.
in qtbase and qtdeclarative, this is naturally serialized via the common
bootstrapped libraries (bootstrap resp. qmldevtools). activeqt, qt3d,
qtscxml, and qtwayland all build only one bootstrapped tool each.
qtwebengine makes a fake host build to create files for gyp/gn; the
convert_dict tool is declared a host tool, but isn't actually built when
x-building anyway, and even if, it's serialized on the former. qttools
needs explicit serialization, though. no other host builds exist within
qt as of now.
Task-number: QTBUG-58126
Change-Id: I81a02a2d98f2bfe5d6aaa51119d5e7919549f119
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-01-12 19:52:51 +00:00
|
|
|
} else {
|
|
|
|
QMAKE_DEFAULT_INCDIRS = $$eval($${target_prefix}.INCDIRS)
|
|
|
|
QMAKE_DEFAULT_LIBDIRS = $$eval($${target_prefix}.LIBDIRS)
|
2018-12-17 19:57:18 +00:00
|
|
|
QMAKE_DEFAULT_PATH = $$eval($${target_prefix}.PATH)
|
|
|
|
}
|
|
|
|
|
|
|
|
msvc_cross {
|
|
|
|
qmake_inc_exp.name = INCLUDE
|
|
|
|
qmake_inc_exp.value = $$qtNmakePathList($$QMAKE_DEFAULT_INCDIRS)
|
|
|
|
qmake_lib_exp.name = LIB
|
|
|
|
qmake_lib_exp.value = $$qtNmakePathList($$QMAKE_DEFAULT_LIBDIRS)
|
|
|
|
qmake_path_exp.name = PATH
|
|
|
|
qmake_path_exp.value = $$qtNmakePathList($$QMAKE_DEFAULT_PATH)
|
|
|
|
QMAKE_EXPORTED_VARIABLES += qmake_inc_exp qmake_lib_exp qmake_path_exp
|
fix QMAKE_DEFAULT_*DIRS resolution with apple SDK, take 2
the code got factored out to an own toolchain.prf file, which is
load()ed from default_pre.prf, so no change at first.
however, on mac, we shadow toolchain.prf, and make it load() sdk.prf
first.
a side effect, it has become harder to disable the use of an sdk
altogether: putting CONFIG-=sdk into a project file or the qmake
command line has no effect now. instead, it's possible to put it into
.qmake.{conf,cache}.
to make it simpler again, it's conceivable to finally add qmake -pre,
which would allow setting variables before default_pre.prf is executed.
take 2: there was nothing wrong with the original patch, but in 5.8,
CONFIG+=simulator_and_device moved from qconfig.pri to various prf files
that would do it according to the simulator_and_device configure
feature, which would be way too late for the "pulled ahead" sdk.prf
loading. as simulator_and_device is now gone entirely, it is safe to
re-apply this patch (mostly) as-is.
Task-number: QTBUG-56144
Change-Id: I6cf484982eaed8af39f7a539c60f5a087a299914
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
2016-10-14 11:14:13 +00:00
|
|
|
}
|
2016-12-15 15:20:27 +00:00
|
|
|
|
|
|
|
unset(target_prefix)
|