Skip to content

Commit

Permalink
CMakeLists: Fail for unmet dependencies
Browse files Browse the repository at this point in the history
If (optional) feature/plugin is required, but the dependency is not
found, the build will fail.

Before the build process continued by (silently) disabling the
feature/plugin.
  • Loading branch information
palinek committed Sep 19, 2016
1 parent 5cda400 commit 1c22479
Showing 1 changed file with 25 additions and 36 deletions.
61 changes: 25 additions & 36 deletions CMakeLists.txt
Expand Up @@ -99,14 +99,11 @@ setByDefault(CPULOAD_PLUGIN Yes)
if(CPULOAD_PLUGIN)
find_library(STATGRAB_LIB statgrab)

if(NOT(${STATGRAB_LIB} MATCHES "NOTFOUND"))
list(APPEND ENABLED_PLUGINS "Cpu Load")
add_subdirectory(plugin-cpuload)
else()
message(STATUS "")
message(STATUS "CPU Load plugin requires libstatgrab")
message(STATUS "")
if(NOT STATGRAB_LIB)
message(FATAL_ERROR "CPU Load plugin requires libstatgrab")
endif()
list(APPEND ENABLED_PLUGINS "Cpu Load")
add_subdirectory(plugin-cpuload)
endif()

setByDefault(DIRECTORYMENU_PLUGIN Yes)
Expand Down Expand Up @@ -161,14 +158,11 @@ setByDefault(SENSORS_PLUGIN Yes)
if(SENSORS_PLUGIN)
find_library(SENSORS_LIB sensors)

if(NOT(${SENSORS_LIB} MATCHES "NOTFOUND"))
list(APPEND ENABLED_PLUGINS "Sensors")
add_subdirectory(plugin-sensors)
else()
message(STATUS "")
message(STATUS "Sensors plugin requires lm_sensors")
message(STATUS "")
if(NOT SENSORS_LIB)
message(FATAL_ERROR "Sensors plugin requires lm_sensors")
endif()
list(APPEND ENABLED_PLUGINS "Sensors")
add_subdirectory(plugin-sensors)
endif()

setByDefault(SHOWDESKTOP_PLUGIN Yes)
Expand All @@ -183,14 +177,11 @@ setByDefault(NETWORKMONITOR_PLUGIN Yes)
if(NETWORKMONITOR_PLUGIN)
find_library(STATGRAB_LIB statgrab)

if(NOT(${STATGRAB_LIB} MATCHES "NOTFOUND"))
list(APPEND ENABLED_PLUGINS "Network Monitor")
add_subdirectory(plugin-networkmonitor)
else()
message(STATUS "")
message(STATUS "Network Monitor plugin requires libstatgrab")
message(STATUS "")
if(NOT STATGRAB_LIB)
message(FATAL_ERROR "Network Monitor plugin requires libstatgrab")
endif()
list(APPEND ENABLED_PLUGINS "Network Monitor")
add_subdirectory(plugin-networkmonitor)
endif()

setByDefault(SYSSTAT_PLUGIN Yes)
Expand Down Expand Up @@ -229,27 +220,25 @@ setByDefault(VOLUME_USE_ALSA Yes)
if(VOLUME_PLUGIN)
if (VOLUME_USE_PULSEAUDIO)
find_package(PulseAudio)
if (NOT PULSEAUDIO_FOUND)
message(FATAL_ERROR "PulseAudio not found, but required (VOLUME_USE_PULSEAUDIO) for Volume plugin!")
endif ()
endif(VOLUME_USE_PULSEAUDIO)

if(VOLUME_USE_ALSA)
find_package(ALSA)
if (NOT ALSA_FOUND)
message(FATAL_ERROR "ALSA not found, but required (VOLUME_USE_ALSA) for Volume plugin!")
endif ()
endif()

if(PULSEAUDIO_FOUND OR ALSA_FOUND)
list(APPEND ENABLED_PLUGINS "Volume")
message(STATUS "")
message(STATUS "Volume plugin will be built")
message(STATUS " ALSA: ${ALSA_FOUND}")
message(STATUS " PulseAudio: ${PULSEAUDIO_FOUND}")
message(STATUS "")
add_subdirectory(plugin-volume)
else()
message(STATUS "")
message(STATUS "Volume plugin requires pulseaudio or alsa")
message(STATUS " ALSA: ${ALSA_FOUND}")
message(STATUS " PulseAudio: ${PULSEAUDIO_FOUND}")
message(STATUS "")
endif()
list(APPEND ENABLED_PLUGINS "Volume")
message(STATUS "")
message(STATUS "Volume plugin will be built")
message(STATUS " ALSA: ${ALSA_FOUND}")
message(STATUS " PulseAudio: ${PULSEAUDIO_FOUND}")
message(STATUS "")
add_subdirectory(plugin-volume)
endif()

setByDefault(WORLDCLOCK_PLUGIN Yes)
Expand Down

0 comments on commit 1c22479

Please sign in to comment.