2014-07-14 16:26:10 +02:00
include ( CMakeColors )
2015-09-09 18:55:08 +02:00
set ( MODULE_DATA_DESTINATION share/calamares/modules )
2014-07-14 16:26:10 +02:00
function ( calamares_add_module_subdirectory )
set ( SUBDIRECTORY ${ ARGV0 } )
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory ( ${ SUBDIRECTORY } )
2014-08-06 16:01:39 +02:00
# ...otherwise, we look for a module.desc.
2014-08-05 18:18:57 +02:00
elseif ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" )
2014-07-14 16:26:10 +02:00
set ( MODULES_DIR ${ CMAKE_INSTALL_LIBDIR } /calamares/modules )
set ( MODULE_DESTINATION ${ MODULES_DIR } / ${ SUBDIRECTORY } )
# We glob all the files inside the subdirectory, and we make sure they are
# synced with the bindir structure and installed.
file ( GLOB MODULE_FILES RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } / ${ SUBDIRECTORY } "${SUBDIRECTORY}/*" )
foreach ( MODULE_FILE ${ MODULE_FILES } )
2014-07-24 10:14:42 +02:00
if ( NOT IS_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } / ${ SUBDIRECTORY } / ${ MODULE_FILE } )
2014-07-14 16:26:10 +02:00
configure_file ( ${ SUBDIRECTORY } / ${ MODULE_FILE } ${ SUBDIRECTORY } / ${ MODULE_FILE } COPYONLY )
2014-08-05 18:18:57 +02:00
2015-09-09 18:55:08 +02:00
get_filename_component ( FLEXT ${ MODULE_FILE } EXT )
2016-11-21 01:32:04 +01:00
if ( "${FLEXT}" STREQUAL ".conf" AND INSTALL_CONFIG )
2014-08-05 18:18:57 +02:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ SUBDIRECTORY } / ${ MODULE_FILE }
2015-09-09 18:55:08 +02:00
D E S T I N A T I O N $ { M O D U L E _ D A T A _ D E S T I N A T I O N } )
list ( APPEND MODULE_CONFIG_FILES ${ MODULE_FILE } )
2014-08-05 18:18:57 +02:00
else ( )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ SUBDIRECTORY } / ${ MODULE_FILE }
D E S T I N A T I O N $ { M O D U L E _ D E S T I N A T I O N } )
endif ( )
2014-07-14 16:26:10 +02:00
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}" )
2015-09-09 18:55:08 +02:00
if ( MODULE_CONFIG_FILES )
2016-11-21 01:32:04 +01:00
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 ( )
2015-09-09 18:55:08 +02:00
endif ( )
2014-07-14 16:26:10 +02:00
message ( "" )
endif ( )
else ( )
2014-08-06 16:01:39 +02:00
message ( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )
2014-07-14 16:26:10 +02:00
message ( "" )
endif ( )
endfunction ( )