diff --git a/CMakeLists.txt b/CMakeLists.txt index d72463bbd..1fa59421c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,22 @@ option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." ON ) option( WITH_KF5Crash "Enable crash reporting with KCrash." ON ) +### USE_* +# +# By convention, when there are multiple modules that implement similar +# functionality, and it only makes sense to have **at most one** of them +# enabled at any time, those modules are named -. +# For example, services-systemd and services-openrc. +# +# Setting up SKIP_MODULES to ignore "the ones you don't want" can be +# annoying and error-prone (e.g. if a new module shows up). The USE_* +# modules provide a way to do automatic selection. To pick exactly +# one of the implementations from group , set USE_ to the +# name of the implementation. If USE_ is unset, or empty, then +# all the implementations are enabled (this just means they are +# **available** to `settings.conf`, not that they are used). +# +# Currently, no USE_ variables exist. ### Calamares application info # diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 514d6b4f6..bf1817b52 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -15,13 +15,31 @@ string( REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}" ) file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" ) list( SORT SUBDIRECTORIES ) +# Handle the USE_ variables by looking for subdirectories +# with a - kind of name. +foreach( SUBDIRECTORY ${SUBDIRECTORIES} ) +endforeach() + foreach( SUBDIRECTORY ${SUBDIRECTORIES} ) list( FIND SKIP_LIST ${SUBDIRECTORY} DO_SKIP ) + set( _skip_reason "user request" ) + if( SUBDIRECTORY MATCHES "^[a-zA-Z0-9_]+-" ) + string( REGEX REPLACE "^[^-]+-" "" _implementation ${SUBDIRECTORY} ) + string( REGEX REPLACE "-.*" "" _category ${SUBDIRECTORY} ) + if( USE_${_category} ) + if( NOT "${_implementation}" STREQUAL "${USE_${_category}}" ) + list( APPEND SKIP_LIST ${SUBDIRECTORY} ) + set( _skip_reason "USE_${_category}=${USE_${_category}}" ) + set( DO_SKIP 1 ) + endif() + endif() + endif() + if( NOT DO_SKIP EQUAL -1 ) message( "${ColorReset}-- Skipping module ${BoldRed}${SUBDIRECTORY}${ColorReset}." ) message( "" ) - list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (user request)" ) + list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (${_skip_reason})" ) elseif( ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" ) AND ( DO_SKIP EQUAL -1 ) ) set( SKIPPED_MODULES )