Merge branch 'issue-1428'

Install all the relevant CMake, libcalamares and libcalamaresui
files -- config and headers -- so that external modules can be
created (again). This support had severely bitrotted, so
that the only effective way to add modules was to do so inside
the Calamares build tree. Now it's independent again.

FIXES #1428
This commit is contained in:
Adriaan de Groot 2020-06-10 17:27:41 +02:00
commit 6c40d69574
11 changed files with 169 additions and 137 deletions

View File

@ -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
#
@ -520,16 +523,10 @@ 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
)
# 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 Calamares is installed,
# the CalamaresConfig.cmake module sets this variable to the IMPORTED
# libraries for Calamares.
set( Calamares_LIBRARIES calamares )
add_subdirectory( src )
@ -539,32 +536,39 @@ 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
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 )
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
)
install(
EXPORT Calamares
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
FILE "CalamaresTargets.cmake"
NAMESPACE Calamares::
)
# 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"
@ -573,48 +577,36 @@ install(
"CMakeModules/CalamaresAddTranslations.cmake"
"CMakeModules/CalamaresAutomoc.cmake"
"CMakeModules/CMakeColors.cmake"
"CMakeModules/FindYAMLCPP.cmake"
DESTINATION
"${CMAKE_INSTALL_CMAKEDIR}"
)
# Install the export set for use with the install-tree
install(
EXPORT
CalamaresLibraryDepends
DESTINATION
"${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

View File

@ -93,11 +93,10 @@ 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
${LIBRARY_QT5_MODULES}
)
if(LIBRARY_LINK_LIBRARIES)
target_link_libraries(${target} LINK_PUBLIC ${LIBRARY_LINK_LIBRARIES})

View File

@ -1,4 +0,0 @@
set(CALAMARES_INCLUDE_DIRS
"@PROJECT_SOURCE_DIR@/src/libcalamares"
"@PROJECT_BINARY_DIR@/src/libcalamares"
)

View File

@ -1,32 +1,78 @@
# 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}")
# 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
# 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")
@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()
# Our library dependencies (contains definitions for IMPORTED targets)
include("${CALAMARES_CMAKE_DIR}/CalamaresLibraryDepends.cmake")
### Legacy support
#
#
set(Calamares_LIB_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
set(Calamares_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set(Calamares_LIBRARIES Calamares::calamares)
# These are IMPORTED targets created by CalamaresLibraryDepends.cmake
set(CALAMARES_LIBRARIES calamares)
### CMake support
#
#
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
# Convenience variables
set(CALAMARES_USE_FILE "${CALAMARES_CMAKE_DIR}/CalamaresUse.cmake")
set(CALAMARES_APPLICATION_NAME "Calamares")
include(CalamaresAddBrandingSubdirectory)
include(CalamaresAddLibrary)
include(CalamaresAddModuleSubdirectory)
include(CalamaresAddPlugin)
# 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@)

View File

@ -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()

View File

@ -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 )

View File

@ -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.

View File

@ -163,21 +163,25 @@ set_target_properties( calamares
PROPERTIES
VERSION ${CALAMARES_VERSION_SHORT}
SOVERSION ${CALAMARES_VERSION_SHORT}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_INSTALL_FULL_INCLUDEDIR}/libcalamares
)
calamares_automoc( calamares )
target_link_libraries( calamares
LINK_PRIVATE
${OPTIONAL_PRIVATE_LIBRARIES}
LINK_PUBLIC
yamlcpp
LINK_PUBLIC
Qt5::Core
KF5::CoreAddons
${OPTIONAL_PUBLIC_LIBRARIES}
)
### Installation
#
#
install( TARGETS calamares
EXPORT CalamaresLibraryDepends
EXPORT Calamares
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@ -192,13 +196,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
${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()
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 )
### TESTING
#

View File

@ -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

View File

@ -66,8 +66,9 @@ calamares_add_library( calamaresui
EXPORT_MACRO UIDLLEXPORT_PRO
LINK_LIBRARIES
Qt5::Svg
yamlcpp
RESOURCES libcalamaresui.qrc
EXPORT CalamaresLibraryDepends
EXPORT Calamares
VERSION ${CALAMARES_VERSION_SHORT}
)
@ -82,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()

View File

@ -26,5 +26,6 @@ calamares_add_test(
PackageModel.cpp
LIBRARIES
Qt5::Gui
yamlcpp
)