diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-09-07 09:50:15 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-09-07 10:13:39 +0000 |
commit | 102d8d48db92438eff0d59a7907bc18d42673ec5 (patch) | |
tree | 21d8fd6c094a7b4db6dfa1e2d85148aeafb2f2aa /cmake/FindQt5.cmake | |
parent | 7e8c3e91a19d9112aa12ef81ee42a160183bd7aa (diff) |
CMake build: Make Qt6::Core5Compat available in a portable way
While porting to Qt6 we'll need the compat library at some places.
Add a custom Qt6Core5Compat target that we can unconditionally use.
For Qt5 it refers to a dummy target.
For Qt6 it refers to the actual compat library.
Task-number: QTCREATORBUG-24098
Change-Id: Idd2b9f285352f685cfe715eee3fa046dfb468873
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/FindQt5.cmake')
-rw-r--r-- | cmake/FindQt5.cmake | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmake/FindQt5.cmake b/cmake/FindQt5.cmake index 45e21e5dfd..c0b4925078 100644 --- a/cmake/FindQt5.cmake +++ b/cmake/FindQt5.cmake @@ -24,7 +24,13 @@ endif() find_package(Qt6 ${Qt5_FIND_VERSION} CONFIG COMPONENTS Core QUIET) if (NOT Qt6_FOUND) + # remove Core5Compat from components to find in Qt5, but add a dummy target, + # which unfortunately cannot start with "Qt6::" + list(REMOVE_ITEM Qt5_FIND_COMPONENTS Core5Compat) find_package(Qt5 ${Qt5_FIND_VERSION} CONFIG ${__arguments} ${Qt5_FIND_COMPONENTS}) + if (NOT TARGET Qt6Core5Compat) + add_library(Qt6Core5Compat INTERFACE) + endif() # Remove Qt6 from the not found packages in Qt5 mode get_property(not_found_packages GLOBAL PROPERTY "PACKAGES_NOT_FOUND") @@ -50,6 +56,11 @@ foreach(comp IN LISTS Qt5_FIND_COMPONENTS) endif() endforeach() +# alias Qt6::Core5Compat to Qt6Core5Compat to make consistent with Qt5 path +if (TARGET Qt6::Core5Compat AND NOT TARGET Qt6CoreCompat) + add_library(Qt6Core5Compat ALIAS Qt6::Core5Compat) +endif() + set(Qt5_FOUND ${Qt6_FOUND}) set(Qt5_VERSION ${Qt6_VERSION}) |