first
This commit is contained in:
86
calamares/CMakeModules/AppStreamHelper.cmake
Normal file
86
calamares/CMakeModules/AppStreamHelper.cmake
Normal file
@@ -0,0 +1,86 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2023 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Finds AppStream-Qt suitable for the Qt version that is in use.
|
||||
# Creates target calamares::appstreamqt to alias whatever is found.
|
||||
# Sets AppStreamQt_FOUND appropriately, regardless of the underlying
|
||||
# variables (e.g. might be AppStreamQt6_FOUND).
|
||||
#
|
||||
|
||||
option(BUILD_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" OFF)
|
||||
|
||||
if(TARGET calaappstream)
|
||||
if(TARGET calamares::appstreamqt)
|
||||
message(STATUS "AppStreamQt has already been found")
|
||||
set(AppStreamQt_FOUND TRUE)
|
||||
else()
|
||||
message(STATUS "AppStreamQt has been searched-for and not found")
|
||||
set(AppStreamQt_FOUND FALSE)
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
if(NOT BUILD_APPSTREAM)
|
||||
return()
|
||||
endif()
|
||||
|
||||
### FIND APPSTREAM
|
||||
#
|
||||
# First, look for a Qt-versioned variety of the package.
|
||||
# If that is not found, look for an unversioned one.
|
||||
set(HAVE_APPSTREAM OFF)
|
||||
find_package(AppStream${qtname})
|
||||
# Not everyone renames the variables consistently
|
||||
if(AppStream${qtname}_FOUND OR AppStreamQt_FOUND)
|
||||
set(_appstream_name AppStream${qtname})
|
||||
set(HAVE_APPSTREAM ON)
|
||||
else()
|
||||
find_package(AppStreamQt)
|
||||
if(AppStreamQt_FOUND)
|
||||
set(_appstream_name AppStreamQt)
|
||||
# TODO: how to check underlying Qt version?
|
||||
set(HAVE_APPSTREAM ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_APPSTREAM)
|
||||
# Look for the directory name containing the headers
|
||||
find_file(_appstream_header NAMES ${_appstream_name}/pool.h AppStreamQt/pool.h)
|
||||
if(NOT _appstream_header)
|
||||
set(HAVE_APPSTREAM OFF)
|
||||
else()
|
||||
if(_appstream_header MATCHES /${_appstream_name}/)
|
||||
set(_appstream_header_directory ${_appstream_name})
|
||||
else()
|
||||
set(_appstream_header_directory AppStreamQt)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# Placeholder name
|
||||
set(_appstream_name AppStreamQt)
|
||||
endif()
|
||||
|
||||
set(_appstream_dependency_type OPTIONAL)
|
||||
if(BUILD_APPSTREAM)
|
||||
set(_appstream_dependency_type REQUIRED)
|
||||
endif()
|
||||
|
||||
set_package_properties(
|
||||
${_appstream_name}
|
||||
PROPERTIES
|
||||
DESCRIPTION "Support for AppStream (cache) data"
|
||||
URL "https://github.com/ximion/appstream"
|
||||
PURPOSE "AppStream provides package data"
|
||||
TYPE ${_appstream_dependency_type}
|
||||
)
|
||||
|
||||
add_library(calaappstream INTERFACE) # Always, but might not be populated
|
||||
if(HAVE_APPSTREAM)
|
||||
target_compile_definitions(calaappstream INTERFACE HAVE_APPSTREAM_VERSION=${${_appstream_name}_VERSION_MAJOR} HAVE_APPSTREAM_HEADERS=${_appstream_header_directory})
|
||||
target_link_libraries(calaappstream INTERFACE ${_appstream_name})
|
||||
add_library(calamares::appstreamqt ALIAS calaappstream)
|
||||
endif()
|
||||
set(AppStreamQt_FOUND ${HAVE_APPSTREAM})
|
||||
43
calamares/CMakeModules/CMakeColors.cmake
Normal file
43
calamares/CMakeModules/CMakeColors.cmake
Normal file
@@ -0,0 +1,43 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2014 Kevin Kofler <kevin.kofler@chello.at>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Defines a handful of strings that, with normal xterm handling,
|
||||
# will change colors in the output, so it's nicer to read.
|
||||
if(NOT WIN32)
|
||||
set(_use_color ON)
|
||||
if("0" STREQUAL "$ENV{CLICOLOR}")
|
||||
set(_use_color OFF)
|
||||
endif()
|
||||
if("0" STREQUAL "$ENV{CLICOLOR_FORCE}")
|
||||
set(_use_color OFF)
|
||||
endif()
|
||||
if(NOT CMAKE_COLOR_MAKEFILE)
|
||||
set(_use_color OFF)
|
||||
endif()
|
||||
|
||||
if(_use_color)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(ColorBold "${Esc}[1m")
|
||||
set(Red "${Esc}[31m")
|
||||
set(Green "${Esc}[32m")
|
||||
set(Yellow "${Esc}[33m")
|
||||
set(Blue "${Esc}[34m")
|
||||
set(Magenta "${Esc}[35m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(White "${Esc}[37m")
|
||||
set(BoldRed "${Esc}[1;31m")
|
||||
set(BoldGreen "${Esc}[1;32m")
|
||||
set(BoldYellow "${Esc}[1;33m")
|
||||
set(BoldBlue "${Esc}[1;34m")
|
||||
set(BoldMagenta "${Esc}[1;35m")
|
||||
set(BoldCyan "${Esc}[1;36m")
|
||||
set(BoldWhite "${Esc}[1;37m")
|
||||
endif()
|
||||
endif()
|
||||
147
calamares/CMakeModules/CalamaresAddBrandingSubdirectory.cmake
Normal file
147
calamares/CMakeModules/CalamaresAddBrandingSubdirectory.cmake
Normal file
@@ -0,0 +1,147 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Support macros for creating Calamares branding components.
|
||||
#
|
||||
# Calamares branding components have two parts:
|
||||
# - a branding.desc file that tells Calamares how to describe the product
|
||||
# (e.g. strings like "Generic GNU/Linux") and the name of a QML file
|
||||
# (the "slideshow") that is displayed during installation.
|
||||
# - the QML files themselves, plus supporting images etc.
|
||||
#
|
||||
# Branding components can be created inside the Calamares source tree
|
||||
# (there is one example the `default/` branding, which is also connected
|
||||
# to the default configuration shipped with Calamares), but they can be
|
||||
# built outside of, and largely independently of, Calamares by using
|
||||
# these CMake macros.
|
||||
#
|
||||
# See the calamares-examples repository for more examples.
|
||||
#
|
||||
include( CMakeParseArguments)
|
||||
|
||||
include( CMakeColors )
|
||||
|
||||
# Usage calamares_add_branding( <name> [DIRECTORY <dir>] [SUBDIRECTORIES <dir> ...])
|
||||
#
|
||||
# Adds a branding component to the build:
|
||||
# - the component's top-level files are copied into the build-dir;
|
||||
# CMakeLists.txt is excluded from the glob.
|
||||
# - the component's top-level files are installed into the component branding dir
|
||||
#
|
||||
# The branding component lives in <dir> if given, otherwise the
|
||||
# current source directory. The branding component is installed
|
||||
# with the given <name>, which is usually the name of the
|
||||
# directory containing the component, and which must match the
|
||||
# *componentName* in `branding.desc`.
|
||||
#
|
||||
# If SUBDIRECTORIES are given, then those are copied (each one level deep)
|
||||
# to the installation location as well, preserving the subdirectory name.
|
||||
function( calamares_add_branding NAME )
|
||||
cmake_parse_arguments( _CABT "" "DIRECTORY" "SUBDIRECTORIES" ${ARGN} )
|
||||
if (NOT _CABT_DIRECTORY)
|
||||
set(_CABT_DIRECTORY ".")
|
||||
endif()
|
||||
|
||||
set( SUBDIRECTORY ${_CABT_DIRECTORY} )
|
||||
set( _brand_dir ${_CABT_DIRECTORY} )
|
||||
|
||||
set( BRANDING_DIR share/calamares/branding )
|
||||
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )
|
||||
|
||||
foreach( _subdir "" ${_CABT_SUBDIRECTORIES} )
|
||||
file( GLOB BRANDING_COMPONENT_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_brand_dir} "${_brand_dir}/${_subdir}/*" )
|
||||
foreach( BRANDING_COMPONENT_FILE ${BRANDING_COMPONENT_FILES} )
|
||||
set( _subpath ${_brand_dir}/${BRANDING_COMPONENT_FILE} )
|
||||
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_subpath} )
|
||||
set( _src ${CMAKE_CURRENT_SOURCE_DIR}/${_subpath} )
|
||||
set( _dst ${CMAKE_CURRENT_BINARY_DIR}/${_subpath} )
|
||||
if( ${_src} IS_NEWER_THAN ${_dst} )
|
||||
configure_file( ${_src} ${_dst} COPYONLY )
|
||||
endif()
|
||||
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_subpath}
|
||||
DESTINATION ${BRANDING_COMPONENT_DESTINATION}/${_subdir}/ )
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${NAME}${ColorReset}" )
|
||||
message( " ${Green}TYPE:${ColorReset} branding component" )
|
||||
message( " ${Green}BRANDING_COMPONENT_DESTINATION:${ColorReset} ${BRANDING_COMPONENT_DESTINATION}" )
|
||||
endfunction()
|
||||
|
||||
# Usage calamares_add_branding_translations( <name> [DIRECTORY <dir>])
|
||||
#
|
||||
# Adds the translations for a branding component to the build:
|
||||
# - the component's lang/ directory is scanned for .ts files
|
||||
# - the component's translations are installed into the component branding dir
|
||||
#
|
||||
# Translation files must be called calamares-<name>_<lang>.ts . Optionally
|
||||
# the lang/ dir is found in the given <dir> instead of the current source
|
||||
# directory.
|
||||
function( calamares_add_branding_translations NAME )
|
||||
cmake_parse_arguments( _CABT "" "DIRECTORY" "" ${ARGN} )
|
||||
if (NOT _CABT_DIRECTORY)
|
||||
set(_CABT_DIRECTORY ".")
|
||||
endif()
|
||||
|
||||
set( SUBDIRECTORY ${_CABT_DIRECTORY} )
|
||||
set( _brand_dir ${_CABT_DIRECTORY} )
|
||||
|
||||
set( BRANDING_DIR share/calamares/branding )
|
||||
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )
|
||||
|
||||
file( GLOB BRANDING_TRANSLATION_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${SUBDIRECTORY}/lang/calamares-${NAME}_*.ts" )
|
||||
if ( BRANDING_TRANSLATION_FILES )
|
||||
qt_add_translation( QM_FILES ${BRANDING_TRANSLATION_FILES} )
|
||||
add_custom_target( branding-translation-${NAME} ALL DEPENDS ${QM_FILES}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/lang/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${QM_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/lang/
|
||||
)
|
||||
install( FILES ${QM_FILES} DESTINATION ${BRANDING_COMPONENT_DESTINATION}/lang/ )
|
||||
list( LENGTH BRANDING_TRANSLATION_FILES _branding_count )
|
||||
message( " ${Green}BRANDING_TRANSLATIONS:${ColorReset} ${_branding_count} language(s)" )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Usage calamares_add_branding_subdirectory( <dir> [NAME <name>] [SUBDIRECTORIES <dir> ...])
|
||||
#
|
||||
# Adds a branding component from a subdirectory:
|
||||
# - if there is a CMakeLists.txt, use that (that CMakeLists.txt should
|
||||
# call suitable calamares_add_branding() and other macros to install
|
||||
# the branding component).
|
||||
# - otherwise assume a "standard" setup with top-level files and a lang/
|
||||
# subdirectory for translations.
|
||||
#
|
||||
# If NAME is given, this is used instead of <dir> as the name of
|
||||
# the branding component. This is needed if <dir> is more than
|
||||
# one level deep, or to rename a component as it gets installed.
|
||||
#
|
||||
# If SUBDIRECTORIES are given, they are relative to <dir>, and are
|
||||
# copied (one level deep) to the install location as well.
|
||||
function( calamares_add_branding_subdirectory SUBDIRECTORY )
|
||||
cmake_parse_arguments( _CABS "" "NAME" "SUBDIRECTORIES" ${ARGN} )
|
||||
if (NOT _CABS_NAME)
|
||||
set(_CABS_NAME "${SUBDIRECTORY}")
|
||||
endif()
|
||||
|
||||
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
|
||||
add_subdirectory( ${SUBDIRECTORY} )
|
||||
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
|
||||
calamares_add_branding( ${_CABS_NAME} DIRECTORY ${SUBDIRECTORY} SUBDIRECTORIES ${_CABS_SUBDIRECTORIES} )
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
|
||||
calamares_add_branding_translations( ${_CABS_NAME} DIRECTORY ${SUBDIRECTORY} )
|
||||
endif()
|
||||
else()
|
||||
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add branding component subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no branding.desc." )
|
||||
endif()
|
||||
message( "" )
|
||||
endfunction()
|
||||
139
calamares/CMakeModules/CalamaresAddLibrary.cmake
Normal file
139
calamares/CMakeModules/CalamaresAddLibrary.cmake
Normal file
@@ -0,0 +1,139 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Support functions for building plugins.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# calamares_add_library(
|
||||
# library-name
|
||||
# EXPORT_MACRO macro-name
|
||||
# TARGET_TYPE <STATIC|MODULE|...>
|
||||
# EXPORT export-name
|
||||
# VERSION version
|
||||
# SOVERSION version
|
||||
# INSTALL_BINDIR dir
|
||||
# RESOURCES resource-file
|
||||
# SOURCES source-file...
|
||||
# UI ui-file...
|
||||
# LINK_LIBRARIES lib...
|
||||
# LINK_PRIVATE_LIBRARIES lib...
|
||||
# COMPILE_DEFINITIONS def...
|
||||
# [NO_INSTALL]
|
||||
# [NO_VERSION]
|
||||
# )
|
||||
#
|
||||
# The COMPILE_DEFINITIONS are set on the resulting module with a suitable
|
||||
# flag (i.e. `-D`) so only state the name (optionally, also the value)
|
||||
# without a `-D` prefixed to it. Pass in a CMake list as needed.
|
||||
include( CMakeParseArguments )
|
||||
include( CalamaresAutomoc )
|
||||
|
||||
function(calamares_add_library)
|
||||
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||
set(NAME ${ARGV0})
|
||||
set(options NO_INSTALL NO_VERSION)
|
||||
set(oneValueArgs NAME EXPORT_MACRO TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES)
|
||||
set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS)
|
||||
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(LIBRARY_NAME ${NAME})
|
||||
|
||||
set(target ${LIBRARY_NAME})
|
||||
|
||||
# qt stuff
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# add resources from current dir
|
||||
if(LIBRARY_RESOURCES)
|
||||
list(APPEND LIBRARY_SOURCES ${LIBRARY_RESOURCES})
|
||||
endif()
|
||||
|
||||
# add target
|
||||
if(LIBRARY_TARGET_TYPE STREQUAL "STATIC")
|
||||
add_library(${target} STATIC ${LIBRARY_SOURCES})
|
||||
elseif(LIBRARY_TARGET_TYPE STREQUAL "MODULE")
|
||||
add_library(${target} MODULE ${LIBRARY_SOURCES})
|
||||
elseif(LIBRARY_TARGET_TYPE STREQUAL "SHARED")
|
||||
add_library(${target} SHARED ${LIBRARY_SOURCES})
|
||||
else() # default
|
||||
message(FATAL_ERROR "Invalid library type '${LIBRARY_TARGET_TYPE}'")
|
||||
endif()
|
||||
|
||||
calamares_automoc(${target})
|
||||
if(LIBRARY_UI)
|
||||
calamares_autouic(${target} ${LIBRARY_UI})
|
||||
endif()
|
||||
if(LIBRARY_RESOURCES)
|
||||
calamares_autorcc(${target} ${LIBRARY_RESOURCES})
|
||||
endif()
|
||||
|
||||
if(LIBRARY_EXPORT_MACRO)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO})
|
||||
endif()
|
||||
|
||||
if(LIBRARY_COMPILE_DEFINITIONS)
|
||||
set( _lib_definitions "${LIBRARY_EXPORT_MACRO}" ${LIBRARY_COMPILE_DEFINITIONS} )
|
||||
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS "${_lib_definitions}")
|
||||
endif()
|
||||
|
||||
# add link targets
|
||||
target_link_libraries(${target}
|
||||
LINK_PUBLIC ${Calamares_LIBRARIES}
|
||||
${qtname}::Core
|
||||
${qtname}::Gui
|
||||
${qtname}::Widgets
|
||||
)
|
||||
if(LIBRARY_LINK_LIBRARIES)
|
||||
target_link_libraries(${target} LINK_PUBLIC ${LIBRARY_LINK_LIBRARIES})
|
||||
endif()
|
||||
if(LIBRARY_LINK_PRIVATE_LIBRARIES)
|
||||
target_link_libraries(${target} LINK_PRIVATE ${LIBRARY_LINK_PRIVATE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# add soversion
|
||||
if(NOT LIBRARY_NO_VERSION)
|
||||
set_target_properties(${target} PROPERTIES VERSION ${LIBRARY_VERSION})
|
||||
|
||||
if(NOT LIBRARY_SOVERSION)
|
||||
set(LIBRARY_SOVERSION ${LIBRARY_VERSION})
|
||||
endif()
|
||||
|
||||
set_target_properties(${target} PROPERTIES SOVERSION ${LIBRARY_SOVERSION})
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT LIBRARY_INSTALL_BINDIR)
|
||||
set(LIBRARY_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(LIBRARY_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}")
|
||||
endif()
|
||||
|
||||
# make installation optional, maybe useful for dummy plugins one day
|
||||
if(NOT LIBRARY_NO_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
if(NOT LIBRARY_EXPORT)
|
||||
install( TARGETS ${target}
|
||||
RUNTIME DESTINATION ${LIBRARY_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${LIBRARY_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${LIBRARY_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install( TARGETS ${target}
|
||||
EXPORT ${LIBRARY_EXPORT}
|
||||
RUNTIME DESTINATION ${LIBRARY_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${LIBRARY_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${LIBRARY_INSTALL_LIBDIR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
287
calamares/CMakeModules/CalamaresAddModuleSubdirectory.cmake
Normal file
287
calamares/CMakeModules/CalamaresAddModuleSubdirectory.cmake
Normal file
@@ -0,0 +1,287 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Function and support code for adding a Calamares module (either a Qt / C++ plugin,
|
||||
# or a Python module, or whatever) to the build.
|
||||
#
|
||||
# # Usage
|
||||
#
|
||||
# The public API is one single function:
|
||||
#
|
||||
# - calamares_add_module_subdirectory(subdirectory [skiplistvar])
|
||||
# Adds a given *subdirectory* to the modules list, building the
|
||||
# module that is there. The *subdirectory* must contain a `module.desc`
|
||||
# (generally non-C++ modules) or a `CMakeLists.txt` (for C++ modules,
|
||||
# or special cases). The module is assumed to be named after the
|
||||
# (last component of) the subdirectory.
|
||||
#
|
||||
# If the module would be skipped (by the global SKIP_MODULES setting
|
||||
# or a USE_* setting) or the module itself sets a reason to skip
|
||||
# via the calamares_skip_module() function, the module is added to
|
||||
# the list of skipped-modules in *skiplistvar*. If no variable is
|
||||
# given, the reason is set in the parent scope variable
|
||||
# SKIPPED_MODULES . Do **not** use SKIPPED_MODULES as the name of
|
||||
# *skiplistvar*, things will get weird.
|
||||
#
|
||||
# Do note that the name of a module must be the same as the name of
|
||||
# the directory containing it (as documented in src/modules/README.md).
|
||||
# This applies to both C++ and Python modules, and allows the use of
|
||||
# the subdirectory as a proxy for the module name inside.
|
||||
#
|
||||
|
||||
include( CalamaresAddTranslations )
|
||||
include( CalamaresCheckModuleSelection )
|
||||
|
||||
set( MODULE_DATA_DESTINATION share/calamares/modules )
|
||||
|
||||
# We look for Pylint (just once) so that unittests can be added that
|
||||
# check the syntax / variables of Python modules. This should help
|
||||
# avoid more typo's-in-releases.
|
||||
if(BUILD_TESTING AND NOT PYLINT_COMMAND_SEARCHED)
|
||||
set(PYLINT_COMMAND_SEARCHED TRUE)
|
||||
find_program(
|
||||
PYLINT_COMMAND
|
||||
NAMES pylint3 pylint
|
||||
PATHS $ENV{HOME}/.local/bin
|
||||
)
|
||||
endif()
|
||||
|
||||
function( _calamares_add_module_subdirectory_impl )
|
||||
set( SUBDIRECTORY ${ARGV0} )
|
||||
|
||||
# Set SKIPPED_MODULES here, so CMake-based modules have a
|
||||
# parent scope to set it in; this function, in turn sets it
|
||||
# in **its** parent scope.
|
||||
set( SKIPPED_MODULES "" )
|
||||
set( MODULE_CONFIG_FILES "" )
|
||||
|
||||
# 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.
|
||||
#
|
||||
# Compute _modulename (the last directory name) and _mod_dir
|
||||
# (the full path to the module sources).
|
||||
get_filename_component(_dirname "${SUBDIRECTORY}" DIRECTORY)
|
||||
if( _dirname )
|
||||
# Remove the dirname and any leftover leading /s
|
||||
string( REGEX REPLACE "^${_dirname}/*" "" _modulename "${SUBDIRECTORY}" )
|
||||
else()
|
||||
set( _modulename ${SUBDIRECTORY} )
|
||||
endif()
|
||||
# Strip any remaining /
|
||||
string( REGEX REPLACE "/" "" _modulename "${_modulename}" )
|
||||
set( _mod_dir "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" )
|
||||
|
||||
# Skip list check applies to all kinds of modules
|
||||
calamares_check_skip( ${_modulename} SKIPPED_MODULES )
|
||||
if ( SKIPPED_MODULES )
|
||||
# If it's skipped by infrastucture, the message already includes the module
|
||||
# name. We don't need to do any further checking.
|
||||
set( SKIPPED_MODULES "${SKIPPED_MODULES}" PARENT_SCOPE )
|
||||
return()
|
||||
endif()
|
||||
|
||||
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
|
||||
if( EXISTS "${_mod_dir}/CMakeLists.txt" )
|
||||
add_subdirectory( ${SUBDIRECTORY} )
|
||||
file( GLOB MODULE_CONFIG_FILES RELATIVE ${_mod_dir} "${SUBDIRECTORY}/*.conf" )
|
||||
# Module has indicated it should be skipped, show that in
|
||||
# the calling CMakeLists (which is src/modules/CMakeLists.txt normally).
|
||||
if ( SKIPPED_MODULES )
|
||||
set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE )
|
||||
set( MODULE_CONFIG_FILES "" )
|
||||
else()
|
||||
# The SKIPPED_MODULES may be set in the directory itself
|
||||
get_directory_property( _skip DIRECTORY ${SUBDIRECTORY} DEFINITION SKIPPED_MODULES )
|
||||
if ( _skip )
|
||||
set( SKIPPED_MODULES ${_skip} PARENT_SCOPE )
|
||||
set( MODULE_CONFIG_FILES "" )
|
||||
endif()
|
||||
endif()
|
||||
if ( SKIPPED_MODULES )
|
||||
return()
|
||||
endif()
|
||||
# ...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}/${_modulename} )
|
||||
|
||||
# Read module.desc, check that the interface type is supported.
|
||||
#
|
||||
# _mod_enabled boolean if the module should be built (only if the interface is supported)
|
||||
# _mod_reason is a human-readable explanation why it isn't built
|
||||
# _mod_testing boolean if the module should be added to the loadmodule tests
|
||||
file(STRINGS "${_mod_dir}/module.desc" MODULE_INTERFACE REGEX "^interface")
|
||||
if ( MODULE_INTERFACE MATCHES "pythonqt" )
|
||||
message( FATAL_ERROR "PythonQt is no longer supported" )
|
||||
set( _mod_enabled OFF )
|
||||
set( _mod_reason "No PythonQt support" )
|
||||
set( _mod_testing OFF )
|
||||
elseif ( MODULE_INTERFACE MATCHES "python" )
|
||||
set( _mod_enabled ${Calamares_WITH_PYTHON} )
|
||||
set( _mod_reason "No Python support" )
|
||||
set( _mod_testing ON ) # Will check syntax and imports, at least
|
||||
elseif ( MODULE_INTERFACE MATCHES "qtplugin" )
|
||||
set( _mod_enabled OFF )
|
||||
set( _mod_reason "C++ modules must have a CMakeLists.txt instead" )
|
||||
set( _mod_testing OFF )
|
||||
elseif ( MODULE_INTERFACE MATCHES "process" )
|
||||
set( _mod_enabled ON )
|
||||
set( _mod_reason "" )
|
||||
set( _mod_testing OFF )
|
||||
else()
|
||||
set( _mod_enabled OFF )
|
||||
set( _mod_reason "Unknown module interface '${MODULE_INTERFACE}'" )
|
||||
set( _mod_testing OFF )
|
||||
endif()
|
||||
|
||||
if ( _mod_enabled )
|
||||
# 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 ${_mod_dir} "${SUBDIRECTORY}/*" )
|
||||
foreach( MODULE_FILE ${MODULE_FILES} )
|
||||
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" )
|
||||
message(STATUS "Config ${MODULE_FILE}")
|
||||
list( APPEND MODULE_CONFIG_FILES ${MODULE_FILE} )
|
||||
else()
|
||||
message(STATUS "Non-Config ${MODULE_FILE}")
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE}
|
||||
DESTINATION ${MODULE_DESTINATION} )
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${_modulename}${ColorReset}" )
|
||||
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} => [Build directory and ${MODULE_DATA_DESTINATION}]")
|
||||
foreach(_cf ${MODULE_CONFIG_FILES})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${_cf} DESTINATION ${MODULE_DATA_DESTINATION})
|
||||
endforeach()
|
||||
else()
|
||||
message(" ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => [Build directory only]")
|
||||
endif()
|
||||
endif()
|
||||
message( "" )
|
||||
# We copy over the lang directory, if any
|
||||
if( IS_DIRECTORY "${_mod_dir}/lang" )
|
||||
install_calamares_gettext_translations(
|
||||
${SUBDIRECTORY}
|
||||
SOURCE_DIR "${_mod_dir}/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()
|
||||
else()
|
||||
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )
|
||||
message( "" )
|
||||
endif()
|
||||
|
||||
# Check any config files for basic correctness
|
||||
if ( BUILD_TESTING AND MODULE_CONFIG_FILES )
|
||||
set( _count 0 )
|
||||
foreach( _config_file ${MODULE_CONFIG_FILES} )
|
||||
set( _count_str "-${_count}" )
|
||||
if ( _count EQUAL 0 )
|
||||
set( _count_str "" )
|
||||
endif()
|
||||
add_test(
|
||||
NAME config-${SUBDIRECTORY}${_count_str}
|
||||
COMMAND test_conf ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${_config_file} )
|
||||
math( EXPR _count "${_count} + 1" )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Adding general tests
|
||||
#
|
||||
# Add a check that the module can be loaded. Since this calls exec(), the module
|
||||
# may try to do things to the running system. Needs work to make that a
|
||||
# safe thing to do.
|
||||
#
|
||||
# If the module has a tests/ subdirectory with *.global and *.job
|
||||
# files (YAML files holding global and job-configurations for
|
||||
# testing purposes) then those files are used to drive additional
|
||||
# tests. The files must be numbered (starting from 1) for this to work;
|
||||
# 1.global and 1.job together make the configuration for test 1.
|
||||
#
|
||||
# If the module has a tests/CMakeLists.txt while it doesn't have its
|
||||
# own CMakeLists.txt (e.g. a Python module), then the subdirectory
|
||||
# for tests/ is added on its own.
|
||||
#
|
||||
if ( BUILD_TESTING AND _mod_enabled AND _mod_testing )
|
||||
add_test(
|
||||
NAME load-${SUBDIRECTORY}
|
||||
COMMAND loadmodule ${SUBDIRECTORY}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
# Try it with the tests/ configurations shipped with the module
|
||||
set( _count 1 )
|
||||
set( _testdir ${_mod_dir}/tests )
|
||||
while ( EXISTS "${_testdir}/${_count}.global" OR EXISTS "${_testdir}/${_count}.job" )
|
||||
set( _dash_g "" )
|
||||
set( _dash_j "" )
|
||||
if ( EXISTS "${_testdir}/${_count}.global" )
|
||||
set( _dash_g -g ${_testdir}/${_count}.global )
|
||||
endif()
|
||||
if ( EXISTS "${_testdir}/${_count}.job" )
|
||||
set( _dash_j -j ${_testdir}/${_count}.job )
|
||||
endif()
|
||||
add_test(
|
||||
NAME load-${SUBDIRECTORY}-${_count}
|
||||
COMMAND loadmodule ${_dash_g} ${_dash_j} ${SUBDIRECTORY}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
math( EXPR _count "${_count} + 1" )
|
||||
endwhile()
|
||||
if ( EXISTS ${_testdir}/CMakeTests.txt AND NOT EXISTS ${_mod_dir}/CMakeLists.txt )
|
||||
include( ${_testdir}/CMakeTests.txt )
|
||||
endif()
|
||||
if ( PYLINT_COMMAND AND MODULE_INTERFACE MATCHES "python" )
|
||||
# Python modules get an additional test via pylint; this
|
||||
# needs to run at top-level because the ci/libcalamares directory
|
||||
# contains API stubs.
|
||||
#
|
||||
# TODO: the entry point is assumed to be `main.py`, but that is
|
||||
# configurable through module.desc
|
||||
add_test(
|
||||
NAME lint-${SUBDIRECTORY}
|
||||
COMMAND env PYTHONPATH=ci: ${PYLINT_COMMAND} -E ${_mod_dir}/main.py
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function( calamares_add_module_subdirectory )
|
||||
set( SUBDIRECTORY ${ARGV0} )
|
||||
set( _ams_SKIP_LIST ${ARGV1} )
|
||||
|
||||
set( SKIPPED_MODULES "" )
|
||||
_calamares_add_module_subdirectory_impl( ${SUBDIRECTORY} )
|
||||
if ( SKIPPED_MODULES )
|
||||
if ( _ams_SKIP_LIST )
|
||||
list( APPEND ${_ams_SKIP_LIST} "${SKIPPED_MODULES}" )
|
||||
set( ${_ams_SKIP_LIST} "${${_ams_SKIP_LIST}}" PARENT_SCOPE )
|
||||
else()
|
||||
set( SKIPPED_MODULES "${SKIPPED_MODULES}" PARENT_SCOPE )
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
233
calamares/CMakeModules/CalamaresAddPlugin.cmake
Normal file
233
calamares/CMakeModules/CalamaresAddPlugin.cmake
Normal file
@@ -0,0 +1,233 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Convenience function for creating a C++ (qtplugin) module for Calamares.
|
||||
# This function provides cmake-time feedback about the plugin, adds
|
||||
# targets for compilation and boilerplate information, and creates
|
||||
# a module.desc with standard values (if the module.desc file exists,
|
||||
# that one is used instead, which happens only for unusual plugins).
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# calamares_add_plugin(
|
||||
# module-name
|
||||
# TYPE <viewmodule|job>
|
||||
# EXPORT_MACRO macro-name
|
||||
# SOURCES source-file...
|
||||
# UI ui-file...
|
||||
# LINK_LIBRARIES lib...
|
||||
# LINK_PRIVATE_LIBRARIES lib...
|
||||
# [COMPILE_DEFINITIONS def...]
|
||||
# [RESOURCES resource-file]
|
||||
# [REQUIRES module-name...]
|
||||
# [NO_INSTALL]
|
||||
# [NO_CONFIG]
|
||||
# [SHARED_LIB]
|
||||
# [EMERGENCY]
|
||||
# [WEIGHT w]
|
||||
# )
|
||||
#
|
||||
# Function optional parameters:
|
||||
# - COMPILE_DEFINITIONS
|
||||
# Definitions are set on the resulting module with a suitable
|
||||
# flag (i.e. `-D`) so only state the name (optionally, also the value)
|
||||
# without a `-D` prefixed to it.
|
||||
# - RESOURCES
|
||||
# One (single!) filename for the RCC file for the plugin.
|
||||
# - REQUIRES
|
||||
# One or more names of modules which are added to the *requiredModules*
|
||||
# key in the descriptor. See *Module Requirements* in the module
|
||||
# documentation.
|
||||
# - NO_INSTALL
|
||||
# If this is set, the module is not installed by default; use this to
|
||||
# build testing modules or unit-testing modules.
|
||||
# - SHARED_LIB
|
||||
# In unusual circumstances, this function is used to add a library
|
||||
# rather than a normal Calamares module / plugin.
|
||||
# - EMERGENCY
|
||||
# If this is set, the module is marked as an *emergency* module in the
|
||||
# descriptor. See *Emergency Modules* in the module documentation.
|
||||
# - WEIGHT
|
||||
# If this is set, writes an explicit weight into the module.desc;
|
||||
# module weights are used in progress reporting.
|
||||
#
|
||||
#
|
||||
# This function follows the global SKIP_MODULES and USE_* settings, so
|
||||
# a plugin may be skipped -- then nothing will be built. In that case,
|
||||
# SKIPPED_MODULES is set in the parent (i.e. caller's) scope with the
|
||||
# reason why. This should rarely be a concern as AddModuleSubdirectory
|
||||
# already handles skip-reasons and collects them for reporting.
|
||||
#
|
||||
# The target defined this way is called "calamares_<TYPE>_<module-name>",
|
||||
# e.g. "calamares_viewmodule_packagechooserq". The function sets a variable
|
||||
# in its **calling** scope, `<module-name>_TARGET` with the full name
|
||||
# of the target.
|
||||
|
||||
include( CMakeParseArguments )
|
||||
|
||||
include( CalamaresAddLibrary )
|
||||
include( CalamaresCheckModuleSelection )
|
||||
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_CONFIG NO_INSTALL SHARED_LIB EMERGENCY )
|
||||
set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES WEIGHT )
|
||||
set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS REQUIRES )
|
||||
cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
set( PLUGIN_NAME ${NAME} )
|
||||
set( PLUGIN_DESTINATION ${CMAKE_INSTALL_LIBDIR}/calamares/modules/${PLUGIN_NAME} )
|
||||
set( PLUGIN_DESC_FILE module.desc )
|
||||
file( GLOB PLUGIN_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.conf" )
|
||||
set( PLUGIN_DATA_DESTINATION share/calamares/modules )
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
|
||||
calamares_check_skip( ${NAME} _skip)
|
||||
if ( _skip )
|
||||
set( SKIPPED_MODULES "${_skip}" PARENT_SCOPE )
|
||||
return()
|
||||
endif()
|
||||
|
||||
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${PLUGIN_NAME}${ColorReset}" )
|
||||
message( " ${Green}TYPE:${ColorReset} ${PLUGIN_TYPE}" )
|
||||
message( " ${Green}LINK_LIBRARIES:${ColorReset} ${PLUGIN_LINK_LIBRARIES}" )
|
||||
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}")
|
||||
elseif( NOT PLUGIN_NO_INSTALL )
|
||||
set( _destination "[Build directory only]" )
|
||||
else()
|
||||
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}" )
|
||||
endif()
|
||||
message( "" )
|
||||
|
||||
# create target name once for convenience
|
||||
set( target "calamares_${PLUGIN_TYPE}_${PLUGIN_NAME}" )
|
||||
|
||||
# automatic library linkage
|
||||
if(PLUGIN_TYPE STREQUAL "viewmodule")
|
||||
list(APPEND PLUGIN_LINK_PRIVATE_LIBRARIES Calamares::calamaresui)
|
||||
elseif(PLUGIN_TYPE STREQUAL "job")
|
||||
list(APPEND PLUGIN_LINK_PRIVATE_LIBRARIES Calamares::calamares)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown plugin type ${PLUGIN_TYPE}")
|
||||
endif()
|
||||
|
||||
# determine target type
|
||||
if( NOT ${PLUGIN_SHARED_LIB} )
|
||||
set( target_type "MODULE" )
|
||||
else()
|
||||
set( target_type "SHARED" )
|
||||
endif()
|
||||
|
||||
set( calamares_add_library_args
|
||||
"${target}"
|
||||
"EXPORT_MACRO" "${PLUGIN_EXPORT_MACRO}"
|
||||
"TARGET_TYPE" "${target_type}"
|
||||
"SOURCES" "${PLUGIN_SOURCES}"
|
||||
)
|
||||
|
||||
if( PLUGIN_UI )
|
||||
list( APPEND calamares_add_library_args "UI" "${PLUGIN_UI}" )
|
||||
endif()
|
||||
|
||||
if( PLUGIN_LINK_LIBRARIES )
|
||||
list( APPEND calamares_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}" )
|
||||
endif()
|
||||
|
||||
if( PLUGIN_LINK_PRIVATE_LIBRARIES )
|
||||
list( APPEND calamares_add_library_args "LINK_PRIVATE_LIBRARIES" "${PLUGIN_LINK_PRIVATE_LIBRARIES}" )
|
||||
endif()
|
||||
|
||||
if( PLUGIN_COMPILE_DEFINITIONS )
|
||||
list( APPEND calamares_add_library_args "COMPILE_DEFINITIONS" ${PLUGIN_COMPILE_DEFINITIONS} )
|
||||
endif()
|
||||
|
||||
if ( PLUGIN_NO_INSTALL )
|
||||
list( APPEND calamares_add_library_args "NO_INSTALL" )
|
||||
endif()
|
||||
|
||||
list( APPEND calamares_add_library_args
|
||||
"NO_VERSION"
|
||||
"INSTALL_BINDIR" "${PLUGIN_DESTINATION}"
|
||||
)
|
||||
|
||||
if( PLUGIN_RESOURCES )
|
||||
list( APPEND calamares_add_library_args "RESOURCES" "${PLUGIN_RESOURCES}" )
|
||||
endif()
|
||||
|
||||
calamares_add_library( ${calamares_add_library_args} )
|
||||
|
||||
if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_DESC_FILE} )
|
||||
configure_file( ${PLUGIN_DESC_FILE} ${PLUGIN_DESC_FILE} COPYONLY )
|
||||
else()
|
||||
set( _file ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE} )
|
||||
set( _type ${PLUGIN_TYPE} )
|
||||
file( WRITE ${_file} "# AUTO-GENERATED metadata file\n# Syntax is YAML 1.2\n---\n" )
|
||||
file( APPEND ${_file} "type: \"${_type}\"\nname: \"${PLUGIN_NAME}\"\ninterface: \"qtplugin\"\nload: \"lib${target}.so\"\n" )
|
||||
if ( PLUGIN_REQUIRES )
|
||||
file( APPEND ${_file} "requiredModules:\n" )
|
||||
foreach( _r ${PLUGIN_REQUIRES} )
|
||||
file( APPEND ${_file} " - ${_r}\n" )
|
||||
endforeach()
|
||||
endif()
|
||||
if ( PLUGIN_EMERGENCY )
|
||||
file( APPEND ${_file} "emergency: true\n" )
|
||||
endif()
|
||||
if ( PLUGIN_NO_CONFIG )
|
||||
file( APPEND ${_file} "noconfig: true\n" )
|
||||
endif()
|
||||
if ( PLUGIN_WEIGHT )
|
||||
file( APPEND ${_file} "weight: ${PLUGIN_WEIGHT}\n" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ( NOT PLUGIN_NO_INSTALL )
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE}
|
||||
DESTINATION ${PLUGIN_DESTINATION} )
|
||||
|
||||
set( _warned_config OFF )
|
||||
foreach( PLUGIN_CONFIG_FILE ${PLUGIN_CONFIG_FILES} )
|
||||
if( ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_CONFIG_FILE} IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} )
|
||||
configure_file( ${PLUGIN_CONFIG_FILE} ${PLUGIN_CONFIG_FILE} COPYONLY )
|
||||
else()
|
||||
message( " ${BoldYellow}Not updating${ColorReset} ${PLUGIN_CONFIG_FILE}" )
|
||||
set( _warned_config ON )
|
||||
endif()
|
||||
if(INSTALL_CONFIG)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} DESTINATION ${PLUGIN_DATA_DESTINATION})
|
||||
endif()
|
||||
endforeach()
|
||||
if ( _warned_config )
|
||||
message( "" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${NAME}_TARGET ${target} PARENT_SCOPE)
|
||||
endfunction()
|
||||
56
calamares/CMakeModules/CalamaresAddTest.cmake
Normal file
56
calamares/CMakeModules/CalamaresAddTest.cmake
Normal file
@@ -0,0 +1,56 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Support functions for building Calamares tests.
|
||||
# This extends KDE's ECM tests with some custom patterns.
|
||||
#
|
||||
# calamares_add_test(
|
||||
# <NAME>
|
||||
# [GUI]
|
||||
# [RESOURCES FILE]
|
||||
# SOURCES <FILE..>
|
||||
# )
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include(CalamaresAutomoc)
|
||||
|
||||
function(calamares_add_test name)
|
||||
set(options GUI)
|
||||
set(oneValueArgs RESOURCES)
|
||||
set(multiValueArgs SOURCES LIBRARIES DEFINITIONS)
|
||||
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(TEST_NAME ${name})
|
||||
|
||||
if(ECM_FOUND AND BUILD_TESTING)
|
||||
ecm_add_test(
|
||||
${TEST_SOURCES} ${TEST_RESOURCES}
|
||||
TEST_NAME
|
||||
${TEST_NAME}
|
||||
LINK_LIBRARIES
|
||||
Calamares::calamares
|
||||
${TEST_LIBRARIES}
|
||||
${qtname}::Core
|
||||
${qtname}::Test
|
||||
)
|
||||
calamares_automoc( ${TEST_NAME} )
|
||||
# We specifically pass in the source directory of the test-being-
|
||||
# compiled, so that it can find test-files in that source dir.
|
||||
target_compile_definitions(
|
||||
${TEST_NAME}
|
||||
PRIVATE -DBUILD_AS_TEST="${CMAKE_CURRENT_SOURCE_DIR}" ${TEST_DEFINITIONS}
|
||||
)
|
||||
if(TEST_GUI)
|
||||
target_link_libraries(${TEST_NAME} Calamares::calamaresui ${qtname}::Gui)
|
||||
endif()
|
||||
if(TEST_RESOURCES)
|
||||
calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
158
calamares/CMakeModules/CalamaresAddTranslations.cmake
Normal file
158
calamares/CMakeModules/CalamaresAddTranslations.cmake
Normal file
@@ -0,0 +1,158 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# This file has not yet been documented for use outside of Calamares itself.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include(FeatureSummary)
|
||||
|
||||
# The Gettext module is still old-fashioned, ALLCAPS variables
|
||||
find_package( Gettext )
|
||||
set_package_properties( GETTEXT PROPERTIES
|
||||
DESCRIPTION "GNU gettext (translation) tools."
|
||||
URL "https://www.gnu.org/software/gettext/"
|
||||
PURPOSE "Gettext is used in the translation of Python modules."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
|
||||
# Installs a directory containing language-code-labeled subdirectories with
|
||||
# gettext data into the appropriate system directory. Allows renaming the
|
||||
# .mo files during install to avoid namespace clashes.
|
||||
#
|
||||
# install_calamares_gettext_translations(
|
||||
# NAME <name of module, for human use>
|
||||
# SOURCE_DIR path/to/lang
|
||||
# FILENAME <name of file.mo>
|
||||
# [RENAME <new-name of.mo>]
|
||||
# )
|
||||
#
|
||||
# For all of the (global) translation languages enabled for Calamares,
|
||||
# try installing $SOURCE_DIR/$lang/LC_MESSAGES/<filename>.mo into the
|
||||
# system gettext data directory (e.g. share/locale/), possibly renaming
|
||||
# filename.mo to renamed.mo in the process.
|
||||
function( install_calamares_gettext_translations )
|
||||
# parse arguments ( name needs to be saved before passing ARGN into the macro )
|
||||
set( NAME ${ARGV0} )
|
||||
set( oneValueArgs NAME SOURCE_DIR FILENAME RENAME )
|
||||
cmake_parse_arguments( TRANSLATION "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
if( NOT TRANSLATION_NAME )
|
||||
set( TRANSLATION_NAME ${NAME} )
|
||||
endif()
|
||||
if( NOT TRANSLATION_FILENAME )
|
||||
set( TRANSLATION_FILENAME "${TRANSLATION_NAME}.mo" )
|
||||
endif()
|
||||
if( NOT TRANSLATION_RENAME )
|
||||
set( TRANSLATION_RENAME "${TRANSLATION_FILENAME}" )
|
||||
endif()
|
||||
string( REGEX REPLACE ".mo$" ".po" TRANSLATION_SOURCE_FILENAME "${TRANSLATION_FILENAME}" )
|
||||
|
||||
if ( GETTEXT_FOUND AND GETTEXT_MSGFMT_EXECUTABLE )
|
||||
message( STATUS "Installing gettext translations for ${TRANSLATION_NAME}")
|
||||
message( STATUS " Installing ${TRANSLATION_FILENAME} from ${TRANSLATION_SOURCE_DIR}")
|
||||
else()
|
||||
message( WARNING "Gettext translations requested for ${TRANSLATION_NAME}, but gettext was not found." )
|
||||
return()
|
||||
endif()
|
||||
|
||||
set( TARGET_NAME calamares-gettext-translations-${NAME} )
|
||||
if( NOT TARGET "${TARGET_NAME}" )
|
||||
add_custom_target( "${TARGET_NAME}" ALL )
|
||||
endif()
|
||||
|
||||
set( TRANSLATION_NAME "${NAME}" )
|
||||
foreach( lang ${CALAMARES_TRANSLATION_LANGUAGES} ) # Global
|
||||
string( MAKE_C_IDENTIFIER "${TARGET_NAME}-${lang}" TARGET_SUBNAME )
|
||||
|
||||
set( lang_po "${TRANSLATION_SOURCE_DIR}/${lang}/LC_MESSAGES/${TRANSLATION_SOURCE_FILENAME}" )
|
||||
set( lang_mo_dir "${CMAKE_BINARY_DIR}/lang/${lang}/LC_MESSAGES" )
|
||||
set( lang_mo "${lang_mo_dir}/${TRANSLATION_RENAME}" )
|
||||
if( lang STREQUAL "en" )
|
||||
message( STATUS " Skipping ${TRANSLATION_NAME} translations for en_US" )
|
||||
else()
|
||||
# We **don't** use the gettext macro's here because the source
|
||||
# structure doesn't match: we are calling this once per language
|
||||
# for all of Calamares's languages, while the gettext module
|
||||
# expects it to be called once, for a given language source-dir.
|
||||
#
|
||||
# Using any of the gettext macros just gets us multiple rules
|
||||
# for python.gmo, and it wants to use msgmerge, besides, which
|
||||
# doesn't fit our Transifex workflow.
|
||||
make_directory( ${lang_mo_dir} )
|
||||
add_custom_command(
|
||||
OUTPUT ${lang_mo}
|
||||
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
|
||||
ARGS -o ${lang_mo} ${lang_po}
|
||||
MAIN_DEPENDENCY ${lang_po}
|
||||
)
|
||||
add_custom_target( "${TARGET_SUBNAME}" DEPENDS ${lang_mo} )
|
||||
add_dependencies( "${TARGET_NAME}" "${TARGET_SUBNAME}" )
|
||||
install(
|
||||
FILES ${lang_mo}
|
||||
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES/
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(_calamares_qrc_translations_qrc_source ${CMAKE_CURRENT_LIST_DIR}/i18n.qrc.in) # Needs to be set outside of function
|
||||
function(calamares_qrc_translations basename)
|
||||
set(options "")
|
||||
set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE)
|
||||
set(multiValueArgs PREFIXES LANGUAGES)
|
||||
cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT _qrt_OUTPUT_VARIABLE)
|
||||
message(FATAL_ERROR "No output variable")
|
||||
endif()
|
||||
if(NOT _qrt_PREFIXES)
|
||||
set(_qrt_PREFIXES "${basename}")
|
||||
endif()
|
||||
if(NOT _qrt_LANGUAGES)
|
||||
set(_qrt_LANGUAGES ${CALAMARES_TRANSLATION_LANGUAGES})
|
||||
endif()
|
||||
if(NOT _qrt_SUBDIRECTORY)
|
||||
set(_qrt_SUBDIRECTORY "")
|
||||
endif()
|
||||
|
||||
set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc)
|
||||
set(translations_qrc_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${basename}.cxx)
|
||||
|
||||
# Must use this variable name because of the @ substitution
|
||||
set(calamares_i18n_qrc_content "")
|
||||
set(calamares_i18n_ts_filelist "")
|
||||
foreach(lang ${_qrt_LANGUAGES})
|
||||
foreach(tlsource ${_qrt_PREFIXES})
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts")
|
||||
string(APPEND calamares_i18n_qrc_content "<file>${tlsource}_${lang}.qm</file>\n")
|
||||
list(APPEND calamares_i18n_ts_filelist "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
configure_file(${_calamares_qrc_translations_qrc_source} ${translations_qrc_infile} @ONLY)
|
||||
qt_add_translation(QM_FILES ${calamares_i18n_ts_filelist})
|
||||
|
||||
# Run the resource compiler (rcc_options should already be set)
|
||||
add_custom_command(
|
||||
OUTPUT ${translations_qrc_outfile}
|
||||
COMMAND ${qtname}::rcc
|
||||
ARGS
|
||||
${rcc_options}
|
||||
--format-version 1
|
||||
-name ${basename}
|
||||
-o ${translations_qrc_outfile}
|
||||
${translations_qrc_infile}
|
||||
MAIN_DEPENDENCY ${translations_qrc_infile}
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
|
||||
set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE)
|
||||
endfunction()
|
||||
57
calamares/CMakeModules/CalamaresAutomoc.cmake
Normal file
57
calamares/CMakeModules/CalamaresAutomoc.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
#
|
||||
###
|
||||
#
|
||||
# Helper function for doing automoc, autouic, autorcc on targets,
|
||||
# and on the corresponding .ui or .rcc files.
|
||||
#
|
||||
# calamares_automoc(target)
|
||||
# Sets AUTOMOC TRUE for a target.
|
||||
#
|
||||
# If the global variable CALAMARES_AUTOMOC_OPTIONS is set, uses that
|
||||
# as well to set options passed to MOC. This can be used to add
|
||||
# libcalamares/utils/moc-warnings.h file to the moc, which in turn
|
||||
# reduces compiler warnings in generated MOC code.
|
||||
#
|
||||
# calamares_autouic(target [uifile ..])
|
||||
# Sets AUTOUIC TRUE for a target.
|
||||
#
|
||||
# If the global variable CALAMARES_AUTOUIC_OPTIONS is set, adds that
|
||||
# to the options passed to uic for each of the named uifiles.
|
||||
#
|
||||
# calamares_autorcc(target [rcfile ..])
|
||||
# Sets AUTOUIC TRUE for a target.
|
||||
#
|
||||
# If the global variable CALAMARES_AUTORCC_OPTIONS is set, adds that
|
||||
# to the options passed to rcc for each of the named rcfiles.
|
||||
|
||||
function(calamares_automoc TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE )
|
||||
if ( CALAMARES_AUTOMOC_OPTIONS )
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOMOC_MOC_OPTIONS "${CALAMARES_AUTOMOC_OPTIONS}" )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(calamares_autouic TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOUIC TRUE )
|
||||
if ( CALAMARES_AUTOUIC_OPTIONS )
|
||||
foreach(S ${ARGN})
|
||||
set_property(SOURCE ${S} PROPERTY AUTOUIC_OPTIONS "${CALAMARES_AUTOUIC_OPTIONS}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(calamares_autorcc TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTORCC TRUE )
|
||||
if ( CALAMARES_AUTORCC_OPTIONS )
|
||||
foreach(S ${ARGN})
|
||||
set_property(SOURCE ${S} PROPERTY AUTORCC_OPTIONS "${CALAMARES_AUTORCC_OPTIONS}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
116
calamares/CMakeModules/CalamaresCheckModuleSelection.cmake
Normal file
116
calamares/CMakeModules/CalamaresCheckModuleSelection.cmake
Normal file
@@ -0,0 +1,116 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Calamares is Free Software: see the License-Identifier above.
|
||||
#
|
||||
###
|
||||
#
|
||||
# This module implements the "skip modules" part of configuring
|
||||
# the Calamares repository or an external-modules repository.
|
||||
#
|
||||
# It should not be necessary to include() this module explicitly,
|
||||
# since both AddPlugin and AddModuleSubdirectory do so implicitly.
|
||||
#
|
||||
#
|
||||
# # Usage
|
||||
#
|
||||
# The public API is two functions:
|
||||
#
|
||||
# - calamares_skip_module(reason)
|
||||
# A C++ module (or any that uses CMake) can call this macro to
|
||||
# add *reason* to the list of skipped modules. Typically a module
|
||||
# will pass in "modulename (why)" so that it is clear **which**
|
||||
# module is skipped. This macro should be called at the top-level
|
||||
# of a module's CMakeLists.txt and the module should then **not**
|
||||
# call calamares_add_plugin().
|
||||
# - calamares_explain_skipped_modules(list...)
|
||||
# This will print out all the module reasons (see above) that have
|
||||
# been added to the given *listvar*. When AddModuleSubdirectory is
|
||||
# used as the mechanism to add all the subdirectories in the repository
|
||||
# that contain modules, with a consistent *listvar* setting,
|
||||
# this will show all the modules that have been skipped.
|
||||
#
|
||||
# The internal API is one function:
|
||||
#
|
||||
# - calamares_check_skip(modulename outvar)
|
||||
# Checks if the *modulename* has been listed in the global SKIP_MODULES
|
||||
# variable (to skip specifically-named modules) or if there is a USE_*
|
||||
# setting applicable to the module. If the module is skipped for this
|
||||
# reason, a suitable entry is added to *outvar* as if
|
||||
# calamares_skip_module() had been called.
|
||||
#
|
||||
# Best practice is to pick a variable to collect all of the skipped
|
||||
# modules, and to pass the name of that variable to AddModuleSubdirectory
|
||||
# in each call. After all subdirectories have been added, call
|
||||
# calamares_explain_skipped_modules() with the value of that variable.
|
||||
|
||||
|
||||
# Convenience function to indicate that a module has been skipped
|
||||
# (optionally also why). Call this in the module's CMakeLists.txt
|
||||
macro( calamares_skip_module )
|
||||
set( SKIPPED_MODULES ${SKIPPED_MODULES} ${ARGV} PARENT_SCOPE )
|
||||
endmacro()
|
||||
|
||||
function( calamares_explain_skipped_modules )
|
||||
if ( ARGN )
|
||||
message( "${ColorReset}-- Skipped modules:" )
|
||||
foreach( SUBDIRECTORY ${ARGN} )
|
||||
message( "${ColorReset}-- Skipped ${BoldRed}${SUBDIRECTORY}${ColorReset}." )
|
||||
endforeach()
|
||||
message( "" )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Globally, SKIP_MODULES and USE_* affect what modules are built.
|
||||
# Check if *modulename* should be skipped, and if so, set *outvar* to
|
||||
# a human-readable reason for skipping it.
|
||||
function( _calamares_check_skip_impl modulename outvar )
|
||||
# Globally-defined SKIP_MODULES may be space- or semicolon- separated
|
||||
# so convert it to a list-variable.
|
||||
string( REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}" )
|
||||
|
||||
list( FIND SKIP_LIST "${modulename}" DO_SKIP )
|
||||
if( NOT DO_SKIP EQUAL -1 )
|
||||
set( ${outvar} "user request" PARENT_SCOPE )
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Not skipped by the global check, see if it has an applicable USE_*
|
||||
if( "${modulename}" MATCHES "^[a-zA-Z0-9_]+-" )
|
||||
# Split the name into <category>-<implementation>
|
||||
string( REGEX REPLACE "-.*" "" _category "${modulename}" )
|
||||
string( REGEX REPLACE "^[^-]+-" "" _implementation "${modulename}" )
|
||||
else()
|
||||
# Not a module to which USE_* applies
|
||||
return()
|
||||
endif()
|
||||
|
||||
if( "${USE_${_category}}" STREQUAL "none" )
|
||||
set( ${outvar} "category ${_category} disabled" PARENT_SCOPE )
|
||||
return()
|
||||
elseif( "${USE_${_category}}" STREQUAL "" )
|
||||
# Category not set at all or nonexistent
|
||||
return()
|
||||
endif()
|
||||
|
||||
if ( "${USE_${_category}}" STREQUAL "${_implementation}" )
|
||||
# Matches, so accept this module
|
||||
else()
|
||||
set( ${outvar} "category ${_category} selects ${USE_${_category}}" PARENT_SCOPE )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# This is the public API;it calls the _impl version so that there
|
||||
# is an extra intermediate scope for the subdirectory to write results into.
|
||||
function( calamares_check_skip modulename outvar )
|
||||
set( _skip "" )
|
||||
_calamares_check_skip_impl( "${modulename}" _skip )
|
||||
if ( _skip )
|
||||
message( "${ColorReset}-- Skipping module ${BoldRed}${modulename} (${_skip})${ColorReset}." )
|
||||
message( "" )
|
||||
set( ${outvar} "${modulename} (${_skip})" PARENT_SCOPE )
|
||||
endif()
|
||||
endfunction()
|
||||
70
calamares/CMakeModules/ExtendedVersion.cmake
Normal file
70
calamares/CMakeModules/ExtendedVersion.cmake
Normal file
@@ -0,0 +1,70 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# This file defines one function for extending a VERSION-like value
|
||||
# with date and git information (if desired).
|
||||
#
|
||||
# - extend_version( version-string short_only short_var long_var )
|
||||
# Calling this function will copy *version-string* (which would typically
|
||||
# be a semver-style string, like "3.2.40") into the variable *short_var*.
|
||||
# If *short_only* is true, then:
|
||||
# - the short version is also copied into the variable *long_var*,
|
||||
# If *short_only* is false, then:
|
||||
# - the *version-string* plus date and git information, is copied
|
||||
# into the varialbe *long_var*, in the format {version}-{date}-{hash}
|
||||
#
|
||||
#
|
||||
|
||||
function( get_git_version_info out_var )
|
||||
set(CMAKE_VERSION_SOURCE "")
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
|
||||
find_program(GIT_EXECUTABLE NAMES git git.cmd)
|
||||
mark_as_advanced(GIT_EXECUTABLE)
|
||||
if(GIT_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=8 HEAD
|
||||
OUTPUT_VARIABLE head
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
if(head)
|
||||
set(CMAKE_VERSION_SOURCE "${head}")
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
||||
OUTPUT_VARIABLE dirty
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
if(dirty)
|
||||
set(CMAKE_VERSION_SOURCE "${CMAKE_VERSION_SOURCE}-dirty")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set( ${out_var} "${CMAKE_VERSION_SOURCE}" PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
function( extend_version version short_only short_var long_var )
|
||||
set( ${short_var} "${version}" PARENT_SCOPE )
|
||||
set( _v "${version}" )
|
||||
if ( NOT short_only )
|
||||
string( TIMESTAMP CALAMARES_VERSION_DATE "%Y%m%d" )
|
||||
if( CALAMARES_VERSION_DATE GREATER 0 )
|
||||
set( _v ${_v}.${CALAMARES_VERSION_DATE} )
|
||||
endif()
|
||||
get_git_version_info( _gitv )
|
||||
if( _gitv )
|
||||
set( _v "${_v}-${_gitv}" )
|
||||
endif()
|
||||
endif()
|
||||
set( ${long_var} "${_v}" PARENT_SCOPE )
|
||||
endfunction()
|
||||
42
calamares/CMakeModules/FindCrypt.cmake
Normal file
42
calamares/CMakeModules/FindCrypt.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# - Find libcrypt
|
||||
# Find the libcrypt includes and the libcrypt libraries
|
||||
# This module defines
|
||||
# LIBCRYPT_INCLUDE_DIR, root crypt include dir. Include crypt with crypt.h
|
||||
# LIBCRYPT_LIBRARY, the path to libcrypt
|
||||
# LIBCRYPT_FOUND, whether libcrypt was found
|
||||
|
||||
if( CMAKE_SYSTEM MATCHES "FreeBSD" )
|
||||
# FreeBSD has crypt(3) declared in unistd.h, which lives in
|
||||
# libc; the libcrypt found here is not used.
|
||||
find_path( CRYPT_INCLUDE_DIR NAMES unistd.h )
|
||||
add_definitions( -DNO_CRYPT_H )
|
||||
else()
|
||||
find_path( CRYPT_INCLUDE_DIR
|
||||
NAMES crypt.h
|
||||
HINTS
|
||||
${CMAKE_INSTALL_INCLUDEDIR}
|
||||
NO_CACHE
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library( CRYPT_LIBRARIES
|
||||
NAMES crypt
|
||||
HINTS
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
include( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args(
|
||||
Crypt
|
||||
REQUIRED_VARS CRYPT_LIBRARIES CRYPT_INCLUDE_DIR
|
||||
)
|
||||
|
||||
mark_as_advanced( CRYPT_INCLUDE_DIR CRYPT_LIBRARIES )
|
||||
58
calamares/CMakeModules/FindLIBPARTED.cmake
Normal file
58
calamares/CMakeModules/FindLIBPARTED.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
# SPDX-FileCopyrightText: 2008,2010,2011 by Volker Lanz <vl@fidra.de>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)
|
||||
# Already in cache, be silent
|
||||
set(LIBPARTED_FIND_QUIETLY TRUE)
|
||||
endif (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)
|
||||
|
||||
|
||||
FIND_PATH(LIBPARTED_INCLUDE_DIR parted.h PATH_SUFFIXES parted )
|
||||
|
||||
FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted)
|
||||
FIND_LIBRARY(LIBPARTED_FS_RESIZE_LIBRARY NAMES parted-fs-resize)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR)
|
||||
|
||||
if (LIBPARTED_FS_RESIZE_LIBRARY)
|
||||
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY} ${LIBPARTED_FS_RESIZE_LIBRARY})
|
||||
else (LIBPARTED_FS_RESIZE_LIBRARY)
|
||||
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY})
|
||||
endif (LIBPARTED_FS_RESIZE_LIBRARY)
|
||||
|
||||
# KDE adds -ansi to the C make flags, parted headers use GNU extensions, so
|
||||
# undo that
|
||||
unset(CMAKE_C_FLAGS)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS})
|
||||
|
||||
CHECK_FUNCTION_EXISTS("ped_file_system_clobber" LIBPARTED_FILESYSTEM_SUPPORT) # parted < 3.0
|
||||
CHECK_FUNCTION_EXISTS("ped_file_system_resize" LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) # parted != 3.0
|
||||
|
||||
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT LIBPARTED_FS_RESIZE_LIBRARY LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)
|
||||
50
calamares/CMakeModules/FindLibPWQuality.cmake
Normal file
50
calamares/CMakeModules/FindLibPWQuality.cmake
Normal file
@@ -0,0 +1,50 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Locate libpwquality
|
||||
# https://github.com/libpwquality/libpwquality
|
||||
#
|
||||
# This module defines
|
||||
# LibPWQuality_FOUND
|
||||
# LibPWQuality_LIBRARIES, where to find the library
|
||||
# LibPWQuality_INCLUDE_DIRS, where to find pwquality.h
|
||||
#
|
||||
find_package(PkgConfig)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_search_module(pc_pwquality QUIET pwquality)
|
||||
else()
|
||||
# It's just possible that the find_path and find_library will
|
||||
# find it **anyway**, so let's pretend it was there.
|
||||
set(pc_pwquality_FOUND ON)
|
||||
endif()
|
||||
|
||||
find_path(LibPWQuality_INCLUDE_DIR
|
||||
NAMES pwquality.h
|
||||
PATHS ${pc_pwquality_INCLUDE_DIRS}
|
||||
)
|
||||
find_library(LibPWQuality_LIBRARY
|
||||
NAMES pwquality
|
||||
PATHS ${pc_pwquality_LIBRARY_DIRS}
|
||||
)
|
||||
if(pc_pwquality_FOUND)
|
||||
set(LibPWQuality_LIBRARIES ${LibPWQuality_LIBRARY})
|
||||
set(LibPWQuality_INCLUDE_DIRS ${LibPWQuality_INCLUDE_DIR} ${pc_pwquality_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(LibPWQuality DEFAULT_MSG
|
||||
LibPWQuality_INCLUDE_DIRS
|
||||
LibPWQuality_LIBRARIES
|
||||
)
|
||||
mark_as_advanced(LibPWQuality_INCLUDE_DIRS LibPWQuality_LIBRARIES)
|
||||
|
||||
set_package_properties(
|
||||
LibPWQuality PROPERTIES
|
||||
DESCRIPTION "Password quality checking library"
|
||||
URL "https://github.com/libpwquality/libpwquality"
|
||||
)
|
||||
73
calamares/CMakeModules/FindYAMLCPP.cmake
Normal file
73
calamares/CMakeModules/FindYAMLCPP.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Locate yaml-cpp
|
||||
#
|
||||
# This module defines
|
||||
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
|
||||
# YAMLCPP_LIBRARY, where to find yaml-cpp
|
||||
# YAMLCPP_INCLUDE_DIR, where to find yaml.h
|
||||
# There is also one IMPORTED library target,
|
||||
# yamlcpp::yamlcpp
|
||||
#
|
||||
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
|
||||
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...).
|
||||
#
|
||||
# If yaml-cpp is not installed in a standard path, you can use the YAMLCPP_DIR CMake variable
|
||||
# to tell CMake where yaml-cpp is.
|
||||
|
||||
if(TARGET yamlcpp::yamlcpp)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# attempt to find static library first if this is set
|
||||
if(YAMLCPP_STATIC_LIBRARY)
|
||||
set(YAMLCPP_STATIC libyaml-cpp.a)
|
||||
endif()
|
||||
|
||||
# find the yaml-cpp include directory
|
||||
find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
|
||||
PATH_SUFFIXES include
|
||||
PATHS
|
||||
~/Library/Frameworks/yaml-cpp/include/
|
||||
/Library/Frameworks/yaml-cpp/include/
|
||||
/usr/local/include/
|
||||
/usr/include/
|
||||
/sw/yaml-cpp/ # Fink
|
||||
/opt/local/yaml-cpp/ # DarwinPorts
|
||||
/opt/csw/yaml-cpp/ # Blastwave
|
||||
/opt/yaml-cpp/
|
||||
${YAMLCPP_DIR}/include/)
|
||||
|
||||
# find the yaml-cpp library
|
||||
find_library(YAMLCPP_LIBRARY
|
||||
NAMES ${YAMLCPP_STATIC} yaml-cpp
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
${YAMLCPP_DIR}/lib)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
||||
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
||||
|
||||
# Add an imported target
|
||||
if( YAMLCPP_LIBRARY )
|
||||
add_library( yamlcpp::yamlcpp UNKNOWN IMPORTED )
|
||||
set_property( TARGET yamlcpp::yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} )
|
||||
if ( YAMLCPP_INCLUDE_DIR )
|
||||
set_property( TARGET yamlcpp::yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} )
|
||||
endif()
|
||||
endif()
|
||||
64
calamares/CMakeModules/KPMcoreHelper.cmake
Normal file
64
calamares/CMakeModules/KPMcoreHelper.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
###
|
||||
#
|
||||
# Finds KPMcore and consistently sets API flags based on the version.
|
||||
#
|
||||
# If KPMcore is not found, still create calamares::kpmcore interface
|
||||
# library, which will add definition WITHOUT_KPMcore.
|
||||
#
|
||||
if(NOT TARGET calapmcore)
|
||||
find_package(${kfname}Config CONFIG)
|
||||
find_package(${kfname}I18n CONFIG)
|
||||
find_package(${kfname}WidgetsAddons CONFIG)
|
||||
|
||||
if(WITH_QT6)
|
||||
find_package(KPMcore 24.01.75)
|
||||
else()
|
||||
find_package(KPMcore 20.04.0)
|
||||
endif()
|
||||
set_package_properties(
|
||||
KPMcore
|
||||
PROPERTIES
|
||||
URL "https://invent.kde.org/kde/kpmcore"
|
||||
DESCRIPTION "KDE Partitioning library"
|
||||
TYPE RECOMMENDED
|
||||
PURPOSE "For disk partitioning support"
|
||||
)
|
||||
|
||||
# Create an internal Calamares interface to KPMcore
|
||||
# and give it a nice alias name. If kpmcore is not found,
|
||||
# then make a "no KPMcore" library.
|
||||
add_library(calapmcore INTERFACE)
|
||||
|
||||
if(KPMcore_FOUND)
|
||||
find_package(${qtname} REQUIRED DBus) # Needed for KPMCore
|
||||
find_package(${kfname}I18n REQUIRED) # Needed for KPMCore
|
||||
find_package(${kfname}WidgetsAddons REQUIRED) # Needed for KPMCore
|
||||
|
||||
target_link_libraries(calapmcore INTERFACE kpmcore ${qtname}::DBus ${kfname}::I18n ${kfname}::WidgetsAddons)
|
||||
target_include_directories(calapmcore INTERFACE ${KPMCORE_INCLUDE_DIR})
|
||||
math(EXPR _kpm_version_number "(0x${KPMcore_VERSION_MAJOR} * 0x10000)+(0x${KPMcore_VERSION_MINOR} * 0x100)+(0x${KPMcore_VERSION_PATCH})" OUTPUT_FORMAT HEXADECIMAL)
|
||||
target_compile_definitions(calapmcore INTERFACE WITH_KPMcore=${_kpm_version_number})
|
||||
|
||||
# Flag that this library has KPMcore support. A variable
|
||||
# set here has the wrong scope. ENV{} would be visible
|
||||
# everywhere but seems the wrong thing to do. Setting
|
||||
# properties on calapmcore requires a newer CMake than
|
||||
# Debian 11 has, so runs into support issues.
|
||||
add_library(calamares::kpmcore ALIAS calapmcore)
|
||||
else()
|
||||
target_compile_definitions(calapmcore INTERFACE WITHOUT_KPMcore)
|
||||
endif()
|
||||
else()
|
||||
if(TARGET calamares::kpmcore)
|
||||
message(STATUS "KPMcore has already been found")
|
||||
set(KPMcore_FOUND TRUE)
|
||||
else()
|
||||
message(STATUS "KPMcore has been searched-for and not found")
|
||||
set(KPMcore_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
9
calamares/CMakeModules/i18n.qrc.in
Normal file
9
calamares/CMakeModules/i18n.qrc.in
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE RCC>
|
||||
<!-- SPDX-FileCopyrightText: no
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
<RCC version="1.0">
|
||||
<qresource prefix="/lang">
|
||||
@calamares_i18n_qrc_content@
|
||||
</qresource>
|
||||
</RCC>
|
||||
Reference in New Issue
Block a user