From b9f802bbda998c0ba657231d17b6fa3fd95a2f2a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 9 Jun 2020 23:25:17 +0200 Subject: [PATCH 01/13] CMake: shuffle includes together --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 020b83e80..30ba649ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,13 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.10.0") ) endif() +# CMake Modules +include( CMakePackageConfigHelpers ) include( CTest ) +include( FeatureSummary ) + +# Calamares Modules +include( CMakeColors ) ### C++ SETUP # @@ -248,9 +254,6 @@ if( CMAKE_COMPILER_IS_GNUCXX ) endif() endif() -include( FeatureSummary ) -include( CMakeColors ) - ### DEPENDENCIES # @@ -555,6 +558,8 @@ configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/Calam # Create the CalamaresConfig.cmake and CalamaresConfigVersion files file( RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}" ) + + configure_file( CalamaresConfig.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @ONLY ) configure_file( CalamaresConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" @ONLY ) configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY ) From 6507098d16f2d5a7623421643242ab578ca65fc4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 9 Jun 2020 23:38:31 +0200 Subject: [PATCH 02/13] CMake: use standard function for creating a version file --- CMakeLists.txt | 7 ++++++- CalamaresConfigVersion.cmake.in | 12 ------------ 2 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 CalamaresConfigVersion.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 30ba649ee..107dc0b23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,12 +556,17 @@ export( PACKAGE Calamares ) configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY ) # Create the CalamaresConfig.cmake and CalamaresConfigVersion files +write_basic_package_version_file( + ${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + file( RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}" ) configure_file( CalamaresConfig.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @ONLY ) -configure_file( CalamaresConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" @ONLY ) configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY ) # Install the cmake files diff --git a/CalamaresConfigVersion.cmake.in b/CalamaresConfigVersion.cmake.in deleted file mode 100644 index 05b87c8d3..000000000 --- a/CalamaresConfigVersion.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -set(PACKAGE_VERSION "@CALAMARES_VERSION@") - -# Check whether the requested PACKAGE_FIND_VERSION is compatible -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() - From f59b6da7995340df3f8896da2c771db72c81bde3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 9 Jun 2020 23:58:58 +0200 Subject: [PATCH 03/13] CMake: produce a standard modern-CMake config file - Use modern CMake commands to produce the config file - Drop the CalamaresUse.cmake file, include its functionality in the config file. --- CMakeLists.txt | 17 +++++++++-------- CalamaresConfig.cmake.in | 40 ++++++++++++++-------------------------- CalamaresUse.cmake.in | 29 ----------------------------- 3 files changed, 23 insertions(+), 63 deletions(-) delete mode 100644 CalamaresUse.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 107dc0b23..3cf52e198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,25 +556,26 @@ export( PACKAGE Calamares ) configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY ) # Create the CalamaresConfig.cmake and CalamaresConfigVersion files +configure_package_config_file( + "CalamaresConfig.cmake.in" + "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + PATH_VARS + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR + CMAKE_INSTALL_DATADIR +) write_basic_package_version_file( ${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) -file( RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}" ) - - - -configure_file( CalamaresConfig.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @ONLY ) -configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY ) - # Install the cmake files install( FILES "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" - "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" "CMakeModules/CalamaresAddBrandingSubdirectory.cmake" "CMakeModules/CalamaresAddLibrary.cmake" "CMakeModules/CalamaresAddModuleSubdirectory.cmake" diff --git a/CalamaresConfig.cmake.in b/CalamaresConfig.cmake.in index 6d32410c6..9814bf8c1 100644 --- a/CalamaresConfig.cmake.in +++ b/CalamaresConfig.cmake.in @@ -1,32 +1,20 @@ # Config file for the Calamares package # -# It defines the following variables -# CALAMARES_INCLUDE_DIRS - include directories for Calamares -# CALAMARES_LIBRARIES - libraries to link against -# CALAMARES_USE_FILE - name of a convenience include -# CALAMARES_APPLICATION_NAME - human-readable application name -# -# Typical use is: -# -# find_package(Calamares REQUIRED) -# include("${CALAMARES_USE_FILE}") -# +# For legacy use it defines the following variables: +# - Calamares_INCLUDE_DIRS - include directories for Calamares +# - Calamares_LIB_DIRS - library directories +# - Calamares_LIBRARIES - libraries to link against (e.g. -lcalamares) -# Compute paths -get_filename_component(CALAMARES_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -if(EXISTS "${CALAMARES_CMAKE_DIR}/CMakeCache.txt") - # In build tree - include("${CALAMARES_CMAKE_DIR}/CalamaresBuildTreeSettings.cmake") -else() - set(CALAMARES_INCLUDE_DIRS "${CALAMARES_CMAKE_DIR}/@CONF_REL_INCLUDE_DIR@/libcalamares") -endif() +@PACKAGE_INIT@ -# Our library dependencies (contains definitions for IMPORTED targets) -include("${CALAMARES_CMAKE_DIR}/CalamaresLibraryDepends.cmake") +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresConfigVersion.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresTargets.cmake) -# These are IMPORTED targets created by CalamaresLibraryDepends.cmake -set(CALAMARES_LIBRARIES calamares) +set(Calamares_LIB_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") +set(Calamares_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set(Calamares_LIBRARIES calamares) -# Convenience variables -set(CALAMARES_USE_FILE "${CALAMARES_CMAKE_DIR}/CalamaresUse.cmake") -set(CALAMARES_APPLICATION_NAME "Calamares") +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddLibrary.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddModuleSubdirectory.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddPlugin.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddBrandingSubdirectory.cmake) diff --git a/CalamaresUse.cmake.in b/CalamaresUse.cmake.in deleted file mode 100644 index 00f3c968d..000000000 --- a/CalamaresUse.cmake.in +++ /dev/null @@ -1,29 +0,0 @@ -# A setup-cmake-things-for-Calamares module. -# -# This module handles looking for dependencies and including -# all of the Calamares macro modules, so that you can focus -# on just using the macros to build Calamares modules. -# Typical use looks like this: -# -# ``` -# find_package( Calamares REQUIRED ) -# include( "${CALAMARES_CMAKE_DIR}/CalamaresUse.cmake" ) -# ``` -# -# The first CMake command finds Calamares (which will contain -# this file), then adds the found location to the search path, -# and then includes this file. After that, you can use -# Calamares module and plugin macros. - -if( NOT CALAMARES_CMAKE_DIR ) - message( FATAL_ERROR "Use find_package(Calamares) first." ) -endif() -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CALAMARES_CMAKE_DIR} ) - -find_package( Qt5 @QT_VERSION@ CONFIG REQUIRED Core Widgets LinguistTools ) - -include( CalamaresAddLibrary ) -include( CalamaresAddModuleSubdirectory ) -include( CalamaresAddPlugin ) -include( CalamaresAddBrandingSubdirectory ) - From dc16afac4a4e1cf3e2448cd291aaedc4aee0f352 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 00:31:13 +0200 Subject: [PATCH 04/13] CMake: massage IMPORTED targets and module path - Add the Calamares CMake-modules to the search path automatically - Export to CalamaresTargets.cmake and use namespace Calamares:: - Document imported targets - Find Qt, because the translations machinery will need macros from that - The installed lib links to IMPORTED libraries from KF5, so we need to find them (again) as well. --- CMakeLists.txt | 19 ++++---- CMakeModules/CalamaresAddLibrary.cmake | 2 +- CalamaresConfig.cmake.in | 60 +++++++++++++++++++++++--- src/libcalamares/CMakeLists.txt | 4 +- src/libcalamaresui/CMakeLists.txt | 2 +- 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cf52e198..8071f0870 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -532,7 +532,9 @@ configure_file( # Early configure these files as we need them later on set( CALAMARES_CMAKE_DIR "${CMAKE_SOURCE_DIR}/CMakeModules" ) -set( CALAMARES_LIBRARIES calamares ) +# This is used by CalamaresAddLibrary; once installed, this variable +# is set to the IMPORTED library for Calamares. +set( Calamares_LIBRARIES calamares ) add_subdirectory( src ) @@ -570,6 +572,13 @@ write_basic_package_version_file( VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) +export( PACKAGE Calamares ) +install( + EXPORT Calamares + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + FILE "CalamaresTargets.cmake" + NAMESPACE Calamares:: +) # Install the cmake files install( @@ -588,14 +597,6 @@ install( "${CMAKE_INSTALL_CMAKEDIR}" ) -# Install the export set for use with the install-tree -install( - EXPORT - CalamaresLibraryDepends - DESTINATION - "${CMAKE_INSTALL_CMAKEDIR}" -) - if( INSTALL_CONFIG ) install( FILES diff --git a/CMakeModules/CalamaresAddLibrary.cmake b/CMakeModules/CalamaresAddLibrary.cmake index 6155293d7..abfb3ac38 100644 --- a/CMakeModules/CalamaresAddLibrary.cmake +++ b/CMakeModules/CalamaresAddLibrary.cmake @@ -93,7 +93,7 @@ function(calamares_add_library) # add link targets target_link_libraries(${target} - LINK_PUBLIC ${CALAMARES_LIBRARIES} + LINK_PUBLIC ${Calamares_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets diff --git a/CalamaresConfig.cmake.in b/CalamaresConfig.cmake.in index 9814bf8c1..7fa67b310 100644 --- a/CalamaresConfig.cmake.in +++ b/CalamaresConfig.cmake.in @@ -1,20 +1,68 @@ # Config file for the Calamares package # +# The following IMPORTED targets are defined: +# - Calamares::calamares - the core library +# - Calamares::calamaresui - the UI (and QML) library +# # For legacy use it defines the following variables: # - Calamares_INCLUDE_DIRS - include directories for Calamares # - Calamares_LIB_DIRS - library directories -# - Calamares_LIBRARIES - libraries to link against (e.g. -lcalamares) +# - Calamares_LIBRARIES - libraries to link against @PACKAGE_INIT@ +### Versioning and IMPORTED targets +# +# include(${CMAKE_CURRENT_LIST_DIR}/CalamaresConfigVersion.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CalamaresTargets.cmake) +### Dependencies +# +# The libraries can depend on a variety of Qt and KDE Frameworks +# components, so accumulate them and find (just once). +# +macro(accumulate_deps outvar target namespace) + string(LENGTH ${namespace} _nslen) + get_target_property(_libs ${target} INTERFACE_LINK_LIBRARIES) + foreach(_lib ${_libs}) + if (_lib MATCHES ^${namespace}) + string(SUBSTRING ${_lib} ${_nslen} -1 _component) + list(APPEND ${outvar} ${_component}) + endif() + endforeach() +endmacro() + +# Qt5 infrastructure for translations is required +set(qt5_required Core Widgets LinguistTools) +accumulate_deps(qt5_required Calamares::calamares Qt5::) +accumulate_deps(qt5_required Calamares::calamaresui Qt5::) +find_package(Qt5 CONFIG REQUIRED ${qt5_required}) + +set(kf5_required "") +accumulate_deps(kf5_required Calamares::calamares KF5::) +accumulate_deps(kf5_required Calamares::calamaresui KF5::) +if(kf5_required) + find_package(ECM ${ECM_VERSION} NO_MODULE) + if( ECM_FOUND ) + list(PREPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + find_package(KF5 REQUIRED COMPONENTS ${kf5_required}) + endif() +endif() + +### Legacy support +# +# set(Calamares_LIB_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") set(Calamares_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") -set(Calamares_LIBRARIES calamares) +set(Calamares_LIBRARIES Calamares::calamares) -include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddLibrary.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddModuleSubdirectory.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddPlugin.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddBrandingSubdirectory.cmake) +### CMake support +# +# +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) + +include(CalamaresAddLibrary) +include(CalamaresAddModuleSubdirectory) +include(CalamaresAddPlugin) +include(CalamaresAddBrandingSubdirectory) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index b43b89289..b4d369fe0 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -1,5 +1,5 @@ # === This file is part of Calamares - === -# +# # SPDX-FileCopyrightText: 2020 Adriaan de Groot # # Calamares is free software: you can redistribute it and/or modify @@ -177,7 +177,7 @@ target_link_libraries( calamares ) install( TARGETS calamares - EXPORT CalamaresLibraryDepends + EXPORT Calamares RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 32fec2cb1..b00f9682c 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -67,7 +67,7 @@ calamares_add_library( calamaresui LINK_LIBRARIES Qt5::Svg RESOURCES libcalamaresui.qrc - EXPORT CalamaresLibraryDepends + EXPORT Calamares VERSION ${CALAMARES_VERSION_SHORT} ) From e6fe19df20d1689ebb508f79e2f12dabd2dbf3c6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 01:25:36 +0200 Subject: [PATCH 05/13] CMake: remove unused link libraries - Nothing ever sets LIBRARY_QT5_MODULES (it would be a macro argument to calamares_add_library, if anything). --- CMakeModules/CalamaresAddLibrary.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeModules/CalamaresAddLibrary.cmake b/CMakeModules/CalamaresAddLibrary.cmake index abfb3ac38..88978e751 100644 --- a/CMakeModules/CalamaresAddLibrary.cmake +++ b/CMakeModules/CalamaresAddLibrary.cmake @@ -97,7 +97,6 @@ function(calamares_add_library) Qt5::Core Qt5::Gui Qt5::Widgets - ${LIBRARY_QT5_MODULES} ) if(LIBRARY_LINK_LIBRARIES) target_link_libraries(${target} LINK_PUBLIC ${LIBRARY_LINK_LIBRARIES}) From a62d96f555fc42a0232182cf8688ebcf23ac07c2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 01:34:18 +0200 Subject: [PATCH 06/13] CMake: tidy up installation of CMake infrastructure - export() only once - document variables a bit better - drop the LibraryDepends file --- CMakeLists.txt | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8071f0870..23359490f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -530,10 +530,9 @@ configure_file( IMMEDIATE @ONLY ) -# Early configure these files as we need them later on -set( CALAMARES_CMAKE_DIR "${CMAKE_SOURCE_DIR}/CMakeModules" ) -# This is used by CalamaresAddLibrary; once installed, this variable -# is set to the IMPORTED library for Calamares. +# This is used by CalamaresAddLibrary; once Calamares is installed, +# the CalamaresConfig.cmake module sets this variable to the IMPORTED +# libraries for Calamares. set( Calamares_LIBRARIES calamares ) add_subdirectory( src ) @@ -544,20 +543,17 @@ add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration") add_feature_info(KCrash ${WITH_KF5Crash} "Crash dumps via KCrash") add_feature_info(KDBusAddons ${WITH_KF5DBus} "Unique-application via DBus") -# Add all targets to the build-tree export set +### CMake infrastructure installation +# +# 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}" ) -export( TARGETS calamares - FILE "${PROJECT_BINARY_DIR}/CalamaresLibraryDepends.cmake" ) -# Export the package for use from the build-tree -# (this registers the build-tree with a global CMake-registry) export( PACKAGE Calamares ) - -# Create a CalamaresBuildTreeSettings.cmake file for the use from the build tree -configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY ) - -# Create the CalamaresConfig.cmake and CalamaresConfigVersion files +configure_file( + CalamaresBuildTreeSettings.cmake.in + "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY +) configure_package_config_file( "CalamaresConfig.cmake.in" "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @@ -572,7 +568,6 @@ write_basic_package_version_file( VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) -export( PACKAGE Calamares ) install( EXPORT Calamares DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" From 9039e15bdf0dd45dea42deb88dfd3b3d9d09c7f2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 01:42:11 +0200 Subject: [PATCH 07/13] CMake: tidy misc. installation bits - don't generate uninstall file twice - tighten up vertical space --- CMakeLists.txt | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23359490f..52af262d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -523,13 +523,6 @@ endif() # make predefined install dirs available everywhere include( GNUInstallDirs ) -# make uninstall support -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY -) - # This is used by CalamaresAddLibrary; once Calamares is installed, # the CalamaresConfig.cmake module sets this variable to the IMPORTED # libraries for Calamares. @@ -592,36 +585,31 @@ install( "${CMAKE_INSTALL_CMAKEDIR}" ) +### Miscellaneous installs +# +# if( INSTALL_CONFIG ) install( - FILES - settings.conf - DESTINATION - share/calamares + FILES settings.conf + DESTINATIONshare/calamares ) endif() if( INSTALL_POLKIT ) install( - FILES - com.github.calamares.calamares.policy - DESTINATION - "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}" + FILES com.github.calamares.calamares.policy + DESTINATION "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}" ) endif() install( - FILES - calamares.desktop - DESTINATION - ${CMAKE_INSTALL_DATADIR}/applications + FILES calamares.desktop + DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) install( - FILES - man/calamares.8 - DESTINATION - ${CMAKE_INSTALL_MANDIR}/man8/ + FILES man/calamares.8 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/ ) # uninstall target From 14ff681106c4115625c0831b17f05423ae963cce Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 02:01:59 +0200 Subject: [PATCH 08/13] CMake: give libcalamares IMPORTED includes - Set the interface-include path for libcalamares, so that linking to it (as one would from an external repo) pulls in all the includes. --- src/libcalamares/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index b4d369fe0..a2c60efe5 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -163,6 +163,7 @@ set_target_properties( calamares PROPERTIES VERSION ${CALAMARES_VERSION_SHORT} SOVERSION ${CALAMARES_VERSION_SHORT} + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_INSTALL_FULL_INCLUDEDIR}/libcalamares ) calamares_automoc( calamares ) From 3c770b79b30c229f8f831599a41715a40da4f27f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 02:10:21 +0200 Subject: [PATCH 09/13] CMake: install all the libcalamares subdir-headers --- src/libcalamares/CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index a2c60efe5..deb291ba9 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -193,13 +193,18 @@ install( CODE " # Install header files file( GLOB rootHeaders "*.h" ) -file( GLOB kdsingleapplicationguardHeaders "kdsingleapplicationguard/*.h" ) file( GLOB utilsHeaders "utils/*.h" ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h DESTINATION include/libcalamares ) -install( FILES ${rootHeaders} DESTINATION include/libcalamares ) -install( FILES ${kdsingleapplicationguardHeaders} DESTINATION include/libcalamares/kdsingleapplicationguard ) -install( FILES ${utilsHeaders} DESTINATION include/libcalamares/utils ) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h + ${rootHeaders} + DESTINATION include/libcalamares +) +foreach( subdir geoip locale modulesystem network partition utils ) + file( GLOB subdir_headers "${subdir}/*.h" ) + install( FILES ${subdir_headers} DESTINATION include/libcalamares/${subdir} ) +endforeach() ### TESTING # From 6c272bc8bef08de019930c64dfa97135a557dfd5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 02:27:57 +0200 Subject: [PATCH 10/13] [libcalamares] Link yamlcpp privately - link the library privately -- the public API uses QVariantMap - install FindYAMLCPP just in case - add yamlcpp explicitly in the few places that really need it (e.g. netinstall testing the parsing of netinstall.yaml) --- CMakeLists.txt | 1 + src/libcalamares/CMakeLists.txt | 2 +- src/libcalamaresui/CMakeLists.txt | 1 + src/modules/netinstall/CMakeLists.txt | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52af262d0..7aabe437e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -581,6 +581,7 @@ install( "CMakeModules/CalamaresAddTranslations.cmake" "CMakeModules/CalamaresAutomoc.cmake" "CMakeModules/CMakeColors.cmake" + "CMakeModules/FindYAMLCPP.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" ) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index deb291ba9..a7b4472d5 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -170,8 +170,8 @@ calamares_automoc( calamares ) target_link_libraries( calamares LINK_PRIVATE ${OPTIONAL_PRIVATE_LIBRARIES} - LINK_PUBLIC yamlcpp + LINK_PUBLIC Qt5::Core KF5::CoreAddons ${OPTIONAL_PUBLIC_LIBRARIES} diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index b00f9682c..9d7b7a85c 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -66,6 +66,7 @@ calamares_add_library( calamaresui EXPORT_MACRO UIDLLEXPORT_PRO LINK_LIBRARIES Qt5::Svg + yamlcpp RESOURCES libcalamaresui.qrc EXPORT Calamares VERSION ${CALAMARES_VERSION_SHORT} diff --git a/src/modules/netinstall/CMakeLists.txt b/src/modules/netinstall/CMakeLists.txt index 3e6ac3cb5..762e92985 100644 --- a/src/modules/netinstall/CMakeLists.txt +++ b/src/modules/netinstall/CMakeLists.txt @@ -26,5 +26,6 @@ calamares_add_test( PackageModel.cpp LIBRARIES Qt5::Gui + yamlcpp ) From 23c93904dfd2d8b4116ad438a459abb94cc31d0b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 11:51:53 +0200 Subject: [PATCH 11/13] CMake: put CMake-level ABI settings in CalamaresConfig - drop the BuildTreeSettings, it was not usefully used - make CalamaresConfig repeat the WITH_* settings, so that consumers can know the ABI offered --- CMakeLists.txt | 4 ---- CalamaresBuildTreeSettings.cmake.in | 4 ---- CalamaresConfig.cmake.in | 12 +++++++++++- src/libcalamares/CalamaresConfig.h.in | 11 +++++++++-- 4 files changed, 20 insertions(+), 11 deletions(-) delete mode 100644 CalamaresBuildTreeSettings.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aabe437e..09e5c6d1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -543,10 +543,6 @@ set( CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH set( CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}" ) export( PACKAGE Calamares ) -configure_file( - CalamaresBuildTreeSettings.cmake.in - "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY -) configure_package_config_file( "CalamaresConfig.cmake.in" "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" diff --git a/CalamaresBuildTreeSettings.cmake.in b/CalamaresBuildTreeSettings.cmake.in deleted file mode 100644 index 507fc3d64..000000000 --- a/CalamaresBuildTreeSettings.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -set(CALAMARES_INCLUDE_DIRS - "@PROJECT_SOURCE_DIR@/src/libcalamares" - "@PROJECT_BINARY_DIR@/src/libcalamares" -) diff --git a/CalamaresConfig.cmake.in b/CalamaresConfig.cmake.in index 7fa67b310..4c62fb477 100644 --- a/CalamaresConfig.cmake.in +++ b/CalamaresConfig.cmake.in @@ -62,7 +62,17 @@ set(Calamares_LIBRARIES Calamares::calamares) # list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) +include(CalamaresAddBrandingSubdirectory) include(CalamaresAddLibrary) include(CalamaresAddModuleSubdirectory) include(CalamaresAddPlugin) -include(CalamaresAddBrandingSubdirectory) + +# These are feature-settings that affect consumers of Calamares +# libraries as well; without Python-support in the libs, for instance, +# there's no point in having a Python plugin. +# +# This list should match the one in libcalamares/CalamaresConfig.h, +# which is the C++-language side of the same configuration. +set(Calamares_WITH_PYTHON @WITH_PYTHON@) +set(Calamares_WITH_PYTHONQT @WITH_PYTHONQT@) +set(Calamares_WITH_QML @WITH_QML@) diff --git a/src/libcalamares/CalamaresConfig.h.in b/src/libcalamares/CalamaresConfig.h.in index 98efa8c26..c081b158f 100644 --- a/src/libcalamares/CalamaresConfig.h.in +++ b/src/libcalamares/CalamaresConfig.h.in @@ -1,5 +1,5 @@ /* === This file is part of Calamares - === - * + * * SPDX-FileCopyrightText: 2020 Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify @@ -29,7 +29,14 @@ #define CMAKE_INSTALL_FULL_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/calamares" #define CMAKE_INSTALL_FULL_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}" -//cmakedefines for CMake variables (e.g. for optdepends) go here +/* + * These are feature-settings that affect consumers of Calamares + * libraries as well; without Python-support in the libs, for instance, + * there's no point in having a Python plugin. + * + * This list should match the one in CalamaresConfig.cmake + * which is the CMake-time side of the same configuration. + */ #cmakedefine WITH_PYTHON #cmakedefine WITH_PYTHONQT #cmakedefine WITH_QML From dc0ed24f1a05cac6b9fc47ddfeb2531497673c89 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 16:43:34 +0200 Subject: [PATCH 12/13] [libcalamaresui] Install libcalamaresui headers - All the headers go to relevant subdirs, but we don't keep libcalamares and libcalamaresui apart. - While here, remove unused variable from libcalamares CMake --- src/libcalamares/CMakeLists.txt | 7 +++++-- src/libcalamaresui/CMakeLists.txt | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index a7b4472d5..0516b5613 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -177,6 +177,9 @@ target_link_libraries( calamares ${OPTIONAL_PUBLIC_LIBRARIES} ) +### Installation +# +# install( TARGETS calamares EXPORT Calamares RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -193,19 +196,19 @@ install( CODE " # Install header files file( GLOB rootHeaders "*.h" ) -file( GLOB utilsHeaders "utils/*.h" ) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.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 # # diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 9d7b7a85c..773fdf617 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -83,3 +83,25 @@ endif() if( WITH_QML ) target_link_libraries( calamaresui PUBLIC Qt5::QuickWidgets ) endif() + + +### Installation +# +# +# The library is already installed through calamares_add_library(), +# so we only need to do headers. Unlike the Calamares source tree, +# where libcalamares and libcalamaresui live in different branches, +# we're going to glom it all together in the installed headers location. + +install( + FILES + Branding.h + ViewManager.h + DESTINATION include/libcalamares +) + +# Install each subdir-worth of header files +foreach( subdir modulesystem utils viewpages widgets ) + file( GLOB subdir_headers "${subdir}/*.h" ) + install( FILES ${subdir_headers} DESTINATION include/libcalamares/${subdir} ) +endforeach() From 3ae519b8ed577fdd7025ed7f6719ad0a173b3323 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 10 Jun 2020 16:58:17 +0200 Subject: [PATCH 13/13] Documentation: uncomment oem-setup - Calamares complains if this isn't set, so the example should probably be 'safe' from that complaint. With 3.3 plans including 'fatal error instead of warning' this should be fixed on-time. --- settings.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.conf b/settings.conf index 982f4ebbe..8bff02373 100644 --- a/settings.conf +++ b/settings.conf @@ -166,7 +166,7 @@ dont-chroot: false # If this is set to true, Calamares refers to itself as a "setup program" # rather than an "installer". Defaults to the value of dont-chroot, but # Calamares will complain if this is not explicitly set. -# oem-setup: true +oem-setup: false # If this is set to true, the "Cancel" button will be disabled entirely. # The button is also hidden from view.