File: install-cmake-config-to-lib-headerless

package info (click to toggle)
dune-common 2.10.0-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,804 kB
  • sloc: cpp: 52,256; python: 3,979; sh: 1,658; makefile: 17
file content (52 lines) | stat: -rw-r--r-- 1,949 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Description: Install cmake config of header-only module in /usr/lib/cmake
 Needed to make it work in multiarch settings.
Author: Markus Blatt
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- 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})
--- 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_C
 
     # 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})