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.
This commit is contained in:
parent
f59b6da799
commit
dc16afac4a
@ -532,7 +532,9 @@ configure_file(
|
|||||||
|
|
||||||
# Early configure these files as we need them later on
|
# Early configure these files as we need them later on
|
||||||
set( CALAMARES_CMAKE_DIR "${CMAKE_SOURCE_DIR}/CMakeModules" )
|
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 )
|
add_subdirectory( src )
|
||||||
|
|
||||||
@ -570,6 +572,13 @@ write_basic_package_version_file(
|
|||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion
|
COMPATIBILITY SameMajorVersion
|
||||||
)
|
)
|
||||||
|
export( PACKAGE Calamares )
|
||||||
|
install(
|
||||||
|
EXPORT Calamares
|
||||||
|
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
FILE "CalamaresTargets.cmake"
|
||||||
|
NAMESPACE Calamares::
|
||||||
|
)
|
||||||
|
|
||||||
# Install the cmake files
|
# Install the cmake files
|
||||||
install(
|
install(
|
||||||
@ -588,14 +597,6 @@ install(
|
|||||||
"${CMAKE_INSTALL_CMAKEDIR}"
|
"${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install the export set for use with the install-tree
|
|
||||||
install(
|
|
||||||
EXPORT
|
|
||||||
CalamaresLibraryDepends
|
|
||||||
DESTINATION
|
|
||||||
"${CMAKE_INSTALL_CMAKEDIR}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if( INSTALL_CONFIG )
|
if( INSTALL_CONFIG )
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
|
@ -93,7 +93,7 @@ function(calamares_add_library)
|
|||||||
|
|
||||||
# add link targets
|
# add link targets
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
LINK_PUBLIC ${CALAMARES_LIBRARIES}
|
LINK_PUBLIC ${Calamares_LIBRARIES}
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Gui
|
Qt5::Gui
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
|
@ -1,20 +1,68 @@
|
|||||||
# Config file for the Calamares package
|
# 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:
|
# For legacy use it defines the following variables:
|
||||||
# - Calamares_INCLUDE_DIRS - include directories for Calamares
|
# - Calamares_INCLUDE_DIRS - include directories for Calamares
|
||||||
# - Calamares_LIB_DIRS - library directories
|
# - Calamares_LIB_DIRS - library directories
|
||||||
# - Calamares_LIBRARIES - libraries to link against (e.g. -lcalamares)
|
# - Calamares_LIBRARIES - libraries to link against
|
||||||
|
|
||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
### Versioning and IMPORTED targets
|
||||||
|
#
|
||||||
|
#
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresConfigVersion.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresConfigVersion.cmake)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresTargets.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_LIB_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
|
||||||
set(Calamares_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
set(Calamares_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||||
set(Calamares_LIBRARIES calamares)
|
set(Calamares_LIBRARIES Calamares::calamares)
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddLibrary.cmake)
|
### CMake support
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddModuleSubdirectory.cmake)
|
#
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddPlugin.cmake)
|
#
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CalamaresAddBrandingSubdirectory.cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
include(CalamaresAddLibrary)
|
||||||
|
include(CalamaresAddModuleSubdirectory)
|
||||||
|
include(CalamaresAddPlugin)
|
||||||
|
include(CalamaresAddBrandingSubdirectory)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# === This file is part of Calamares - <https://github.com/calamares> ===
|
# === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
#
|
#
|
||||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||||
#
|
#
|
||||||
# Calamares is free software: you can redistribute it and/or modify
|
# Calamares is free software: you can redistribute it and/or modify
|
||||||
@ -177,7 +177,7 @@ target_link_libraries( calamares
|
|||||||
)
|
)
|
||||||
|
|
||||||
install( TARGETS calamares
|
install( TARGETS calamares
|
||||||
EXPORT CalamaresLibraryDepends
|
EXPORT Calamares
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
@ -67,7 +67,7 @@ calamares_add_library( calamaresui
|
|||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
Qt5::Svg
|
Qt5::Svg
|
||||||
RESOURCES libcalamaresui.qrc
|
RESOURCES libcalamaresui.qrc
|
||||||
EXPORT CalamaresLibraryDepends
|
EXPORT Calamares
|
||||||
VERSION ${CALAMARES_VERSION_SHORT}
|
VERSION ${CALAMARES_VERSION_SHORT}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user