From f218e2e9a617f176d4ed69904a81ab97c9597122 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Jun 2020 12:05:35 +0200 Subject: [PATCH] CMake: handle Python modules built from subdirectory a/b --- CMakeModules/CalamaresAddModuleSubdirectory.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeModules/CalamaresAddModuleSubdirectory.cmake b/CMakeModules/CalamaresAddModuleSubdirectory.cmake index 02c1a577f..86f0b8f4c 100644 --- a/CMakeModules/CalamaresAddModuleSubdirectory.cmake +++ b/CMakeModules/CalamaresAddModuleSubdirectory.cmake @@ -61,7 +61,17 @@ function( calamares_add_module_subdirectory ) # ...otherwise, we look for a module.desc. elseif( EXISTS "${_mod_dir}/module.desc" ) set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules ) - set( MODULE_DESTINATION ${MODULES_DIR}/${SUBDIRECTORY} ) + # The module subdirectory may be given as a/b/c, but the module + # needs to be installed as "c", so we split off any intermediate + # directories. + get_filename_component(_dirname "${SUBDIRECTORY}" DIRECTORY) + if( _dirname ) + # Remove the dirname and any leftover leading /s + string( REGEX REPLACE "^${_dirname}/*" "" _modulename "${SUBDIRECTORY}" ) + set( MODULE_DESTINATION ${MODULES_DIR}/${_modulename} ) + else() + set( MODULE_DESTINATION ${MODULES_DIR}/${SUBDIRECTORY} ) + endif() # Read module.desc, check that the interface type is supported. #