From 5f6978d603005d04480b45a142cdd4f61c4b92f8 Mon Sep 17 00:00:00 2001 From: Debian Science Maintainers Date: Fri, 22 Nov 2024 15:28:16 +0100 Subject: [PATCH] Install cmake config of header-only module in /usr/lib/cmake Needed to make it work in multiarch settings. Author: Markus Blatt Gbp-Pq: Name install-cmake-config-to-lib-headerless --- cmake/modules/DuneAddLibrary.cmake | 3 ++- cmake/modules/DuneProject.cmake | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/modules/DuneAddLibrary.cmake b/cmake/modules/DuneAddLibrary.cmake index 9342c62..744066b 100644 --- a/cmake/modules/DuneAddLibrary.cmake +++ b/cmake/modules/DuneAddLibrary.cmake @@ -135,7 +135,6 @@ Add a library to a Dune module. #]=======================================================================] include_guard(GLOBAL) - # Public interface for creating a module library function(dune_add_library _name) cmake_parse_arguments(ARG "OBJECT;INTERFACE" "" "" ${ARGN}) @@ -210,6 +209,8 @@ function(dune_add_library_normal _name) set(ARG_NAMESPACE Dune::) endif() + set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_LIB ON) + set(alias ${ARG_NAMESPACE}${ARG_EXPORT_NAME}) if(NOT TARGET ${alias}) add_library(${alias} ALIAS ${_name}) diff --git a/cmake/modules/DuneProject.cmake b/cmake/modules/DuneProject.cmake index 635dc4c..63d870a 100644 --- a/cmake/modules/DuneProject.cmake +++ b/cmake/modules/DuneProject.cmake @@ -343,7 +343,15 @@ endif()") if(DEFINED DUNE_INSTALL_LIBDIR) message(DEPRECATION "DUNE_INSTALL_LIBDIR is deprecated, use CMAKE_INSTALL_LIBDIR instead") else() - set(DUNE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) + # Determine whether this module is header-only + # In the case the property is not defined + get_property(_has_lib GLOBAL PROPERTY ${PROJECT_NAME}_HAS_LIB SET) + + if(_has_lib) + set(DUNE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) + else() + set(DUNE_INSTALL_LIBDIR ${DUNE_INSTALL_NONOBJECTLIBDIR}) + endif() endif() # Set the location of the doc file source. Needed by custom package configuration @@ -446,7 +454,7 @@ get_filename_component(_dir \"\${CMAKE_CURRENT_LIST_FILE}\" PATH) # install library export set install(EXPORT ${_export_set} - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${ProjectName} + DESTINATION ${DUNE_INSTALL_LIBDIR}/cmake/${ProjectName} NAMESPACE ${_namespace} FILE ${_target_file}) -- 2.30.2