From 2e1f3899978bd0f434cccc14903173a275b7bb47 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 24 Dec 2017 16:08:48 -0500 Subject: [PATCH 1/2] CMake: explain which modules are skipped Modules may be skipped for different reasons: SKIP_MODULES is the traditional approach to suppress some, but other modules may have unmet build requirements (e.g. Plasma Look-and-Feel, or the Partitioning module) and should be able to opt-out of being built. For all those skipped, log it explicitly after all the modules have been examined. Only CMake-based (e.g. C++) modules support opting-out in this way. --- .../CalamaresAddModuleSubdirectory.cmake | 12 ++++++++++++ src/modules/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CMakeModules/CalamaresAddModuleSubdirectory.cmake b/CMakeModules/CalamaresAddModuleSubdirectory.cmake index caf1b707e..12aad380f 100644 --- a/CMakeModules/CalamaresAddModuleSubdirectory.cmake +++ b/CMakeModules/CalamaresAddModuleSubdirectory.cmake @@ -3,15 +3,27 @@ include( CalamaresAddTranslations ) set( MODULE_DATA_DESTINATION share/calamares/modules ) +# Convenience function to indicate that a module has been skipped +# (optionally also why). Call this in the module's CMakeLists.txt +macro( calamares_skip_module ) + set( SKIPPED_MODULES ${SKIPPED_MODULES} ${ARGV} PARENT_SCOPE ) +endmacro() + function( calamares_add_module_subdirectory ) set( SUBDIRECTORY ${ARGV0} ) + set( SKIPPED_MODULES ) set( MODULE_CONFIG_FILES "" ) # If this subdirectory has a CMakeLists.txt, we add_subdirectory it... if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" ) add_subdirectory( ${SUBDIRECTORY} ) file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" ) + # Module has indicated it should be skipped, show that in + # the calling CMakeLists (which is src/modules/CMakeLists.txt normally). + if ( SKIPPED_MODULES ) + set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE ) + endif() # ...otherwise, we look for a module.desc. elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" ) set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules ) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index d48ecd29f..dceaef8dd 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -1,5 +1,11 @@ include( CMakeColors ) +# The variable SKIP_MODULES can be set to skip particular modules; +# individual modules can also decide they must be skipped (e.g. OS-specific +# modules, or ones with unmet dependencies). Collect the skipped modules +# in this list. +set( LIST_SKIPPED_MODULES "" ) + if( BUILD_TESTING ) add_executable( test_conf test_conf.cpp ) target_link_libraries( test_conf ${YAMLCPP_LIBRARY} ) @@ -13,11 +19,24 @@ foreach( SUBDIRECTORY ${SUBDIRECTORIES} ) if( NOT DO_SKIP EQUAL -1 ) message( "${ColorReset}-- Skipping module ${BoldRed}${SUBDIRECTORY}${ColorReset}." ) message( "" ) + list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (user request)" ) elseif( ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" ) AND ( DO_SKIP EQUAL -1 ) ) + set( SKIPPED_MODULES ) calamares_add_module_subdirectory( ${SUBDIRECTORY} ) + if ( SKIPPED_MODULES ) + list( APPEND LIST_SKIPPED_MODULES "${SKIPPED_MODULES}" ) + endif() endif() endforeach() +if ( LIST_SKIPPED_MODULES ) + message( "${ColorReset}-- Skipped modules:" ) + foreach( SUBDIRECTORY ${LIST_SKIPPED_MODULES} ) + message( "${ColorReset}-- Skipped ${BoldRed}${SUBDIRECTORY}${ColorReset}." ) + endforeach() + message( "" ) +endif() + include( CalamaresAddTranslations ) add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) From 661789825a8de9a644b58996652d54eebc9f10c1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 23 Dec 2017 10:07:42 -0500 Subject: [PATCH 2/2] [plasmalnf] Make the module optional - Check for presence of KDE Frameworks for Plasma & Package - Explain when module is skipped --- src/modules/plasmalnf/CMakeLists.txt | 55 +++++++++++++++++++--------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 8148a80e9..15897f98c 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -1,22 +1,41 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) -find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package ) +# Requires a sufficiently recent Plasma framework, but also +# needs a runtime support component (which we don't test for). +set( lnf_ver 5.41 ) -calamares_add_plugin( plasmalnf - TYPE viewmodule - EXPORT_MACRO PLUGINDLLEXPORT_PRO - SOURCES - PlasmaLnfViewStep.cpp - PlasmaLnfPage.cpp - PlasmaLnfJob.cpp - ThemeWidget.cpp - RESOURCES - page_plasmalnf.qrc - UI - page_plasmalnf.ui - LINK_PRIVATE_LIBRARIES - calamaresui - KF5::Package - KF5::Plasma - SHARED_LIB +find_package( KF5Plasma ${lnf_ver} ) +find_package( KF5Package ${lnf_ver} ) +set_package_properties( + KF5Plasma PROPERTIES + PURPOSE "For Plasma Look-and-Feel selection" ) +set_package_properties( + KF5Package PROPERTIES + PURPOSE "For Plasma Look-and-Feel selection" +) + +if ( KF5Plasma_FOUND AND KF5Package_FOUND ) + find_package( KF5 ${lnf_ver} REQUIRED CoreAddons Plasma Package ) + + calamares_add_plugin( plasmalnf + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + PlasmaLnfViewStep.cpp + PlasmaLnfPage.cpp + PlasmaLnfJob.cpp + ThemeWidget.cpp + RESOURCES + page_plasmalnf.qrc + UI + page_plasmalnf.ui + LINK_PRIVATE_LIBRARIES + calamaresui + KF5::Package + KF5::Plasma + SHARED_LIB + ) +else() + calamares_skip_module( "plasmalnf (missing requirements)" ) +endif()