From fd2edfdc08148b6612e89ea6b13f5e3eb095e496 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Mon, 21 Dec 2020 21:19:28 +0100
Subject: [PATCH] cmake: Display package versions in summary
---
cmake/03-libs.cmake | 19 +++++++++++++------
cmake/05-summary.cmake | 24 ++++++++++++------------
cmake/common/utils.cmake | 10 ++++------
3 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/cmake/03-libs.cmake b/cmake/03-libs.cmake
index 31aff535..895d27ba 100644
--- a/cmake/03-libs.cmake
+++ b/cmake/03-libs.cmake
@@ -7,19 +7,23 @@ find_package(CairoFC REQUIRED)
if (ENABLE_ALSA)
find_package(ALSA REQUIRED)
+ set(ALSA_VERSION ${ALSA_VERSION_STRING})
endif()
if (ENABLE_CURL)
find_package(CURL REQUIRED)
+ set(CURL_VERSION ${CURL_VERSION_STRING})
endif()
if (ENABLE_MPD)
find_package(LibMPDClient REQUIRED)
+ set(MPD_VERSION ${LibMPDClient_VERSION})
endif()
if (ENABLE_NETWORK)
if(WITH_LIBNL)
find_package(LibNlGenl3 REQUIRED)
+ set(NETWORK_LIBRARY_VERSION ${LibNlGenl3_VERSION})
else()
find_package(Libiw REQUIRED)
endif()
@@ -27,10 +31,9 @@ endif()
if (ENABLE_PULSEAUDIO)
find_package(LibPulse REQUIRED)
+ set(PULSEAUDIO_VERSION ${LibPulse_VERSION})
endif()
-# Randr is required
-set(XORG_EXTENSIONS RANDR)
if (WITH_XCOMPOSITE)
set(XORG_EXTENSIONS ${XORG_EXTENSIONS} COMPOSITE)
endif()
@@ -44,12 +47,16 @@ if (WITH_XRM)
set(XORG_EXTENSIONS ${XORG_EXTENSIONS} XRM)
endif()
-set(XCB_VERSION "")
-if (WITH_XRANDR_MONITOR)
- set(XCB_VERSION "1.12")
+# Set min xrandr version required
+if (WITH_XRANDR_MONITORS)
+ set(XRANDR_VERSION "1.12")
+else ()
+ set(XRANDR_VERSION "")
endif()
-find_package(Xcb ${XCB_VERSION} REQUIRED COMPONENTS ${XORG_EXTENSIONS})
+# Randr is required
+find_package(Xcb ${XRANDR_VERSION} REQUIRED COMPONENTS RANDR)
+find_package(Xcb REQUIRED COMPONENTS ${XORG_EXTENSIONS})
# FreeBSD Support
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
diff --git a/cmake/05-summary.cmake b/cmake/05-summary.cmake
index ddcb2b09..d8175355 100644
--- a/cmake/05-summary.cmake
+++ b/cmake/05-summary.cmake
@@ -21,21 +21,21 @@ colored_option(" testsuite" BUILD_TESTS)
colored_option(" documentation" BUILD_DOC)
message(STATUS " Module support:")
-colored_option(" alsa" ENABLE_ALSA)
-colored_option(" curl" ENABLE_CURL)
+colored_option(" alsa" ENABLE_ALSA ALSA_VERSION)
+colored_option(" curl" ENABLE_CURL CURL_VERSION)
colored_option(" i3" ENABLE_I3)
-colored_option(" mpd" ENABLE_MPD)
-colored_option(" network (${WIRELESS_LIB})" ENABLE_NETWORK)
-colored_option(" pulseaudio" ENABLE_PULSEAUDIO)
-colored_option(" xkeyboard" WITH_XKB)
+colored_option(" mpd" ENABLE_MPD MPD_VERSION)
+colored_option(" network (${WIRELESS_LIB})" ENABLE_NETWORK NETWORK_LIBRARY_VERSION)
+colored_option(" pulseaudio" ENABLE_PULSEAUDIO PULSEAUDIO_VERSION)
+colored_option(" xkeyboard" WITH_XKB Xcb_XKB_VERSION)
message(STATUS " X extensions:")
-colored_option(" xcb-randr" WITH_XRANDR)
-colored_option(" xcb-randr (monitor support)" WITH_XRANDR_MONITORS)
-colored_option(" xcb-composite" WITH_XCOMPOSITE)
-colored_option(" xcb-xkb" WITH_XKB)
-colored_option(" xcb-xrm" WITH_XRM)
-colored_option(" xcb-cursor" WITH_XCURSOR)
+colored_option(" xcb-randr" WITH_XRANDR Xcb_RANDR_VERSION)
+colored_option(" xcb-randr (monitor support)" WITH_XRANDR_MONITORS Xcb_RANDR_VERSION)
+colored_option(" xcb-composite" WITH_XCOMPOSITE Xcb_COMPOSITE_VERSION)
+colored_option(" xcb-xkb" WITH_XKB Xcb_XKB_VERSION)
+colored_option(" xcb-xrm" WITH_XRM Xcb_XRM_VERSION)
+colored_option(" xcb-cursor" WITH_XCURSOR Xcb_CURSOR_VERSION)
message(STATUS " Log options:")
colored_option(" Trace logging" DEBUG_LOGGER)
diff --git a/cmake/common/utils.cmake b/cmake/common/utils.cmake
index be9265a7..b02d5665 100644
--- a/cmake/common/utils.cmake
+++ b/cmake/common/utils.cmake
@@ -13,11 +13,8 @@ endfunction()
# colored_option {{{
function(colored_option text flag)
- # Append version of option, if ${flag}_VERSION is set
- set(version ${${flag}_VERSION})
-
- if(NOT "${version}" STREQUAL "")
- set(text "${text} (${version})")
+ if(ARGC GREATER 2 AND NOT "${${ARGV2}}" STREQUAL "")
+ set(text "${text} (${${ARGV2}})")
endif()
if(${flag})
@@ -90,6 +87,7 @@ macro(find_package_impl pkg_config_name find_pkg_name header_to_find)
set(${find_pkg_name}_INCLUDE_DIR ${PC_${find_pkg_name}_INCLUDE_DIRS})
set(${find_pkg_name}_INCLUDE_DIRS ${${find_pkg_name}_INCLUDE_DIR})
set(${find_pkg_name}_LIBRARY ${PC_${find_pkg_name}_LIBRARIES})
+ set(${find_pkg_name}_VERSION ${PC_${find_pkg_name}_VERSION})
set(${find_pkg_name}_LIBRARIES ${${find_pkg_name}_LIBRARY})
find_package_handle_standard_args(${find_pkg_name}
@@ -97,7 +95,7 @@ macro(find_package_impl pkg_config_name find_pkg_name header_to_find)
${find_pkg_name}_INCLUDE_DIRS
${find_pkg_name}_LIBRARIES
VERSION_VAR
- PC_${find_pkg_name}_VERSION
+ ${find_pkg_name}_VERSION
)
mark_as_advanced(${find_pkg_name}_INCLUDE_DIR ${find_pkg_name}_LIBRARY)