diff options
author | Li Xinwei <1326710505@qq.com> | 2021-05-27 19:41:43 +0800 |
---|---|---|
committer | Li Xinwei <1326710505@qq.com> | 2021-06-02 13:32:06 +0800 |
commit | 2c49f85380d7ad79d9473e0f42e7afaa36d31af9 (patch) | |
tree | bb4a601432cfdf9fb8fb89fceeeed2feadac2b0c /cmake/QtGenerateLibPri.cmake | |
parent | 350902f1cd631ae2387e4c9308c905abf618085d (diff) |
CMake: Fix generated prl and pri files for MSVC
In MSVC static build, if we build Qt with 3rdparty library (e.g. zstd),
cmake will add"zstd" (without "-l" prefix) to Qt6Core.prl. Then we
use this Qt to build a qmake project, compilation will fail due to
missing zstd.obj. Without "-l" prefix, qmake will treat "zstd" as an
object file instead of a library.
Library names in qt_module.pri and qt_lib_*_private.pri are also
missing "-l" prefix.
This is because on most compilers, CMAKE_LINK_LIBRARY_FLAG equals
"-l". But on MSVC, it is an empty string. So we should pass
"-DLINK_LIBRARY_FLAG=-l" for MSVC.
Also add "-L/path/to/library" if the library path is not in default
linker search directories. This will write un-relocatable paths to prl
files only when using 3rdparty libraries to build Qt statically. Usually
it's not a problem.
In addition, CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is also empty on
MSVC. So The third argument of "$<FILTER>" is empty, it is an invalid
generator expression. This means no include dir will be written to
qt_module.pri and qt_lib_*_private.pri on MSVC. So only use "$<FILTER>"
when CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not empty.
Pick-to: 6.1
Change-Id: Ib66f95dc09cf920363a4b9338fb97747dd2f8ab7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtGenerateLibPri.cmake')
-rw-r--r-- | cmake/QtGenerateLibPri.cmake | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/cmake/QtGenerateLibPri.cmake b/cmake/QtGenerateLibPri.cmake index f5763899e6..3c5e860e16 100644 --- a/cmake/QtGenerateLibPri.cmake +++ b/cmake/QtGenerateLibPri.cmake @@ -7,6 +7,7 @@ # LIBRARY_SUFFIXES: list of known library extensions, e.g. .so;.a on Linux # LIBRARY_PREFIXES: list of known library prefies, e.g. the "lib" in "libz" on on Linux # LINK_LIBRARY_FLAG: flag used to link a shared library to an executable, e.g. -l on UNIX +# IMPLICIT_LINK_DIRECTORIES: list of implicit linker search paths # # QMAKE_LIBS_XXX values are split into QMAKE_LIBS_XXX_DEBUG and QMAKE_LIBS_XXX_RELEASE if # debug_and_release was detected. The CMake configuration "Debug" is considered for the _DEBUG |