Add CalamaresAddModuleSubdirectory, a CMake function for modules that
do not require building through a CMakeLists.txt.
This commit is contained in:
parent
25f44492e9
commit
c57d99a21c
@ -74,8 +74,9 @@ configure_file(
|
||||
|
||||
# Early configure these files as we need them later on
|
||||
configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY )
|
||||
file( COPY CalamaresAddPlugin.cmake DESTINATION "${PROJECT_BINARY_DIR}" )
|
||||
file( COPY CalamaresAddLibrary.cmake DESTINATION "${PROJECT_BINARY_DIR}" )
|
||||
file( COPY CalamaresAddModuleSubdirectory.cmake DESTINATION "${PROJECT_BINARY_DIR}" )
|
||||
file( COPY CalamaresAddPlugin.cmake DESTINATION "${PROJECT_BINARY_DIR}" )
|
||||
|
||||
set( CALAMARES_LIBRARIES calamareslib )
|
||||
|
||||
|
36
CalamaresAddModuleSubdirectory.cmake
Normal file
36
CalamaresAddModuleSubdirectory.cmake
Normal file
@ -0,0 +1,36 @@
|
||||
include( CMakeColors )
|
||||
|
||||
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} )
|
||||
# ...otherwise, we look for a module.conf.
|
||||
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.conf" )
|
||||
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} )
|
||||
if( NOT IS_DIRECTORY( ${MODULE_FILE} ) )
|
||||
configure_file( ${SUBDIRECTORY}/${MODULE_FILE} ${SUBDIRECTORY}/${MODULE_FILE} COPYONLY )
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE}
|
||||
DESTINATION ${MODULE_DESTINATION} )
|
||||
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}" )
|
||||
message( "" )
|
||||
endif()
|
||||
else()
|
||||
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.conf." )
|
||||
message( "" )
|
||||
endif()
|
||||
endfunction()
|
@ -7,4 +7,5 @@ if(NOT CALAMARES_CMAKE_DIR)
|
||||
endif()
|
||||
|
||||
include( "${CALAMARES_CMAKE_DIR}/CalamaresAddLibrary.cmake" )
|
||||
include( "${CALAMARES_CMAKE_DIR}/CalamaresAddModuleSubdirectory.cmake" )
|
||||
include( "${CALAMARES_CMAKE_DIR}/CalamaresAddPlugin.cmake" )
|
||||
|
@ -1,6 +1,6 @@
|
||||
file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" )
|
||||
foreach( SUBDIRECTORY ${SUBDIRECTORIES} )
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt")
|
||||
add_subdirectory(${SUBDIRECTORY})
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" )
|
||||
calamares_add_module_subdirectory( ${SUBDIRECTORY} )
|
||||
endif()
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user