Рефакторинг myx_find_qt
This commit is contained in:
parent
1957cbdb5c
commit
0c9573d005
@ -1,34 +1,35 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
macro(myx_find_qt)
|
macro(myx_find_qt)
|
||||||
set(options)
|
set(options REQUIRED)
|
||||||
set(oneValueArgs VERSION)
|
set(oneValueArgs VERSION)
|
||||||
set(multiValueArgs COMPONENTS PRIVATE)
|
set(multiValueArgs COMPONENTS PRIVATE)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
if(ARG_VERSION)
|
if(NOT ARG_VERSION)
|
||||||
set(myx_qt_ver "${ARG_VERSION}")
|
set(ARG_VERSION "5")
|
||||||
else()
|
|
||||||
set(myx_qt_ver "5")
|
|
||||||
if(QT_DEFAULT_MAJOR_VERSION)
|
if(QT_DEFAULT_MAJOR_VERSION)
|
||||||
set(myx_qt_ver "${QT_DEFAULT_MAJOR_VERSION}")
|
set(ARG_VERSION "${QT_DEFAULT_MAJOR_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT (myx_qt_ver STREQUAL "5" OR myx_qt_ver STREQUAL "6"))
|
if(ARG_REQUIRED)
|
||||||
myx_message_fatal_error("Supported Qt versions are 5 and 6")
|
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")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(iter ${ARG_COMPONENTS})
|
foreach(iter ${ARG_COMPONENTS})
|
||||||
find_package(Qt${myx_qt_ver} COMPONENTS ${iter} REQUIRED)
|
find_package(Qt${ARG_VERSION} COMPONENTS ${iter} ${ARG_REQUIRED})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(iter ${ARG_PRIVATE})
|
foreach(iter ${ARG_PRIVATE})
|
||||||
find_package("Qt${myx_qt_ver}${iter}" COMPONENTS Private REQUIRED)
|
find_package("Qt${ARG_VERSION}${iter}" COMPONENTS Private ${ARG_REQUIRED})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
unset(myx_qt_ver)
|
|
||||||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
||||||
unset(ARG_${__iter})
|
unset(ARG_${__iter})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
Loading…
Reference in New Issue
Block a user