2023-08-01 08:21:33 +00:00
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
macro(myx_find_qt)
|
2023-08-01 08:42:24 +00:00
|
|
|
set(options REQUIRED)
|
2023-08-01 08:21:33 +00:00
|
|
|
set(oneValueArgs VERSION)
|
|
|
|
set(multiValueArgs COMPONENTS PRIVATE)
|
|
|
|
|
|
|
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
2023-08-01 08:42:24 +00:00
|
|
|
if(NOT ARG_VERSION)
|
|
|
|
set(ARG_VERSION "5")
|
2023-08-01 08:21:33 +00:00
|
|
|
if(QT_DEFAULT_MAJOR_VERSION)
|
2023-08-01 08:42:24 +00:00
|
|
|
set(ARG_VERSION "${QT_DEFAULT_MAJOR_VERSION}")
|
2023-08-01 08:21:33 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-08-01 08:42:24 +00:00
|
|
|
if(ARG_REQUIRED)
|
|
|
|
set(ARG_REQUIRED "REQUIRED")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT (ARG_VERSION STREQUAL "5" OR ARG_VERSION STREQUAL "6"))
|
|
|
|
message(FATAL_ERROR "Supported Qt versions are 5 and 6")
|
2023-08-01 08:21:33 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(iter ${ARG_COMPONENTS})
|
2023-08-01 08:42:24 +00:00
|
|
|
find_package(Qt${ARG_VERSION} COMPONENTS ${iter} ${ARG_REQUIRED})
|
2023-08-01 08:21:33 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(iter ${ARG_PRIVATE})
|
2023-08-01 08:42:24 +00:00
|
|
|
find_package("Qt${ARG_VERSION}${iter}" COMPONENTS Private ${ARG_REQUIRED})
|
2023-08-01 08:21:33 +00:00
|
|
|
endforeach()
|
|
|
|
|
2024-03-18 21:16:53 +00:00
|
|
|
foreach(iter IN LISTS oneValueArgs multiValueArgs)
|
|
|
|
unset(ARG_${iter})
|
2023-08-01 08:21:33 +00:00
|
|
|
endforeach()
|
|
|
|
unset(ARG_UNPARSED_ARGUMENTS)
|
|
|
|
unset(multiValueArgs)
|
|
|
|
unset(oneValueArgs)
|
|
|
|
unset(options)
|
|
|
|
endmacro()
|