calamares/src/libcalamares/CMakeLists.txt

303 lines
7.5 KiB
CMake
Raw Normal View History

# === This file is part of Calamares - <https://calamares.io> ===
#
[libcalamares] Update SPDX identifiers. Update CppJob.h Update CalamaresConfig.h.in Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.cpp Update CalamaresConfig.h.in Update CppJob.cpp Update CppJob.h Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.h Update ProcessJob.cpp Update ProcessJob.h Update PythonHelper.cpp Update PythonJob.cpp Update PythonJob.h Update PythonHelper.h Update PythonJobApi.cpp Update PythonJobApi.h Update Settings.cpp Update Settings.h Update GeoIPJSON.cpp Update GeoIPJSON.h Update GeoIPTests.cpp Update GeoIPTests.h Update GeoIPXML.cpp Update GeoIPXML.h Update Handler.cpp Update Handler.h Update Interface.cpp Update Interface.h Update test_geoip.cpp Update CountryData_p.cpp Update Label.cpp Update Label.h Update LabelModel.cpp Update LabelModel.h Update CountryData_p.cpp Update CountryData_p.cpp Update Lookup.cpp Update Lookup.h Update Tests.cpp Update Tests.h Update TimeZone.cpp Update TimeZone.h Update TranslatableConfiguration.cpp Update TranslatableConfiguration.h Update ZoneData_p.cxxtr Update cldr-extractor.py Update zone-extractor.py Update Actions.h Update Actions.h Update Descriptor.h Update InstanceKey.cpp Update Module.cpp Update Module.h Update Requirement.cpp Update RequirementsChecker.h Update RequirementsModel.cpp Update RequirementsModel.h Update Tests.cpp Update Manager.cpp Update Manager.h Update Tests.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update KPMTests.cpp Update FileSystem.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update Mount.cpp Update Mount.h Update PartitionIterator.cpp Update PartitionIterator.h Update PartitionIterator.h Update PartitionQuery.cpp Update PartitionQuery.h Update PartitionSize.cpp Update PartitionSize.h Update Sync.cpp Update Sync.h Update Tests.cpp Update Tests.h Update BoostPython.h Update CalamaresUtilsSystem.cpp Update CalamaresUtilsSystem.h Update CommandList.cpp Update CommandList.h Update Dirs.cpp Update Dirs.h Update Entropy.cpp Update Entropy.h Update Entropy.cpp Update Logger.cpp Update Logger.h Update NamedEnum.h Update NamedSuffix.h Update PluginFactory.cpp Update PluginFactory.h Update RAII.h Update RAII.h Update Retranslator.cpp Update Retranslator.h Update String.cpp Update String.h Update TestPaths.cpp Update Tests.cpp Update Tests.h Update UMask.cpp Update UMask.h Update Units.h Update Variant.cpp Update Variant.h Update Yaml.cpp Update Yaml.h Update moc-warnings.h
2020-05-30 16:15:03 +02:00
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
# SPDX-License-Identifier: BSD-2-Clause
[libcalamares] Update SPDX identifiers. Update CppJob.h Update CalamaresConfig.h.in Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.cpp Update CalamaresConfig.h.in Update CppJob.cpp Update CppJob.h Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.h Update ProcessJob.cpp Update ProcessJob.h Update PythonHelper.cpp Update PythonJob.cpp Update PythonJob.h Update PythonHelper.h Update PythonJobApi.cpp Update PythonJobApi.h Update Settings.cpp Update Settings.h Update GeoIPJSON.cpp Update GeoIPJSON.h Update GeoIPTests.cpp Update GeoIPTests.h Update GeoIPXML.cpp Update GeoIPXML.h Update Handler.cpp Update Handler.h Update Interface.cpp Update Interface.h Update test_geoip.cpp Update CountryData_p.cpp Update Label.cpp Update Label.h Update LabelModel.cpp Update LabelModel.h Update CountryData_p.cpp Update CountryData_p.cpp Update Lookup.cpp Update Lookup.h Update Tests.cpp Update Tests.h Update TimeZone.cpp Update TimeZone.h Update TranslatableConfiguration.cpp Update TranslatableConfiguration.h Update ZoneData_p.cxxtr Update cldr-extractor.py Update zone-extractor.py Update Actions.h Update Actions.h Update Descriptor.h Update InstanceKey.cpp Update Module.cpp Update Module.h Update Requirement.cpp Update RequirementsChecker.h Update RequirementsModel.cpp Update RequirementsModel.h Update Tests.cpp Update Manager.cpp Update Manager.h Update Tests.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update KPMTests.cpp Update FileSystem.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update Mount.cpp Update Mount.h Update PartitionIterator.cpp Update PartitionIterator.h Update PartitionIterator.h Update PartitionQuery.cpp Update PartitionQuery.h Update PartitionSize.cpp Update PartitionSize.h Update Sync.cpp Update Sync.h Update Tests.cpp Update Tests.h Update BoostPython.h Update CalamaresUtilsSystem.cpp Update CalamaresUtilsSystem.h Update CommandList.cpp Update CommandList.h Update Dirs.cpp Update Dirs.h Update Entropy.cpp Update Entropy.h Update Entropy.cpp Update Logger.cpp Update Logger.h Update NamedEnum.h Update NamedSuffix.h Update PluginFactory.cpp Update PluginFactory.h Update RAII.h Update RAII.h Update Retranslator.cpp Update Retranslator.h Update String.cpp Update String.h Update TestPaths.cpp Update Tests.cpp Update Tests.h Update UMask.cpp Update UMask.h Update Units.h Update Variant.cpp Update Variant.h Update Yaml.cpp Update Yaml.h Update moc-warnings.h
2020-05-30 16:15:03 +02:00
#
[libcalamares] Update SPDX identifiers. Update CppJob.h Update CalamaresConfig.h.in Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.cpp Update CalamaresConfig.h.in Update CppJob.cpp Update CppJob.h Update DllMacro.h Update GlobalStorage.cpp Update GlobalStorage.h Update Job.cpp Update Job.h Update JobExample.cpp Update JobExample.h Update JobQueue.h Update ProcessJob.cpp Update ProcessJob.h Update PythonHelper.cpp Update PythonJob.cpp Update PythonJob.h Update PythonHelper.h Update PythonJobApi.cpp Update PythonJobApi.h Update Settings.cpp Update Settings.h Update GeoIPJSON.cpp Update GeoIPJSON.h Update GeoIPTests.cpp Update GeoIPTests.h Update GeoIPXML.cpp Update GeoIPXML.h Update Handler.cpp Update Handler.h Update Interface.cpp Update Interface.h Update test_geoip.cpp Update CountryData_p.cpp Update Label.cpp Update Label.h Update LabelModel.cpp Update LabelModel.h Update CountryData_p.cpp Update CountryData_p.cpp Update Lookup.cpp Update Lookup.h Update Tests.cpp Update Tests.h Update TimeZone.cpp Update TimeZone.h Update TranslatableConfiguration.cpp Update TranslatableConfiguration.h Update ZoneData_p.cxxtr Update cldr-extractor.py Update zone-extractor.py Update Actions.h Update Actions.h Update Descriptor.h Update InstanceKey.cpp Update Module.cpp Update Module.h Update Requirement.cpp Update RequirementsChecker.h Update RequirementsModel.cpp Update RequirementsModel.h Update Tests.cpp Update Manager.cpp Update Manager.h Update Tests.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update KPMTests.cpp Update FileSystem.cpp Update FileSystem.cpp Update FileSystem.h Update KPMManager.cpp Update KPMManager.h Update Mount.cpp Update Mount.h Update PartitionIterator.cpp Update PartitionIterator.h Update PartitionIterator.h Update PartitionQuery.cpp Update PartitionQuery.h Update PartitionSize.cpp Update PartitionSize.h Update Sync.cpp Update Sync.h Update Tests.cpp Update Tests.h Update BoostPython.h Update CalamaresUtilsSystem.cpp Update CalamaresUtilsSystem.h Update CommandList.cpp Update CommandList.h Update Dirs.cpp Update Dirs.h Update Entropy.cpp Update Entropy.h Update Entropy.cpp Update Logger.cpp Update Logger.h Update NamedEnum.h Update NamedSuffix.h Update PluginFactory.cpp Update PluginFactory.h Update RAII.h Update RAII.h Update Retranslator.cpp Update Retranslator.h Update String.cpp Update String.h Update TestPaths.cpp Update Tests.cpp Update Tests.h Update UMask.cpp Update UMask.h Update Units.h Update Variant.cpp Update Variant.h Update Yaml.cpp Update Yaml.h Update moc-warnings.h
2020-05-30 16:15:03 +02:00
#
# libcalamares is the non-GUI part of Calamares, which includes handling
# translations, configurations, logging, utilities, global storage, and
# (non-GUI) jobs.
#
add_definitions( -DDLLEXPORT_PRO )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
2014-06-04 16:35:26 +02: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
set( OPTIONAL_PRIVATE_LIBRARIES "" )
set( OPTIONAL_PUBLIC_LIBRARIES "" )
2014-06-04 16:35:26 +02:00
set( libSources
CppJob.cpp
GlobalStorage.cpp
2014-06-27 15:34:05 +02:00
Job.cpp
JobExample.cpp
2014-06-04 16:35:26 +02:00
JobQueue.cpp
ProcessJob.cpp
Settings.cpp
# GeoIP services
geoip/Interface.cpp
geoip/GeoIPFixed.cpp
geoip/GeoIPJSON.cpp
geoip/Handler.cpp
# Locale-data service
locale/Global.cpp
locale/Label.cpp
locale/LabelModel.cpp
locale/Lookup.cpp
locale/TimeZone.cpp
locale/TranslatableConfiguration.cpp
locale/TranslatableString.cpp
# Modules
modulesystem/Config.cpp
modulesystem/Descriptor.cpp
modulesystem/InstanceKey.cpp
modulesystem/Module.cpp
modulesystem/Preset.cpp
modulesystem/RequirementsChecker.cpp
modulesystem/RequirementsModel.cpp
# Network service
network/Manager.cpp
# Packages service
packages/Globals.cpp
# Partition service
partition/Global.cpp
partition/Mount.cpp
partition/PartitionSize.cpp
partition/Sync.cpp
# Utility service
utils/CalamaresUtilsSystem.cpp
utils/CommandList.cpp
utils/Dirs.cpp
utils/Entropy.cpp
utils/Logger.cpp
utils/Permissions.cpp
utils/PluginFactory.cpp
utils/Retranslator.cpp
utils/String.cpp
utils/UMask.cpp
utils/Variant.cpp
utils/Yaml.cpp
2014-06-04 16:35:26 +02:00
)
### OPTIONAL Automount support (requires dbus)
#
#
if( Qt5DBus_FOUND)
list( APPEND libSources partition/AutoMount.cpp )
list( APPEND OPTIONAL_PRIVATE_LIBRARIES Qt5::DBus )
endif()
### OPTIONAL Python support
#
#
if( WITH_PYTHON )
list( APPEND libSources
PythonHelper.cpp
PythonJob.cpp
PythonJobApi.cpp
)
include_directories(${PYTHON_INCLUDE_DIRS})
link_directories(${PYTHON_LIBRARIES})
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
list( APPEND OPTIONAL_PRIVATE_LIBRARIES
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
)
endif()
### OPTIONAL GeoIP XML support
#
#
find_package(Qt5 COMPONENTS Xml)
if( Qt5Xml_FOUND )
list( APPEND libSources geoip/GeoIPXML.cpp )
list( APPEND OPTIONAL_PUBLIC_LIBRARIES Qt5::Network Qt5::Xml )
endif()
### OPTIONAL KPMcore support
#
#
include( KPMcoreHelper )
if ( KPMcore_FOUND )
find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore
find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore
foreach ( d ${KPMcore_API_DEFINITIONS} )
add_definitions( -D${d} )
endforeach()
include_directories( ${KPMCORE_INCLUDE_DIR} )
list( APPEND libSources
partition/FileSystem.cpp
partition/KPMManager.cpp
partition/PartitionIterator.cpp
partition/PartitionQuery.cpp
)
list( APPEND OPTIONAL_PRIVATE_LIBRARIES kpmcore )
endif()
### LIBRARY
#
#
add_library( calamares SHARED ${libSources} )
set_target_properties( calamares
PROPERTIES
VERSION ${CALAMARES_VERSION_SHORT}
SOVERSION ${CALAMARES_VERSION_SHORT}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_INSTALL_FULL_INCLUDEDIR}/libcalamares
2014-06-04 16:35:26 +02:00
)
calamares_automoc( calamares )
2014-06-04 16:35:26 +02:00
target_link_libraries( calamares
LINK_PRIVATE
${OPTIONAL_PRIVATE_LIBRARIES}
LINK_PUBLIC
yamlcpp
Qt5::Core
KF5::CoreAddons
${OPTIONAL_PUBLIC_LIBRARIES}
2014-06-04 16:35:26 +02:00
)
### Installation
#
#
install( TARGETS calamares
EXPORT Calamares
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
2014-06-04 16:35:26 +02: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.
install( CODE "
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\" )
")
2014-06-04 16:35:26 +02:00
# Install header files
file( GLOB rootHeaders "*.h" )
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h
${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h
${rootHeaders}
DESTINATION include/libcalamares
)
# Install each subdir-worth of header files
foreach( subdir geoip locale modulesystem network partition utils )
file( GLOB subdir_headers "${subdir}/*.h" )
install( FILES ${subdir_headers} DESTINATION include/libcalamares/${subdir} )
endforeach()
### TESTING
#
#
calamares_add_test(
libcalamarestest
SOURCES
Tests.cpp
)
calamares_add_test(
libcalamaresgeoiptest
SOURCES
geoip/GeoIPTests.cpp
${geoip_src}
)
# Build up translations for this one test
set( trans_file "localetest" )
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
set( calamares_i18n_qrc_content "<file>localetest_nl.qm</file>" )
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
qt5_add_translation(QM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/testdata/localetest_nl.ts")
# Run the resource compiler (rcc_options should already be set)
add_custom_command(
OUTPUT ${trans_outfile}
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES}
)
calamares_add_test(
libcalamareslocaletest
SOURCES
locale/Tests.cpp
${trans_outfile}
)
calamares_add_test(
libcalamaresmodulesystemtest
SOURCES
modulesystem/Tests.cpp
)
calamares_add_test(
libcalamaresnetworktest
SOURCES
network/Tests.cpp
)
calamares_add_test(
libcalamarespackagestest
SOURCES
packages/Tests.cpp
)
calamares_add_test(
libcalamarespartitiontest
SOURCES
partition/Global.cpp
partition/Tests.cpp
LIBRARIES
${OPTIONAL_PRIVATE_LIBRARIES}
)
if( KPMcore_FOUND )
calamares_add_test(
libcalamarespartitionkpmtest
SOURCES
partition/KPMTests.cpp
LIBRARIES
${OPTIONAL_PRIVATE_LIBRARIES}
)
endif()
calamares_add_test(
libcalamaresutilstest
SOURCES
utils/Tests.cpp
)
calamares_add_test(
libcalamaresutilspathstest
SOURCES
utils/TestPaths.cpp
)
# This is not an actual test, it's a test / demo application
# for experimenting with GeoIP.
add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
target_link_libraries( test_geoip calamares Qt5::Network yamlcpp )
calamares_automoc( test_geoip )
if ( Qt5DBus_FOUND )
add_executable( test_automount partition/calautomount.cpp )
target_link_libraries( test_automount calamares Qt5::DBus )
endif()