CMake: don't copy over modules with unsupported interfaces.

If Python isn't found, or PythonQt isn't found, there is no point
in copying over the modules into the build tree; this may even be
misleading because the files are there, but won't work and this
will be noticed at runtime only.

Instead, skip the modules and explain why.
This commit is contained in:
Adriaan de Groot 2018-01-15 22:41:06 +01:00
parent 66c03b4055
commit 4630008fa1

View File

@ -24,61 +24,79 @@ function( calamares_add_module_subdirectory )
set( SKIPPED_MODULES ) set( SKIPPED_MODULES )
set( MODULE_CONFIG_FILES "" ) set( MODULE_CONFIG_FILES "" )
set( _mod_dir "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" )
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it... # If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" ) if( EXISTS "${_mod_dir}/CMakeLists.txt" )
add_subdirectory( ${SUBDIRECTORY} ) add_subdirectory( ${SUBDIRECTORY} )
file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" ) file( GLOB MODULE_CONFIG_FILES RELATIVE ${_mod_dir} "${SUBDIRECTORY}/*.conf" )
# Module has indicated it should be skipped, show that in # Module has indicated it should be skipped, show that in
# the calling CMakeLists (which is src/modules/CMakeLists.txt normally). # the calling CMakeLists (which is src/modules/CMakeLists.txt normally).
if ( SKIPPED_MODULES ) if ( SKIPPED_MODULES )
set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE ) set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE )
endif() endif()
# ...otherwise, we look for a module.desc. # ...otherwise, we look for a module.desc.
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" ) elseif( EXISTS "${_mod_dir}/module.desc" )
set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules ) set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules )
set( MODULE_DESTINATION ${MODULES_DIR}/${SUBDIRECTORY} ) set( MODULE_DESTINATION ${MODULES_DIR}/${SUBDIRECTORY} )
# We glob all the files inside the subdirectory, and we make sure they are # Read module.desc, check that the interface type is supported.
# synced with the bindir structure and installed. file(STRINGS "${_mod_dir}/module.desc" MODULE_INTERFACE REGEX "^interface")
file( GLOB MODULE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*" ) if ( MODULE_INTERFACE MATCHES "pythonqt" )
foreach( MODULE_FILE ${MODULE_FILES} ) set( _mod_enabled ${WITH_PYTHONQT} )
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/${MODULE_FILE} ) set( _mod_reason "No PythonQt support" )
configure_file( ${SUBDIRECTORY}/${MODULE_FILE} ${SUBDIRECTORY}/${MODULE_FILE} COPYONLY ) elseif ( MODULE_INTERFACE MATCHES "python" )
set( _mod_enabled ${WITH_PYTHON} )
get_filename_component( FLEXT ${MODULE_FILE} EXT ) set( _mod_reason "No Python support" )
if( "${FLEXT}" STREQUAL ".conf" AND INSTALL_CONFIG) else()
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE} set( _mod_enabled ON )
DESTINATION ${MODULE_DATA_DESTINATION} ) set( _mod_reason "" )
list( APPEND MODULE_CONFIG_FILES ${MODULE_FILE} )
else()
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE}
DESTINATION ${MODULE_DESTINATION} )
endif()
endif()
endforeach()
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message( " ${Green}TYPE:${ColorReset} jobmodule" )
# message( " ${Green}FILES:${ColorReset} ${MODULE_FILES}" )
message( " ${Green}MODULE_DESTINATION:${ColorReset} ${MODULE_DESTINATION}" )
if( MODULE_CONFIG_FILES )
if ( INSTALL_CONFIG )
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${MODULE_DATA_DESTINATION}" )
else()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => [Skipping installation]" )
endif()
endif()
message( "" )
endif() endif()
# We copy over the lang directory, if any
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" ) if ( _mod_enabled )
install_calamares_gettext_translations( # We glob all the files inside the subdirectory, and we make sure they are
${SUBDIRECTORY} # synced with the bindir structure and installed.
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" file( GLOB MODULE_FILES RELATIVE ${_mod_dir} "${SUBDIRECTORY}/*" )
FILENAME ${SUBDIRECTORY}.mo foreach( MODULE_FILE ${MODULE_FILES} )
RENAME calamares-${SUBDIRECTORY}.mo if( NOT IS_DIRECTORY ${_mod_dir}/${MODULE_FILE} )
) configure_file( ${SUBDIRECTORY}/${MODULE_FILE} ${SUBDIRECTORY}/${MODULE_FILE} COPYONLY )
get_filename_component( FLEXT ${MODULE_FILE} EXT )
if( "${FLEXT}" STREQUAL ".conf" AND INSTALL_CONFIG)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE}
DESTINATION ${MODULE_DATA_DESTINATION} )
list( APPEND MODULE_CONFIG_FILES ${MODULE_FILE} )
else()
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE}
DESTINATION ${MODULE_DESTINATION} )
endif()
endif()
endforeach()
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message( " ${Green}TYPE:${ColorReset} jobmodule" )
message( " ${Green}MODULE_DESTINATION:${ColorReset} ${MODULE_DESTINATION}" )
if( MODULE_CONFIG_FILES )
if ( INSTALL_CONFIG )
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${MODULE_DATA_DESTINATION}" )
else()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => [Skipping installation]" )
endif()
endif()
message( "" )
endif()
# We copy over the lang directory, if any
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
install_calamares_gettext_translations(
${SUBDIRECTORY}
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang"
FILENAME ${SUBDIRECTORY}.mo
RENAME calamares-${SUBDIRECTORY}.mo
)
endif()
else()
# Module disabled due to missing dependencies / unsupported interface
set( SKIPPED_MODULES "${SUBDIRECTORY} (${_mod_reason})" PARENT_SCOPE )
endif() endif()
else() else()
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." ) message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )