From 0dbaf46b5cac9179312c0e9c00e9cc1462322d66 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Tue, 11 Aug 2015 10:51:23 -0700 Subject: cmake: added variable to LIBUHD_REGISTER_COMPONENT macro to make required, set LibUHD to required * If required component's dependencies aren't met, CMake will throw an error unless user specifically disables it --- host/cmake/Modules/UHDComponent.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'host/cmake') diff --git a/host/cmake/Modules/UHDComponent.cmake b/host/cmake/Modules/UHDComponent.cmake index bf4a50e33..5a7dd8c86 100644 --- a/host/cmake/Modules/UHDComponent.cmake +++ b/host/cmake/Modules/UHDComponent.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010-2011,2013 Ettus Research LLC +# Copyright 2010-2011,2013,2015 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,18 +26,31 @@ SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) # - enb the default enable setting # - deps a list of dependencies # - dis the default disable setting +# - req fail if dependencies not met (unless specifically disabled) ######################################################################## -MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis) +MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis req) MESSAGE(STATUS "") MESSAGE(STATUS "Configuring ${name} support...") FOREACH(dep ${deps}) MESSAGE(STATUS " Dependency ${dep} = ${${dep}}") ENDFOREACH(dep) + #if user specified option, store here + IF("${${var}}" STREQUAL "OFF") + SET(user_disabled TRUE) + ELSE() + SET(user_disabled FALSE) + ENDIF("${${var}}" STREQUAL "OFF") + #setup the dependent option for this component INCLUDE(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis}) + #if a required option's dependencies aren't met, fail unless user specifies otherwise + IF(NOT ${var} AND ${req} AND NOT user_disabled) + MESSAGE(FATAL_ERROR "Dependencies for required component ${name} not met.") + ENDIF(NOT ${var} AND ${req} AND NOT user_disabled) + #append the component into one of the lists IF(${var}) MESSAGE(STATUS " Enabling ${name} support.") -- cgit v1.2.3