From 0c9573d005b0e191d8cb09386db28553c02c3247 Mon Sep 17 00:00:00 2001 From: Andrei Astafev Date: Tue, 1 Aug 2023 11:42:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20myx=5Ffind=5Fqt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyxCMake/lib/macro/FindQt.cmake | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/MyxCMake/lib/macro/FindQt.cmake b/MyxCMake/lib/macro/FindQt.cmake index 570030d..27a5fb5 100644 --- a/MyxCMake/lib/macro/FindQt.cmake +++ b/MyxCMake/lib/macro/FindQt.cmake @@ -1,34 +1,35 @@ include_guard(GLOBAL) macro(myx_find_qt) - set(options) + set(options REQUIRED) set(oneValueArgs VERSION) set(multiValueArgs COMPONENTS PRIVATE) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(ARG_VERSION) - set(myx_qt_ver "${ARG_VERSION}") - else() - set(myx_qt_ver "5") + if(NOT ARG_VERSION) + set(ARG_VERSION "5") if(QT_DEFAULT_MAJOR_VERSION) - set(myx_qt_ver "${QT_DEFAULT_MAJOR_VERSION}") + set(ARG_VERSION "${QT_DEFAULT_MAJOR_VERSION}") endif() endif() - if(NOT (myx_qt_ver STREQUAL "5" OR myx_qt_ver STREQUAL "6")) - myx_message_fatal_error("Supported Qt versions are 5 and 6") + 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") endif() foreach(iter ${ARG_COMPONENTS}) - find_package(Qt${myx_qt_ver} COMPONENTS ${iter} REQUIRED) + find_package(Qt${ARG_VERSION} COMPONENTS ${iter} ${ARG_REQUIRED}) endforeach() 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() - unset(myx_qt_ver) foreach(__iter IN LISTS oneValueArgs multiValueArgs) unset(ARG_${__iter}) endforeach()