2020-08-25 16:05:56 +02:00
|
|
|
# === This file is part of Calamares - <https://calamares.io> ===
|
2020-06-10 00:31:13 +02:00
|
|
|
#
|
2020-05-30 16:15:03 +02:00
|
|
|
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
2020-08-26 00:24:52 +02:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
2020-05-30 16:15:03 +02:00
|
|
|
#
|
2020-08-07 00:45:36 +02:00
|
|
|
|
2020-05-30 16:15:03 +02:00
|
|
|
#
|
2019-05-07 13:02:55 +02:00
|
|
|
# libcalamares is the non-GUI part of Calamares, which includes handling
|
2020-08-07 00:45:36 +02:00
|
|
|
# translations, configurations, logging, utilities, global storage, and
|
|
|
|
# (non-GUI) jobs.
|
|
|
|
#
|
2019-05-07 13:02:55 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
add_definitions(-DDLLEXPORT_PRO)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
2014-06-04 16:35:26 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CalamaresVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CalamaresVersionX.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersionX.h)
|
2014-06-04 16:35:26 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
set(OPTIONAL_PRIVATE_LIBRARIES "")
|
|
|
|
set(OPTIONAL_PUBLIC_LIBRARIES "")
|
2019-05-10 14:04:36 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
set(libSources
|
2016-09-25 03:20:50 +02:00
|
|
|
CppJob.cpp
|
2014-07-21 17:08:06 +02:00
|
|
|
GlobalStorage.cpp
|
2014-06-27 15:34:05 +02:00
|
|
|
Job.cpp
|
2019-03-17 18:25:35 +01:00
|
|
|
JobExample.cpp
|
2014-06-04 16:35:26 +02:00
|
|
|
JobQueue.cpp
|
2014-07-10 12:08:43 +02:00
|
|
|
ProcessJob.cpp
|
2018-04-05 10:31:13 +02:00
|
|
|
Settings.cpp
|
2019-05-10 14:04:36 +02:00
|
|
|
# GeoIP services
|
|
|
|
geoip/Interface.cpp
|
2020-06-03 15:03:19 +02:00
|
|
|
geoip/GeoIPFixed.cpp
|
2019-05-10 14:04:36 +02:00
|
|
|
geoip/GeoIPJSON.cpp
|
|
|
|
geoip/Handler.cpp
|
2019-05-10 12:45:54 +02:00
|
|
|
# Locale-data service
|
2020-09-03 20:15:28 +02:00
|
|
|
locale/Global.cpp
|
2019-05-10 12:45:54 +02:00
|
|
|
locale/Lookup.cpp
|
2019-11-26 11:19:30 +01:00
|
|
|
locale/TimeZone.cpp
|
2019-08-04 22:56:41 +02:00
|
|
|
locale/TranslatableConfiguration.cpp
|
2020-08-05 17:52:41 +02:00
|
|
|
locale/TranslatableString.cpp
|
2021-07-26 11:38:15 +02:00
|
|
|
locale/Translation.cpp
|
|
|
|
locale/TranslationsModel.cpp
|
2020-01-24 22:53:14 +01:00
|
|
|
# Modules
|
2021-03-12 13:49:37 +01:00
|
|
|
modulesystem/Config.cpp
|
2020-08-11 20:15:14 +02:00
|
|
|
modulesystem/Descriptor.cpp
|
2020-01-24 22:53:14 +01:00
|
|
|
modulesystem/InstanceKey.cpp
|
2020-03-31 22:56:42 +02:00
|
|
|
modulesystem/Module.cpp
|
2021-03-12 13:16:36 +01:00
|
|
|
modulesystem/Preset.cpp
|
2020-03-31 23:13:13 +02:00
|
|
|
modulesystem/RequirementsChecker.cpp
|
2020-04-02 21:33:07 +02:00
|
|
|
modulesystem/RequirementsModel.cpp
|
2019-08-20 15:25:37 +02:00
|
|
|
# Network service
|
|
|
|
network/Manager.cpp
|
2021-03-16 13:50:15 +01:00
|
|
|
# Packages service
|
|
|
|
packages/Globals.cpp
|
2019-05-10 12:45:54 +02:00
|
|
|
# Partition service
|
2021-02-08 11:13:49 +01:00
|
|
|
partition/Global.cpp
|
2019-06-20 11:35:46 +02:00
|
|
|
partition/Mount.cpp
|
2019-05-08 19:23:07 +02:00
|
|
|
partition/PartitionSize.cpp
|
2019-06-19 12:14:49 +02:00
|
|
|
partition/Sync.cpp
|
2019-05-10 12:45:54 +02:00
|
|
|
# Utility service
|
2014-07-29 20:18:02 +02:00
|
|
|
utils/CalamaresUtilsSystem.cpp
|
2018-01-15 11:59:44 +01:00
|
|
|
utils/CommandList.cpp
|
2019-04-29 12:22:24 +02:00
|
|
|
utils/Dirs.cpp
|
2020-01-29 16:03:50 +01:00
|
|
|
utils/Entropy.cpp
|
2014-06-18 18:05:04 +02:00
|
|
|
utils/Logger.cpp
|
2020-06-22 22:32:47 +02:00
|
|
|
utils/Permissions.cpp
|
2019-08-12 15:52:59 +02:00
|
|
|
utils/PluginFactory.cpp
|
2014-11-11 12:42:37 +01:00
|
|
|
utils/Retranslator.cpp
|
2021-10-04 00:10:44 +02:00
|
|
|
utils/Runner.cpp
|
2019-04-29 12:48:01 +02:00
|
|
|
utils/String.cpp
|
2019-07-02 22:08:36 +02:00
|
|
|
utils/UMask.cpp
|
2019-04-29 11:36:04 +02:00
|
|
|
utils/Variant.cpp
|
2019-04-29 12:04:55 +02:00
|
|
|
utils/Yaml.cpp
|
2014-06-04 16:35:26 +02:00
|
|
|
)
|
2014-07-16 16:07:32 +02:00
|
|
|
|
2020-12-22 16:05:20 +01:00
|
|
|
### OPTIONAL Automount support (requires dbus)
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
if(Qt5DBus_FOUND)
|
|
|
|
list(APPEND libSources partition/AutoMount.cpp)
|
|
|
|
list(APPEND OPTIONAL_PRIVATE_LIBRARIES Qt5::DBus)
|
2020-12-22 16:05:20 +01:00
|
|
|
endif()
|
|
|
|
|
2019-05-10 14:04:36 +02:00
|
|
|
### OPTIONAL Python support
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
if(WITH_PYTHON)
|
|
|
|
list(APPEND libSources PythonHelper.cpp PythonJob.cpp PythonJobApi.cpp)
|
2014-07-16 16:07:32 +02:00
|
|
|
|
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
|
|
|
link_directories(${PYTHON_LIBRARIES})
|
|
|
|
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
link_directories(${Boost_LIBRARY_DIRS})
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
list(APPEND OPTIONAL_PRIVATE_LIBRARIES ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
|
2014-07-16 16:07:32 +02:00
|
|
|
endif()
|
|
|
|
|
2019-05-10 14:04:36 +02:00
|
|
|
### OPTIONAL GeoIP XML support
|
|
|
|
#
|
|
|
|
#
|
2019-04-30 22:53:26 +02:00
|
|
|
find_package(Qt5 COMPONENTS Xml)
|
2022-02-08 16:13:40 +01:00
|
|
|
if(Qt5Xml_FOUND)
|
|
|
|
list(APPEND libSources geoip/GeoIPXML.cpp)
|
|
|
|
list(APPEND OPTIONAL_PUBLIC_LIBRARIES Qt5::Network Qt5::Xml)
|
2019-04-30 22:53:26 +02:00
|
|
|
endif()
|
|
|
|
|
2019-06-13 12:12:47 +02:00
|
|
|
### OPTIONAL KPMcore support
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
include(KPMcoreHelper)
|
2019-06-13 12:12:47 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
if(KPMcore_FOUND)
|
|
|
|
find_package(Qt5 REQUIRED DBus) # Needed for KPMCore
|
|
|
|
find_package(KF5 REQUIRED I18n WidgetsAddons) # Needed for KPMCore
|
2019-06-13 12:12:47 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
foreach(d ${KPMcore_API_DEFINITIONS})
|
|
|
|
add_definitions(-D${d})
|
2020-10-07 01:15:12 +02:00
|
|
|
endforeach()
|
2022-02-08 16:13:40 +01:00
|
|
|
include_directories(${KPMCORE_INCLUDE_DIR})
|
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
libSources
|
2019-06-13 14:55:43 +02:00
|
|
|
partition/FileSystem.cpp
|
2019-06-13 21:40:34 +02:00
|
|
|
partition/KPMManager.cpp
|
2019-06-13 12:12:47 +02:00
|
|
|
partition/PartitionIterator.cpp
|
2019-06-13 14:41:33 +02:00
|
|
|
partition/PartitionQuery.cpp
|
2019-06-13 12:12:47 +02:00
|
|
|
)
|
2022-02-08 16:13:40 +01:00
|
|
|
list(APPEND OPTIONAL_PRIVATE_LIBRARIES kpmcore)
|
2019-06-13 12:12:47 +02:00
|
|
|
endif()
|
|
|
|
|
2019-05-10 14:04:36 +02:00
|
|
|
### LIBRARY
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
add_library(calamares SHARED ${libSources})
|
|
|
|
set_target_properties(
|
|
|
|
calamares
|
2014-06-04 18:19:05 +02:00
|
|
|
PROPERTIES
|
2018-03-01 12:37:52 +01:00
|
|
|
VERSION ${CALAMARES_VERSION_SHORT}
|
|
|
|
SOVERSION ${CALAMARES_VERSION_SHORT}
|
2020-06-10 02:01:59 +02:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_INSTALL_FULL_INCLUDEDIR}/libcalamares
|
2014-06-04 16:35:26 +02:00
|
|
|
)
|
2019-04-17 12:19:12 +02:00
|
|
|
calamares_automoc( calamares )
|
2014-06-04 16:35:26 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
target_link_libraries(
|
|
|
|
calamares
|
|
|
|
LINK_PRIVATE ${OPTIONAL_PRIVATE_LIBRARIES}
|
|
|
|
LINK_PUBLIC yamlcpp::yamlcpp Qt5::Core ${OPTIONAL_PUBLIC_LIBRARIES}
|
2014-06-04 16:35:26 +02:00
|
|
|
)
|
|
|
|
|
2021-07-26 14:22:28 +02:00
|
|
|
add_library(Calamares::calamares ALIAS calamares)
|
|
|
|
|
2020-06-10 16:43:34 +02:00
|
|
|
### Installation
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
install(
|
|
|
|
TARGETS calamares
|
2020-06-10 00:31:13 +02:00
|
|
|
EXPORT Calamares
|
2022-02-08 16:13:40 +01:00
|
|
|
RUNTIME
|
|
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2014-06-04 16:35:26 +02:00
|
|
|
)
|
|
|
|
|
2018-03-01 12:37:52 +01:00
|
|
|
# Make symlink lib/calamares/libcalamares.so to lib/libcalamares.so.VERSION so
|
|
|
|
# lib/calamares can be used as module path for the Python interpreter.
|
2022-02-08 16:13:40 +01:00
|
|
|
install(
|
|
|
|
CODE
|
|
|
|
"
|
2018-03-01 12:37:52 +01:00
|
|
|
file( MAKE_DIRECTORY \"\$ENV{DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}/calamares\" )
|
|
|
|
execute_process( COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../libcalamares.so.${CALAMARES_VERSION_SHORT} libcalamares.so WORKING_DIRECTORY \"\$ENV{DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}/calamares\" )
|
2022-02-08 16:13:40 +01:00
|
|
|
"
|
|
|
|
)
|
2018-03-01 12:37:52 +01:00
|
|
|
|
2014-06-04 16:35:26 +02:00
|
|
|
# Install header files
|
2022-02-08 16:13:40 +01:00
|
|
|
file(GLOB rootHeaders "*.h")
|
2020-06-10 02:10:21 +02:00
|
|
|
install(
|
2022-02-08 16:13:40 +01:00
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h ${rootHeaders}
|
2020-06-10 02:10:21 +02:00
|
|
|
DESTINATION include/libcalamares
|
|
|
|
)
|
2020-06-10 16:43:34 +02:00
|
|
|
# Install each subdir-worth of header files
|
2022-02-08 16:13:40 +01:00
|
|
|
foreach(subdir geoip locale modulesystem network partition utils)
|
|
|
|
file(GLOB subdir_headers "${subdir}/*.h")
|
|
|
|
install(FILES ${subdir_headers} DESTINATION include/libcalamares/${subdir})
|
2020-06-10 02:10:21 +02:00
|
|
|
endforeach()
|
2019-05-10 14:04:36 +02:00
|
|
|
|
|
|
|
### TESTING
|
|
|
|
#
|
|
|
|
#
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamarestest SOURCES Tests.cpp)
|
2020-08-07 00:45:36 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamaresgeoiptest SOURCES geoip/GeoIPTests.cpp ${geoip_src})
|
2020-02-07 13:49:06 +01:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
function(calamares_qrc_translations basename)
|
|
|
|
set(NAME ${ARGV0})
|
|
|
|
set(options "")
|
|
|
|
set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE)
|
|
|
|
set(multiValueArgs LANGUAGES)
|
|
|
|
cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
2021-04-18 13:35:18 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
if(NOT _qrt_OUTPUT_VARIABLE)
|
|
|
|
set(_qrt_OUTPUT_VARIABLE "qrc_translations_${basename}")
|
2021-04-18 13:35:18 +02:00
|
|
|
endif()
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc)
|
|
|
|
set(translations_qrc_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${basename}.cxx)
|
2021-04-18 13:35:18 +02:00
|
|
|
|
|
|
|
# Must use this variable name because of the @ substitution
|
2022-02-08 16:13:40 +01:00
|
|
|
set(calamares_i18n_qrc_content "")
|
|
|
|
set(calamares_i18n_ts_filelist "")
|
|
|
|
foreach(lang ${_qrt_LANGUAGES})
|
|
|
|
string(APPEND calamares_i18n_qrc_content "<file>${basename}_${lang}.qm</file>")
|
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
calamares_i18n_ts_filelist
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts"
|
|
|
|
)
|
2021-04-18 13:35:18 +02:00
|
|
|
endforeach()
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY)
|
2021-04-18 13:35:18 +02:00
|
|
|
qt5_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 "${Qt5Core_RCC_EXECUTABLE}"
|
2022-02-08 16:13:40 +01:00
|
|
|
ARGS
|
|
|
|
${rcc_options}
|
|
|
|
--format-version
|
|
|
|
1
|
|
|
|
-name
|
|
|
|
${basename}
|
|
|
|
-o
|
|
|
|
${translations_qrc_outfile}
|
|
|
|
${translations_qrc_infile}
|
2021-04-18 13:35:18 +02:00
|
|
|
MAIN_DEPENDENCY ${translations_qrc_infile}
|
|
|
|
DEPENDS ${QM_FILES}
|
|
|
|
)
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE)
|
2021-04-18 13:35:18 +02:00
|
|
|
endfunction()
|
2021-04-18 13:19:55 +02:00
|
|
|
|
2021-04-18 13:35:18 +02:00
|
|
|
calamares_qrc_translations( localetest OUTPUT_VARIABLE localetest_qrc SUBDIRECTORY testdata LANGUAGES nl )
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamareslocaletest SOURCES locale/Tests.cpp ${localetest_qrc})
|
2020-02-07 13:49:06 +01:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamaresmodulesystemtest SOURCES modulesystem/Tests.cpp)
|
2020-08-11 20:19:00 +02:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamaresnetworktest SOURCES network/Tests.cpp)
|
2020-02-17 15:05:00 +01:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamarespackagestest SOURCES packages/Tests.cpp)
|
2021-03-16 13:50:15 +01:00
|
|
|
|
2020-02-17 15:05:00 +01:00
|
|
|
calamares_add_test(
|
|
|
|
libcalamarespartitiontest
|
2022-02-08 16:13:40 +01:00
|
|
|
SOURCES partition/Global.cpp partition/Tests.cpp
|
|
|
|
LIBRARIES ${OPTIONAL_PRIVATE_LIBRARIES}
|
2020-02-17 15:05:00 +01:00
|
|
|
)
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
if(KPMcore_FOUND)
|
2020-04-22 15:38:42 +02:00
|
|
|
calamares_add_test(
|
|
|
|
libcalamarespartitionkpmtest
|
2022-02-08 16:13:40 +01:00
|
|
|
SOURCES partition/KPMTests.cpp
|
|
|
|
LIBRARIES ${OPTIONAL_PRIVATE_LIBRARIES}
|
2020-04-22 15:38:42 +02:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamaresutilstest SOURCES utils/Tests.cpp utils/Runner.cpp)
|
2020-02-17 15:05:00 +01:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
calamares_add_test(libcalamaresutilspathstest SOURCES utils/TestPaths.cpp)
|
2019-04-30 22:53:26 +02:00
|
|
|
|
2020-04-22 15:38:42 +02:00
|
|
|
# This is not an actual test, it's a test / demo application
|
|
|
|
# for experimenting with GeoIP.
|
2022-02-08 16:13:40 +01:00
|
|
|
add_executable(test_geoip geoip/test_geoip.cpp ${geoip_src})
|
|
|
|
target_link_libraries(test_geoip Calamares::calamares Qt5::Network yamlcpp::yamlcpp)
|
2020-04-22 15:38:42 +02:00
|
|
|
calamares_automoc( test_geoip )
|
2020-12-22 21:25:00 +01:00
|
|
|
|
2022-02-08 16:13:40 +01:00
|
|
|
if(Qt5DBus_FOUND)
|
|
|
|
add_executable(test_automount partition/calautomount.cpp)
|
|
|
|
target_link_libraries(test_automount Calamares::calamares Qt5::DBus)
|
2020-12-22 21:25:00 +01:00
|
|
|
endif()
|