myx/MyxCMake/lib/macro/FindPackages.cmake
2022-10-24 20:03:42 +03:00

35 lines
851 B
CMake

include_guard(GLOBAL)
macro(myx_find_required_packages)
set(options)
set(oneValueArgs)
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(iter ${ARG_PACKAGES})
find_package(${iter} REQUIRED)
endforeach()
if(ARG_Boost)
find_package(Boost COMPONENTS ${ARG_Boost} REQUIRED)
endif()
if(ARG_Qt5)
find_package(Qt5 COMPONENTS ${ARG_Qt5} REQUIRED)
endif()
if(ARG_Qt5Private)
foreach(iter ${ARG_Qt5Private})
find_package("Qt5${iter}" COMPONENTS Private REQUIRED)
endforeach()
endif()
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)
unset(oneValueArgs)
unset(options)
endmacro(myx_find_required_packages)