CMake: add support for NO_CONFIG

- A C++ module should set NO_CONFIG to flag that it doesn't have a
   config file (this is an error if it secretly **does** have one)
This commit is contained in:
Adriaan de Groot 2020-01-20 19:27:34 +01:00
parent fed0c46612
commit fbb452f9bf
2 changed files with 13 additions and 1 deletions

View File

@ -38,6 +38,7 @@
# [RESOURCES resource-file]
# [REQUIRES module-name...]
# [NO_INSTALL]
# [NO_CONFIG]
# [SHARED_LIB]
# [EMERGENCY]
# )
@ -71,7 +72,7 @@ include( CMakeColors )
function( calamares_add_plugin )
# parse arguments ( name needs to be saved before passing ARGN into the macro )
set( NAME ${ARGV0} )
set( options NO_INSTALL SHARED_LIB EMERGENCY )
set( options NO_CONFIG NO_INSTALL SHARED_LIB EMERGENCY )
set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES )
set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS REQUIRES )
cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
@ -90,6 +91,9 @@ function( calamares_add_plugin )
message( " ${Green}LINK_PRIVATE_LIBRARIES:${ColorReset} ${PLUGIN_LINK_PRIVATE_LIBRARIES}" )
message( " ${Green}PLUGIN_DESTINATION:${ColorReset} ${PLUGIN_DESTINATION}" )
if( PLUGIN_CONFIG_FILES )
if( PLUGIN_NO_CONFIG )
message( FATAL_ERROR "${Red}NO_CONFIG${ColorReset} is set, with configuration ${Red}${PLUGIN_CONFIG_FILES}${ColorReset}" )
endif()
set( _destination "(unknown)" )
if ( INSTALL_CONFIG AND NOT PLUGIN_NO_INSTALL )
set( _destination "${PLUGIN_DATA_DESTINATION}" )
@ -100,6 +104,10 @@ function( calamares_add_plugin )
set( _destination "[Skipping installation]" )
endif()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => ${_destination}" )
else()
if( NOT PLUGIN_NO_CONFIG )
message( " ${Red}NO_CONFIG${ColorReset} should be set." )
endif()
endif()
if( PLUGIN_RESOURCES )
message( " ${Green}RESOURCES:${ColorReset} ${PLUGIN_RESOURCES}" )
@ -170,6 +178,9 @@ function( calamares_add_plugin )
if ( PLUGIN_EMERGENCY )
file( APPEND ${_file} "emergency: true\n" )
endif()
if ( NO_CONFIG )
file( APPEND ${_file} "noconfig: true\n" )
endif()
endif()
if ( NOT PLUGIN_NO_INSTALL )

View File

@ -9,4 +9,5 @@ calamares_add_plugin( summary
LINK_PRIVATE_LIBRARIES
calamaresui
SHARED_LIB
NO_CONFIG
)