2020-08-25 16:05:56 +02:00
# === This file is part of Calamares - <https://calamares.io> ===
2017-09-19 11:11:46 +02:00
#
2020-08-10 09:44:34 +02:00
# SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
2020-08-26 00:24:52 +02:00
# SPDX-License-Identifier: BSD-2-Clause
#
###
2020-08-10 09:44:34 +02:00
#
2020-08-25 16:05:56 +02:00
# Calamares is Free Software: see the License-Identifier above.
2017-09-19 11:11:46 +02:00
#
2020-08-26 00:24:52 +02:00
# Individual files may have different licenses (like the CMake
# infrastructure, which is BSD-2-Clause licensed). Check the SPDX
# identifiers in each file.
#
2017-09-19 11:11:46 +02:00
###
2017-07-25 09:00:30 +02:00
#
# Generally, this CMakeLists.txt will find all the dependencies for Calamares
# and complain appropriately. See below (later in this file) for CMake-level
# options. There are some "secret" options as well:
#
# SKIP_MODULES : a space or semicolon-separated list of directory names
# under src/modules that should not be built.
2019-03-17 09:47:30 -04:00
# USE_<foo> : fills in SKIP_MODULES for modules called <foo>-<something>
2019-08-20 13:56:23 +02:00
# WITH_<foo> : try to enable <foo> (these usually default to ON). For
# a list of WITH_<foo> grep CMakeCache.txt after running
2020-06-16 13:54:13 +02:00
# CMake once. These affect the ABI offered by Calamares.
# - PYTHON (enable Python Job modules)
# - QML (enable QML UI View modules)
2021-11-30 11:49:43 +01:00
# The WITH_* options affect the ABI of Calamares: you must
# build (C++) modules for Calamares with the same WITH_*
# settings, or they may not load at all.
2019-03-17 09:47:30 -04:00
# BUILD_<foo> : choose additional things to build
2020-06-16 13:54:13 +02:00
# - TESTING (standard CMake option)
2020-06-16 17:36:59 +02:00
# - SCHEMA_TESTING (requires Python, see ci/configvalidator.py)
2021-11-30 11:49:43 +01:00
# - KF5Crash (uses KCrash, rather than Calamares internal, for crash reporting)
2019-03-17 09:47:30 -04:00
# DEBUG_<foo> : special developer flags for debugging
2017-07-25 09:00:30 +02:00
#
# Example usage:
#
# cmake . -DSKIP_MODULES="partition luksbootkeycfg"
2018-06-28 05:19:32 -04:00
#
# One special target is "show-version", which can be built
# to obtain the version number from here.
2017-07-25 09:00:30 +02:00
2022-02-08 16:18:47 +01:00
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
2021-03-28 18:51:44 +02:00
2022-02-08 16:18:47 +01:00
set(CALAMARES_VERSION 3.3.0)
set(CALAMARES_RELEASE_MODE OFF) # Set to ON during a release
2021-03-28 18:51:44 +02:00
2022-02-08 16:18:47 +01:00
if(CMAKE_SCRIPT_MODE_FILE)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeModules/ExtendedVersion.cmake)
set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
2021-03-28 18:51:44 +02:00
extend_version( ${CALAMARES_VERSION} OFF _vshort _vlong )
2022-02-08 16:18:47 +01:00
message("${_vlong}")
2021-03-28 18:51:44 +02:00
return()
endif()
2022-02-08 16:18:47 +01:00
project(CALAMARES VERSION ${CALAMARES_VERSION} LANGUAGES C CXX)
2015-06-04 02:27:46 +02:00
2022-02-08 16:18:47 +01:00
if(CALAMARES_RELEASE_MODE AND CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Do not build development versions in the source-directory.")
2021-11-29 14:56:15 +01:00
endif()
2021-03-29 10:08:20 +02:00
2018-06-07 13:16:57 +02:00
### OPTIONS
#
2022-02-08 16:18:47 +01:00
option(INSTALL_CONFIG "Install configuration files" OFF)
option(INSTALL_POLKIT "Install Polkit configuration" ON)
option(INSTALL_COMPLETION "Install shell completions" OFF)
2020-05-14 11:15:23 +02:00
# When adding WITH_* that affects the ABI offered by libcalamares,
# also update libcalamares/CalamaresConfig.h.in
2022-02-08 16:18:47 +01:00
option(WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON)
option(WITH_QML "Enable QML UI options." ON)
2020-06-16 17:36:59 +02:00
#
2021-11-30 11:49:43 +01:00
# Additional parts to build that do not affect ABI
2022-02-08 16:18:47 +01:00
option(BUILD_SCHEMA_TESTING "Enable schema-validation-tests" ON)
2021-11-30 11:49:43 +01:00
# Options for the calamares executable
2022-02-08 16:18:47 +01:00
option(BUILD_KF5Crash "Enable crash reporting with KCrash." ON)
2018-06-07 13:16:57 +02:00
2020-04-14 11:18:51 +02:00
# Possible debugging flags are:
# - DEBUG_TIMEZONES draws latitude and longitude lines on the timezone
# widget and enables chatty debug logging, for dealing with the timezone
# location database.
# - DEBUG_FILESYSTEMS does extra logging and checking when looking at
# partition configuration. Lists known KPMCore FS types.
# - DEBUG_PARTITION_UNSAFE (see partition/CMakeLists.txt)
2022-02-21 11:56:34 +01:00
# - DEBUG_PARTITION_BAIL_OUT (see partition/CMakeLists.txt)
2020-04-14 11:18:51 +02:00
2018-06-26 05:18:10 -04:00
### USE_*
#
# By convention, when there are multiple modules that implement similar
# functionality, and it only makes sense to have **at most one** of them
# enabled at any time, those modules are named <foo>-<implementation>.
# For example, services-systemd and services-openrc.
#
# Setting up SKIP_MODULES to ignore "the ones you don't want" can be
# annoying and error-prone (e.g. if a new module shows up). The USE_*
# modules provide a way to do automatic selection. To pick exactly
# one of the implementations from group <foo>, set USE_<foo> to the
# name of the implementation. If USE_<foo> is unset, or empty, then
# all the implementations are enabled (this just means they are
# **available** to `settings.conf`, not that they are used).
#
2020-06-22 13:39:36 +02:00
# To explicitly disable a set of modules, set USE_<foo>=none
# (e.g. the literal string none), which won't match any of the
2019-08-07 22:37:41 +02:00
# modules but is handled specially.
2020-06-22 13:39:36 +02:00
#
# The following USE_* functionalities are available:
# - *services* picks one of the two service-configuration modules,
# for either systemd or openrc. This defaults to empty so that
# **both** modules are available.
2022-02-08 16:18:47 +01:00
set(USE_services "" CACHE STRING "Select the services module to use")
2018-06-07 13:16:57 +02:00
### Calamares application info
#
2022-02-08 16:18:47 +01:00
set(CALAMARES_ORGANIZATION_NAME "Calamares")
set(CALAMARES_ORGANIZATION_DOMAIN "github.com/calamares")
set(CALAMARES_APPLICATION_NAME "Calamares")
set(CALAMARES_DESCRIPTION_SUMMARY "The distribution-independent installer framework")
2018-06-07 13:16:57 +02:00
2018-06-07 13:26:22 +02:00
### Transifex (languages) info
#
# complete = 100% translated,
# good = nearly complete (use own judgement, right now >= 75%)
2019-01-24 08:24:08 -05:00
# ok = incomplete (more than 25% untranslated, at least 5% translated),
2019-06-18 11:44:19 +02:00
# incomplete = <5% translated, placeholder in tx; these are not included.
2018-06-07 13:26:22 +02:00
#
# Language en (source language) is added later. It isn't listed in
# Transifex either. Get the list of languages and their status
2019-01-24 08:24:08 -05:00
# from https://transifex.com/calamares/calamares/ , or (preferably)
# use ci/txstats.py to automatically check.
2018-06-07 13:26:22 +02:00
#
# When adding a new language, take care that it is properly loaded
# by the translation framework. Languages with alternate scripts
# (sr@latin in particular) may need special handling in CalamaresUtils.cpp.
#
2019-08-05 18:24:31 +02:00
# NOTE: move eo (Esperanto) to _ok once Qt can actually create a
2020-08-04 12:37:46 +02:00
# locale for it. (Qt 5.12.2 can, see Translation Status section).
# NOTE: move ie (Interlingue) to _ok once Qt supports it.
# NOTE: update these lines by running `txstats.py`, or for full automation
# `txstats.py -e`. See also
2019-08-02 09:40:25 +02:00
#
2021-12-18 00:38:58 +01:00
# Total 74 languages
2022-04-07 21:51:39 +02:00
set( _tx_complete az az_AZ ca es fi_FI he hi hr ja lt pt_BR pt_PT
sq sv uk zh_TW )
set( _tx_good as be ca@valencia cs_CZ da de fa fr fur it_IT ko ml
nl ru si sk tg tr_TR vi zh_CN )
set( _tx_ok ar ast bg bn el en_GB es_MX et eu gl hu id is mr nb oc
pl ro sl sr sr@latin th )
2022-03-29 00:26:21 +02:00
set( _tx_incomplete eo es_PR gu ie ja-Hira kk kn lo lv mk ne_NP
ta_IN te ur zh zh_HK )
2018-06-07 13:26:22 +02:00
2018-06-07 13:39:28 +02:00
### Required versions
#
# See DEPENDENCIES section below.
2022-02-08 16:18:47 +01:00
set(QT_VERSION 5.15.0)
set(YAMLCPP_VERSION 0.5.1)
set(ECM_VERSION 5.18)
set(PYTHONLIBS_VERSION 3.6)
2022-04-25 14:36:16 +02:00
set(BOOSTPYTHON_VERSION 1.72.0)
2018-06-07 13:39:28 +02:00
2018-06-07 13:16:57 +02:00
### CMAKE SETUP
#
2022-02-08 16:18:47 +01:00
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
2017-06-12 05:23:34 -04:00
2019-08-05 18:24:31 +02:00
# Enable IN_LIST
2022-02-08 16:18:47 +01:00
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
2019-08-05 18:24:31 +02:00
endif()
2020-03-18 10:25:16 +01:00
# Let ``AUTOMOC`` and ``AUTOUIC`` process ``GENERATED`` files.
2022-02-08 16:18:47 +01:00
if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
2017-11-23 17:32:29 +01:00
endif()
2020-03-18 10:25:16 +01:00
# Recognize more macros to trigger automoc
2017-11-23 13:28:21 +01:00
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
2022-02-08 16:18:47 +01:00
list(
APPEND
CMAKE_AUTOMOC_MACRO_NAMES
2017-11-23 13:28:21 +01:00
"K_PLUGIN_FACTORY_WITH_JSON"
"K_EXPORT_PLASMA_DATAENGINE_WITH_JSON"
"K_EXPORT_PLASMA_RUNNER"
)
endif()
2020-06-09 23:25:17 +02:00
# CMake Modules
2022-02-08 16:18:47 +01:00
include(CMakePackageConfigHelpers)
include(CTest)
include(FeatureSummary)
2020-06-09 23:25:17 +02:00
# Calamares Modules
2022-02-08 16:18:47 +01:00
include(CMakeColors)
2018-04-23 10:47:25 -04:00
2018-06-07 13:16:57 +02:00
### C++ SETUP
#
2022-02-08 16:18:47 +01:00
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
2020-10-24 12:32:07 +02:00
2022-02-08 16:18:47 +01:00
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
2020-10-24 12:32:07 +02:00
2022-02-08 16:18:47 +01:00
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--fatal-warnings")
2020-10-24 12:32:07 +02:00
2021-03-29 10:15:29 +02:00
# If no build type is set, pick a reasonable one
2022-02-08 16:18:47 +01:00
if(NOT CMAKE_BUILD_TYPE)
if(CALAMARES_RELEASE_MODE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
2021-03-29 10:15:29 +02:00
else()
2022-02-08 16:18:47 +01:00
set(CMAKE_BUILD_TYPE "Debug")
2021-03-29 10:15:29 +02:00
endif()
endif()
2022-02-08 16:18:47 +01:00
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Found Clang ${CMAKE_CXX_COMPILER_VERSION}, setting up Clang-specific compiler flags.")
2015-06-04 02:27:46 +02:00
2017-09-17 07:01:59 -04:00
# Clang warnings: doing *everything* is counter-productive, since it warns
# about things which we can't fix (e.g. C++98 incompatibilities, but
2020-10-24 12:32:07 +02:00
# Calamares is C++17).
2022-02-08 16:18:47 +01:00
foreach(
CLANG_WARNINGS
2017-09-17 07:01:59 -04:00
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-undefined-reinterpret-cast
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-missing-prototypes
-Wno-documentation-unknown-command
2019-04-30 17:08:12 +02:00
-Wno-unknown-warning-option
2017-09-17 07:01:59 -04:00
)
2022-02-08 16:18:47 +01:00
string(APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}")
2017-09-17 07:01:59 -04:00
endforeach()
2021-03-01 16:47:47 +01:00
# The dwarf-debugging flags are slightly different, too
2022-02-08 16:18:47 +01:00
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -gdwarf")
string(APPEND CMAKE_C_FLAGS_DEBUG " -gdwarf")
2021-03-01 16:47:47 +01:00
2017-09-19 16:46:55 +02:00
# Third-party code where we don't care so much about compiler warnings
# (because it's uncomfortable to patch) get different flags; use
2017-09-21 04:53:09 -04:00
# mark_thirdparty_code( <file> [<file>...] )
2017-09-19 16:46:55 +02:00
# to switch off warnings for those sources.
2022-02-08 16:18:47 +01:00
set(SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything")
2015-06-04 02:27:46 +02:00
2022-02-08 16:18:47 +01:00
set(CMAKE_TOOLCHAIN_PREFIX "llvm-")
2015-06-04 02:27:46 +02:00
2020-01-07 11:20:45 +01:00
# The path prefix is only relevant for CMake 3.16 and later, fixes #1286
2022-02-08 16:18:47 +01:00
set(CMAKE_AUTOMOC_PATH_PREFIX OFF)
set(CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h")
set(CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h)
2015-06-04 02:27:46 +02:00
else()
2022-02-08 16:18:47 +01:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual")
2017-09-19 16:46:55 +02:00
2022-02-08 16:18:47 +01:00
set(SUPPRESS_3RDPARTY_WARNINGS "")
2015-06-04 02:27:46 +02:00
endif()
2014-06-25 19:12:21 +02:00
2017-10-12 12:33:03 -03:00
# Use mark_thirdparty_code() to reduce warnings from the compiler
# on code that we're not going to fix. Call this with a list of files.
2017-09-21 04:53:09 -04:00
macro(mark_thirdparty_code)
2022-02-08 16:18:47 +01:00
set_source_files_properties(
${ARGV}
PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" COMPILE_DEFINITIONS "THIRDPARTY"
2017-09-21 04:53:09 -04:00
)
endmacro()
2022-02-08 16:18:47 +01:00
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
message(STATUS "Found GNU g++ ${CMAKE_CXX_COMPILER_VERSION}, enabling colorized error messages.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto")
2014-06-25 19:12:21 +02:00
endif()
endif()
2021-03-28 18:46:39 +02:00
# API that was deprecated before Qt 5.15 causes a compile error
2022-02-08 16:18:47 +01:00
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050f00)
2014-08-25 14:21:10 +02:00
2018-06-07 13:39:28 +02:00
### DEPENDENCIES
#
2022-02-08 16:18:47 +01:00
find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Concurrent Core Gui LinguistTools Network Svg Widgets)
if(WITH_QML)
find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Quick QuickWidgets)
2020-05-14 15:54:19 +02:00
endif()
2019-08-08 14:06:33 +02:00
# Optional Qt parts
2022-02-08 16:18:47 +01:00
find_package(Qt5DBus CONFIG)
2019-08-05 18:24:31 +02:00
2022-02-08 16:18:47 +01:00
find_package(YAMLCPP ${YAMLCPP_VERSION} REQUIRED)
if(INSTALL_POLKIT)
find_package(PolkitQt5-1 REQUIRED)
2018-06-07 14:17:43 +02:00
else()
# Find it anyway, for dependencies-reporting
2022-02-08 16:18:47 +01:00
find_package(PolkitQt5-1)
2018-06-07 14:17:43 +02:00
endif()
set_package_properties(
2022-02-08 16:18:47 +01:00
PolkitQt5-1
PROPERTIES
2018-06-07 14:17:43 +02:00
DESCRIPTION "Qt5 support for Polkit"
URL "https://cgit.kde.org/polkit-qt-1.git"
PURPOSE "PolkitQt5-1 helps with installing Polkit configuration"
)
2014-06-04 16:35:26 +02:00
2017-10-31 08:25:57 -04:00
# Find ECM once, and add it to the module search path; Calamares
# modules that need ECM can do
# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE),
# no need to mess with the module path after.
find_package(ECM ${ECM_VERSION} NO_MODULE)
2022-02-08 16:18:47 +01:00
if(ECM_FOUND)
2017-10-31 08:25:57 -04:00
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
2022-02-08 16:18:47 +01:00
if(BUILD_TESTING)
2018-10-05 09:19:25 -04:00
# ECM implies that we can build the tests, too
2022-02-08 16:18:47 +01:00
find_package(Qt5 COMPONENTS Test REQUIRED)
include(ECMAddTests)
2018-10-05 09:19:25 -04:00
endif()
2019-04-30 13:38:46 +02:00
include(KDEInstallDirs)
2017-10-31 08:25:57 -04:00
endif()
2022-02-08 16:18:47 +01:00
find_package(KF5 QUIET COMPONENTS CoreAddons Crash DBusAddons)
2019-08-08 14:06:33 +02:00
set_package_properties(
2022-02-08 16:18:47 +01:00
KF5::CoreAddons
PROPERTIES
2019-08-08 14:06:33 +02:00
TYPE REQUIRED
DESCRIPTION "Classes built on QtCore for About Data"
URL "https://api.kde.org/frameworks/kcoreaddons/"
PURPOSE "About Calamares"
)
2021-09-16 13:37:38 +02:00
set_package_properties(
2022-02-08 16:18:47 +01:00
KF5::DBusAddons
PROPERTIES
2021-09-16 13:37:38 +02:00
TYPE REQUIRED
DESCRIPTION "Classes for DBus activation"
URL "https://api.kde.org/frameworks/dbusaddons/"
PURPOSE "Unique instance of Calamares"
)
2022-02-08 16:18:47 +01:00
if(NOT KF5Crash_FOUND)
if(BUILD_KF5Crash)
2021-11-30 11:49:43 +01:00
message(WARNING "BUILD_KF5Crash is set, but KF5::Crash is not available.")
2020-05-08 15:22:15 +02:00
endif()
2022-02-08 16:18:47 +01:00
set(BUILD_KF5Crash OFF)
2016-03-16 12:18:35 +01:00
endif()
2022-04-25 14:36:16 +02:00
find_package(Python ${PYTHONLIBS_VERSION} COMPONENTS Interpreter Development)
2020-06-16 14:06:26 +02:00
set_package_properties(
2022-04-25 14:36:16 +02:00
Python
2022-02-08 16:18:47 +01:00
PROPERTIES
2022-04-25 14:36:16 +02:00
DESCRIPTION "Python3 interpreter."
2020-06-16 14:06:26 +02:00
URL "https://python.org"
2022-04-25 14:36:16 +02:00
PURPOSE "Python3 interpreter for certain tests."
2020-06-16 14:06:26 +02:00
)
2020-07-29 10:58:07 +02:00
2022-02-08 16:18:47 +01:00
set(_schema_explanation "")
2022-04-25 14:36:16 +02:00
if(Python_Interpreter_FOUND)
2022-02-08 16:18:47 +01:00
if(BUILD_SCHEMA_TESTING)
2020-06-16 17:36:59 +02:00
# The configuration validator script has some dependencies,
# and if they are not installed, don't run. If errors out
# with exit(1) on missing dependencies.
2022-02-08 16:18:47 +01:00
if(CALAMARES_CONFIGVALIDATOR_CHECKED)
set(_validator_deps ${CALAMARES_CONFIGVALIDATOR_RESULT})
2020-07-29 10:58:07 +02:00
else()
2022-02-08 16:18:47 +01:00
exec_program(
2022-04-25 14:36:16 +02:00
Python::Interpreter
2022-02-08 16:18:47 +01:00
ARGS
"${CMAKE_SOURCE_DIR}/ci/configvalidator.py"
-x
RETURN_VALUE
_validator_deps
)
set(CALAMARES_CONFIGVALIDATOR_CHECKED TRUE CACHE INTERNAL "Dependencies for configvalidator checked")
set(CALAMARES_CONFIGVALIDATOR_RESULT ${_validator_deps}
CACHE INTERNAL "Result of configvalidator dependency check"
)
2020-07-29 10:58:07 +02:00
endif()
2020-06-16 17:36:59 +02:00
# It should never succeed, but only returns 1 when the imports fail
2022-02-08 16:18:47 +01:00
if(_validator_deps EQUAL 1)
set(_schema_explanation " Missing dependencies for configvalidator.py.")
set(BUILD_SCHEMA_TESTING OFF)
2020-06-16 17:36:59 +02:00
endif()
endif()
else()
# Can't run schema tests without Python3.
2022-02-08 16:18:47 +01:00
set(_schema_explanation " Missing Python3.")
set(BUILD_SCHEMA_TESTING OFF)
2020-06-16 14:06:26 +02:00
endif()
2022-02-08 16:18:47 +01:00
add_feature_info(yaml-schema BUILD_SCHEMA_TESTING "Validate YAML (config files) with schema.${_schema_explanation}")
2020-07-29 10:58:07 +02:00
2022-04-25 14:36:16 +02:00
if(Python_Development_FOUND)
find_package( Boost ${BOOSTPYTHON_VERSION} COMPONENTS python )
2022-02-08 16:18:47 +01:00
set_package_properties(Boost PROPERTIES PURPOSE "Boost.Python is used for Python job modules.")
2015-02-14 22:45:10 +01:00
endif()
2014-07-17 14:54:13 +02:00
2022-04-25 14:36:16 +02:00
if(NOT Python_Development_FOUND OR NOT Boost_FOUND)
2018-01-15 22:27:56 +01:00
message(STATUS "Disabling Boost::Python modules")
2022-02-08 16:18:47 +01:00
set(WITH_PYTHON OFF)
2014-07-16 15:52:54 +02:00
endif()
2020-06-12 11:35:23 +02:00
# Now we know the state of the ABI-options, copy them into "Calamares_"
# prefixed variables, to match how the variables would-be-named
# when building out-of-tree.
set(Calamares_WITH_PYTHON ${WITH_PYTHON})
set(Calamares_WITH_QML ${WITH_QML})
2018-03-27 11:10:14 -04:00
### Transifex Translation status
#
2021-09-07 16:31:24 +02:00
# Construct language lists for use. This massages the language lists
# for use with older Qt (which does not support Esperanto) and checks
# for some obvious error. The actual work of compiling translations
# is done in the lang/ directory.
2018-04-19 09:10:13 -04:00
#
2022-02-08 16:18:47 +01:00
if(Qt5_VERSION VERSION_GREATER 5.12.1)
2020-08-04 12:37:46 +02:00
# At least Qt 5.12.2 seems to support Esperanto in QLocale
2022-02-08 16:18:47 +01:00
if("eo" IN_LIST _tx_incomplete)
2020-08-04 12:37:46 +02:00
message(STATUS "Esperanto support since Qt 5.12.2, enabling Esperanto locale")
2022-02-08 16:18:47 +01:00
list(REMOVE_ITEM _tx_incomplete "eo")
list(APPEND _tx_ok "eo")
2020-08-04 12:37:46 +02:00
endif()
endif()
2022-02-08 16:18:47 +01:00
set(curr_tx ${_tx_complete} ${_tx_good} ${_tx_ok} ${_tx_incomplete})
set(tx_errors OFF)
if(curr_tx)
2018-05-10 08:53:29 -04:00
# New in list
2022-02-08 16:18:47 +01:00
foreach(l ${curr_tx})
set(p_l "lang/calamares_${l}.ts")
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${p_l})
2018-05-10 08:53:29 -04:00
message(WARNING "Language ${l} has no .ts file yet.")
2022-02-08 16:18:47 +01:00
set(tx_errors ON)
2018-05-10 08:53:29 -04:00
endif()
endforeach()
2022-02-08 16:18:47 +01:00
unset(p_l)
unset(l)
2018-05-10 08:53:29 -04:00
endif()
2022-02-08 16:18:47 +01:00
unset(curr_tx)
if(tx_errors)
message(FATAL_ERROR "Translation warnings, see above.")
2018-12-13 14:50:33 +01:00
endif()
2018-03-27 11:10:14 -04:00
2022-02-08 16:18:47 +01:00
set(CALAMARES_TRANSLATION_LANGUAGES en ${_tx_complete} ${_tx_good} ${_tx_ok})
list(SORT CALAMARES_TRANSLATION_LANGUAGES)
2014-06-04 16:35:26 +02:00
2022-02-08 16:18:47 +01:00
add_subdirectory(lang) # i18n tools
2014-06-04 16:35:26 +02:00
2017-08-23 09:31:15 -04:00
### Example Distro
#
# For testing purposes Calamares includes a very, very, limited sample
# distro called "Generic". The root filesystem of "Generic" lives in
# data/example-root and can be squashed up as part of the build, so
# that a pure-upstream run of ./calamares -d from the build directory
# (with all the default settings and configurations) can actually
# do an complete example run.
#
# Some binaries from the build host (e.g. /bin and /lib) are also
# squashed into the example filesystem.
#
# To build the example distro (for use by the default, example,
# unsquashfs module), build the target 'example-distro', eg.:
#
# make example-distro
#
2022-02-08 16:18:47 +01:00
find_program(mksquashfs_PROGRAM mksquashfs)
if(mksquashfs_PROGRAM)
set(mksquashfs_FOUND ON)
set(src_fs ${CMAKE_SOURCE_DIR}/data/example-root/)
set(dst_fs ${CMAKE_BINARY_DIR}/example.sqfs)
if(EXISTS ${src_fs})
2017-08-23 09:31:15 -04:00
# based on the build host. If /lib64 exists, assume it is needed.
2017-09-23 03:02:27 -04:00
# Collect directories needed for a minimal binary distro,
2017-08-23 09:31:15 -04:00
# Note that the last path component is added to the root, so
# if you add /usr/sbin here, it will be put into /sbin_1.
# Add such paths to /etc/profile under ${src_fs}.
2022-02-08 16:18:47 +01:00
set(candidate_fs /sbin /bin /lib /lib64)
set(host_fs "")
foreach(c_fs ${candidate_fs})
if(EXISTS ${c_fs})
list(APPEND host_fs ${c_fs})
2017-08-23 09:31:15 -04:00
endif()
endforeach()
add_custom_command(
OUTPUT ${dst_fs}
COMMAND ${mksquashfs_PROGRAM} ${src_fs} ${dst_fs} -all-root
COMMAND ${mksquashfs_PROGRAM} ${host_fs} ${dst_fs} -all-root
)
add_custom_target(example-distro DEPENDS ${dst_fs})
endif()
2017-09-13 08:32:22 -04:00
else()
2022-02-08 16:18:47 +01:00
set(mksquashfs_FOUND OFF)
2017-08-23 09:31:15 -04:00
endif()
2017-09-13 08:32:22 -04:00
# Doesn't list mksquashfs as an optional dep, though, because it
# hasn't been sent through the find_package() scheme.
2017-10-30 11:43:14 -04:00
#
# "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html"
2022-02-08 16:18:47 +01:00
add_feature_info(ExampleDistro ${mksquashfs_FOUND} "Create example-distro target.")
2018-06-07 13:43:44 +02:00
### CALAMARES PROPER
#
2022-02-08 16:18:47 +01:00
set(CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH})
2021-03-29 10:08:20 +02:00
# In rare cases we have hotfix-releases with a tweak
2022-02-08 16:18:47 +01:00
if(CALAMARES_VERSION_TWEAK)
set(CALAMARES_VERSION "${CALAMARES_VERSION}.${CALAMARES_VERSION_TWEAK}")
2021-03-29 10:08:20 +02:00
endif()
2022-02-08 16:18:47 +01:00
set(CALAMARES_VERSION_SHORT "${CALAMARES_VERSION}")
2021-03-29 10:08:20 +02:00
# Additional info for non-release builds. The "extended" version information
# with date and git information (commit, dirty status) is used only
# by CalamaresVersionX.h, which is included by consumers that need a full
# version number with all that information; normal consumers can include
# CalamaresVersion.h with more stable numbers.
2022-02-08 16:18:47 +01:00
if(NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
include(ExtendedVersion)
2021-03-29 10:08:20 +02:00
extend_version( "${CALAMARES_VERSION}" OFF CALAMARES_VERSION_SHORT CALAMARES_VERSION )
endif()
2018-06-07 13:43:44 +02:00
2022-04-20 13:01:39 +02:00
# Special define for RC (e.g. not-a-release) builds.
# This is consumed via the CalamaresConfig.h header.
if(NOT CALAMARES_RELEASE_MODE)
set(CALAMARES_VERSION_RC 1)
2018-06-28 05:19:32 -04:00
endif()
2018-06-07 13:43:44 +02:00
# enforce using constBegin, constEnd for const-iterators
2022-02-08 16:18:47 +01:00
add_definitions(-DQT_STRICT_ITERATORS -DQT_SHARED -DQT_SHAREDPOINTER_TRACK_POINTERS)
2018-06-07 13:43:44 +02:00
# set paths
2022-02-08 16:18:47 +01:00
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
2018-06-07 13:43:44 +02:00
# Better default installation paths: GNUInstallDirs defines
# CMAKE_INSTALL_FULL_SYSCONFDIR to be CMAKE_INSTALL_PREFIX/etc by default
# but we really want /etc
2022-02-08 16:18:47 +01:00
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
2018-06-07 13:43:44 +02:00
endif()
# make predefined install dirs available everywhere
2022-02-08 16:18:47 +01:00
include(GNUInstallDirs)
2018-06-07 13:43:44 +02:00
2020-06-10 01:34:18 +02:00
# This is used by CalamaresAddLibrary; once Calamares is installed,
# the CalamaresConfig.cmake module sets this variable to the IMPORTED
# libraries for Calamares.
2022-02-08 16:18:47 +01:00
set(Calamares_LIBRARIES calamares)
2018-06-07 13:43:44 +02:00
2022-02-08 16:18:47 +01:00
add_subdirectory(src)
2014-06-04 16:35:26 +02:00
2017-09-23 03:02:27 -04:00
add_feature_info(Python ${WITH_PYTHON} "Python job modules")
2021-11-30 11:49:43 +01:00
add_feature_info(Qml ${WITH_QML} "QML UI support")
2017-09-23 03:02:27 -04:00
add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration")
2021-11-30 11:49:43 +01:00
add_feature_info(Polkit ${INSTALL_POLKIT} "Install Polkit files")
add_feature_info(KCrash ${BUILD_KF5Crash} "Crash dumps via KCrash")
2014-07-16 15:52:54 +02:00
2020-06-10 01:34:18 +02:00
### CMake infrastructure installation
#
#
2022-02-08 16:18:47 +01:00
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH "Installation directory for CMake files")
set(CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}")
2016-02-24 15:00:05 +01:00
2022-02-08 16:18:47 +01:00
export(PACKAGE Calamares)
2020-06-09 23:58:58 +02:00
configure_package_config_file(
"CalamaresConfig.cmake.in"
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
2022-02-08 16:18:47 +01:00
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_DATADIR
2020-06-09 23:58:58 +02:00
)
2020-06-09 23:38:31 +02:00
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
2022-02-08 16:18:47 +01:00
install(EXPORT Calamares DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" FILE "CalamaresTargets.cmake" NAMESPACE Calamares::)
2020-06-09 23:38:31 +02:00
2014-06-04 16:35:26 +02:00
# Install the cmake files
install(
FILES
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
2017-08-08 23:59:15 +09:00
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
2020-02-17 12:02:53 +01:00
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddTest.cmake"
2018-02-14 04:55:21 -05:00
"CMakeModules/CalamaresAddTranslations.cmake"
2019-04-17 12:19:12 +02:00
"CMakeModules/CalamaresAutomoc.cmake"
2021-03-22 15:55:30 +01:00
"CMakeModules/CalamaresCheckModuleSelection.cmake"
2018-02-14 04:55:21 -05:00
"CMakeModules/CMakeColors.cmake"
2020-06-10 02:27:57 +02:00
"CMakeModules/FindYAMLCPP.cmake"
2022-02-08 16:18:47 +01:00
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
2014-06-04 16:35:26 +02:00
)
2020-06-10 01:42:11 +02:00
### Miscellaneous installs
#
#
2022-02-08 16:18:47 +01:00
if(INSTALL_CONFIG)
install(FILES settings.conf DESTINATION share/calamares)
2016-11-21 00:32:04 +00:00
endif()
2014-11-04 17:57:44 +01:00
2022-02-08 16:18:47 +01:00
if(INSTALL_POLKIT)
install(FILES com.github.calamares.calamares.policy DESTINATION "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}")
2018-06-07 14:17:43 +02:00
endif()
2014-11-04 18:09:30 +01:00
2022-02-08 16:18:47 +01:00
if(INSTALL_COMPLETION)
if(NOT CMAKE_INSTALL_BASHCOMPLETIONDIR)
set(CMAKE_INSTALL_BASHCOMPLETIONDIR "${CMAKE_INSTALL_DATADIR}/bash-completion/completions")
2020-08-07 10:43:29 +02:00
endif()
2022-02-08 16:18:47 +01:00
install(FILES ${CMAKE_SOURCE_DIR}/data/completion/bash/calamares DESTINATION "${CMAKE_INSTALL_BASHCOMPLETIONDIR}")
2020-08-07 10:43:29 +02:00
endif()
2022-02-08 16:18:47 +01:00
install(FILES calamares.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
2015-11-12 15:27:01 +01:00
2022-02-08 16:18:47 +01:00
install(FILES man/calamares.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
2017-06-07 03:03:29 -04:00
2015-11-12 15:27:01 +01:00
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
2022-02-08 16:18:47 +01:00
IMMEDIATE
@ONLY
2015-11-12 15:27:01 +01:00
)
2022-02-08 16:18:47 +01:00
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
2018-06-07 13:43:44 +02:00
### CMAKE SUMMARY REPORT
#
2022-02-08 16:18:47 +01:00
get_directory_property(SKIPPED_MODULES DIRECTORY src/modules DEFINITION LIST_SKIPPED_MODULES)
2018-06-07 13:43:44 +02:00
calamares_explain_skipped_modules( ${SKIPPED_MODULES} )
2019-08-08 14:06:33 +02:00
2022-02-08 16:18:47 +01:00
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "The following features have been disabled:" QUIET_ON_EMPTY)
2019-08-08 14:06:33 +02:00
feature_summary(
WHAT OPTIONAL_PACKAGES_NOT_FOUND
DESCRIPTION "The following OPTIONAL packages were not found:"
QUIET_ON_EMPTY
)
feature_summary(
WHAT REQUIRED_PACKAGES_NOT_FOUND
FATAL_ON_MISSING_REQUIRED_PACKAGES
DESCRIPTION "The following REQUIRED packages were not found:"
QUIET_ON_EMPTY
)
2021-03-01 16:37:17 +01:00
### PACKAGING
#
# Note: most distro's will do distro-specific packaging rather than
# using CPack, and this duplicates information in the AppStream, too.
# TODO:3.3 With newer CMake, move HOMEPAGE_URL to the project()call
set(CPACK_PACKAGE_VENDOR calamares)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Linux system installer")
2022-02-08 16:18:47 +01:00
set(CPACK_PACKAGE_DESCRIPTION
"Calamares is a Linux system installer, intended for Linux distributions to use on their ISOs and other bootable media to install the distribution to the end-user's computer. Calamares can also be used as an OEM configuration tool. It is modular, extensible and highly-configurable for Linux distributions from all five major Linux families."
)
2021-03-01 16:37:17 +01:00
set(CPACK_PACKAGE_HOMEPAGE_URL "https://calamares.io")
set(CPACK_PACKAGE_ICON "data/images/squid.png")
include(CPack)