diff --git a/nc.cmake b/nc.cmake index 93e929b..11197cb 100644 --- a/nc.cmake +++ b/nc.cmake @@ -19,3 +19,4 @@ include ("${CMAKE_CURRENT_LIST_DIR}/nc_sanitizer.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_platform.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_optimisation.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_warnings.cmake") +include ("${CMAKE_CURRENT_LIST_DIR}/nc_deps.cmake") \ No newline at end of file diff --git a/nc_deps.cmake b/nc_deps.cmake new file mode 100644 index 0000000..245eada --- /dev/null +++ b/nc_deps.cmake @@ -0,0 +1,22 @@ +# Loads the provided arguments as components from find_package(cruft) if at least one is missing +macro (nc_deps) + if (${ARGC} LESS_EQUAL 0) + message (FATAL_ERROR "nc_deps requires at least one component") + endif () + + set (__nc_deps_lib_FAIL) + + foreach (__nc_deps_lib ${ARGN}) + if (NOT TARGET cruft::${__nc_deps_lib}) + message (WARNING "missing cruft::${lib}") + set (__nc_deps_lib_FAIL 1) + break () + endif() + endforeach () + + if (DEFINED __nc_deps_lib_FAIL) + message (STATUS "using find_package for cruft::${ARGN}") + find_package(cruft CONFIG REQUIRED COMPONENTS ${ARGN}) + endif () +endmacro () +