| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  | #.rst:
 | 
					
						
							|  |  |  | # FindQt5
 | 
					
						
							|  |  |  | # -------
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Qt5 wrapper around Qt6 CMake code.
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | unset(__arguments)
 | 
					
						
							|  |  |  | if (Qt5_FIND_QUIETLY)
 | 
					
						
							|  |  |  |   list(APPEND __arguments QUIET)
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | if (Qt5_FIND_REQUIRED)
 | 
					
						
							|  |  |  |   list(APPEND __arguments REQUIRED)
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (Qt5_FIND_COMPONENTS)
 | 
					
						
							|  |  |  |   # for some reason QUIET doesn't really work when passed to the arguments list
 | 
					
						
							|  |  |  |   if (Qt5_FIND_QUIETLY)
 | 
					
						
							|  |  |  |     list(APPEND __arguments OPTIONAL_COMPONENTS)
 | 
					
						
							|  |  |  |   else()
 | 
					
						
							|  |  |  |     list(APPEND __arguments COMPONENTS)
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 13:36:44 +02:00
										 |  |  | find_package(Qt6 ${Qt5_FIND_VERSION} CONFIG COMPONENTS Core QUIET)
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  | if (NOT Qt6_FOUND)
 | 
					
						
							| 
									
										
										
										
											2020-09-07 09:50:15 +02:00
										 |  |  |   # remove Core5Compat from components to find in Qt5, but add a dummy target,
 | 
					
						
							|  |  |  |   # which unfortunately cannot start with "Qt6::"
 | 
					
						
							| 
									
										
										
										
											2020-10-30 16:58:46 +01:00
										 |  |  |   # also remove Tools, where some tools have moved in Qt6, e.g. from Help
 | 
					
						
							| 
									
										
										
										
											2020-09-07 09:50:15 +02:00
										 |  |  |   list(REMOVE_ITEM Qt5_FIND_COMPONENTS Core5Compat)
 | 
					
						
							| 
									
										
										
										
											2020-10-30 16:58:46 +01:00
										 |  |  |   list(REMOVE_ITEM Qt5_FIND_COMPONENTS Tools)
 | 
					
						
							| 
									
										
										
										
											2020-09-03 13:36:44 +02:00
										 |  |  |   find_package(Qt5 ${Qt5_FIND_VERSION} CONFIG ${__arguments} ${Qt5_FIND_COMPONENTS})
 | 
					
						
							| 
									
										
										
										
											2020-09-07 09:50:15 +02:00
										 |  |  |   if (NOT TARGET Qt6Core5Compat)
 | 
					
						
							|  |  |  |     add_library(Qt6Core5Compat INTERFACE)
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Remove Qt6 from the not found packages in Qt5 mode
 | 
					
						
							|  |  |  |   get_property(not_found_packages GLOBAL PROPERTY "PACKAGES_NOT_FOUND")
 | 
					
						
							|  |  |  |   if(not_found_packages)
 | 
					
						
							|  |  |  |     list(REMOVE_ITEM not_found_packages Qt6)
 | 
					
						
							|  |  |  |     set_property(GLOBAL PROPERTY "PACKAGES_NOT_FOUND" "${not_found_packages}")
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							|  |  |  |   return()
 | 
					
						
							|  |  |  | else()
 | 
					
						
							|  |  |  |   find_package(Qt6 CONFIG ${__arguments} ${Qt5_FIND_COMPONENTS})
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | foreach(comp IN LISTS Qt5_FIND_COMPONENTS)
 | 
					
						
							|  |  |  |   if(TARGET Qt6::${comp})
 | 
					
						
							|  |  |  |     if (NOT TARGET Qt5::${comp})
 | 
					
						
							|  |  |  |       set_property(TARGET Qt6::${comp} PROPERTY IMPORTED_GLOBAL TRUE)
 | 
					
						
							|  |  |  |       add_library(Qt5::${comp} ALIAS Qt6::${comp})
 | 
					
						
							|  |  |  |     endif()
 | 
					
						
							|  |  |  |     if (TARGET Qt6::${comp}Private AND NOT TARGET Qt5::${comp}Private)
 | 
					
						
							|  |  |  |       set_property(TARGET Qt6::${comp}Private PROPERTY IMPORTED_GLOBAL TRUE)
 | 
					
						
							|  |  |  |       add_library(Qt5::${comp}Private ALIAS Qt6::${comp}Private)
 | 
					
						
							|  |  |  |     endif()
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							|  |  |  | endforeach()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-07 09:50:15 +02:00
										 |  |  | # 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()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  | set(Qt5_FOUND ${Qt6_FOUND})
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:31:28 +02:00
										 |  |  | set(Qt5_VERSION ${Qt6_VERSION})
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-30 10:04:28 +01:00
										 |  |  | foreach(tool qmake lrelease moc rcc qhelpgenerator)
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  |   if (TARGET Qt6::${tool} AND NOT TARGET Qt5::${tool})
 | 
					
						
							|  |  |  |     add_executable(Qt5::${tool} IMPORTED GLOBAL)
 | 
					
						
							| 
									
										
										
										
											2020-11-11 15:53:54 +01:00
										 |  |  |     get_target_property(imported_location Qt6::${tool} IMPORTED_LOCATION)
 | 
					
						
							| 
									
										
										
										
											2019-09-23 17:58:34 +02:00
										 |  |  |     set_target_properties(Qt5::${tool} PROPERTIES IMPORTED_LOCATION "${imported_location}")
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							|  |  |  | endforeach()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (NOT DEFINED qt5_wrap_cpp)
 | 
					
						
							|  |  |  |   function(qt5_wrap_cpp outfiles)
 | 
					
						
							|  |  |  |     qt6_wrap_cpp(${outfiles} ${ARGN})
 | 
					
						
							|  |  |  |     set(${outfiles} ${${outfiles}} PARENT_SCOPE)
 | 
					
						
							|  |  |  |   endfunction()
 | 
					
						
							|  |  |  | endif()
 |