File: OpmInstall.cmake

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (74 lines) | stat: -rw-r--r-- 3,080 bytes parent folder | download | duplicates (3)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# - Installation macro
#
# Set up installation targets for the binary library. The following
# suffices must be defined for the prefix passed as parameter:
#
# _NAME             Name of the library
# _HEADERS          List of header files to install
# _TARGET           CMake target which builds the library
# _LIBRARY_TYPE     Static or shared library
# _DEBUG            File containing debug symbols
include (GNUInstallDirs)

macro (opm_install opm)
  foreach (_hdr IN LISTS ${opm}_HEADERS)
	get_filename_component (_dir ${_hdr} PATH)
	file (RELATIVE_PATH _rel_dir "${PROJECT_SOURCE_DIR}" "${_dir}")
	install (
	  FILES ${_hdr}
	  DESTINATION include${${opm}_VER_DIR}/${_rel_dir}
	  )
  endforeach (_hdr)
  install (
	TARGETS ${${opm}_TARGET} ${${opm}_EXTRA_TARGETS}
	EXPORT ${opm}-targets
	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
	ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
	)
  if(NOT "${${opm}_TARGET}" STREQUAL "")
    export(TARGETS ${${opm}_TARGET} ${${opm}_EXTRA_TARGETS}
            FILE ${opm}-targets.cmake)
    install(EXPORT ${opm}-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${opm})
  endif()
  # only /usr/lib/debug seems to be searched for debug info; if we have
  # write access to that directory (package installation), then default
  # to use it; otherwise put the debug files together with the library
  # (local installation). everything can be overridden by the option.
  if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
	set (_sys_dbg_def ON)
  else (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
	set (_sys_dbg_def OFF)
  endif (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
  option (SYSTEM_DEBUG "Put .debug files in GDB debug file directory" ${_sys_dbg_def})
  set (DEBUG_FILE_DIRECTORY /usr/lib/debug CACHE PATH "GDB debug file directory")
  mark_as_advanced (DEBUG_FILE_DIRECTORY)
  if (SYSTEM_DEBUG AND NOT APPLE)
	set (_dbg_prefix "${DEBUG_FILE_DIRECTORY}/")
  else (SYSTEM_DEBUG AND NOT APPLE)
	set (_dbg_prefix "")
  endif (SYSTEM_DEBUG AND NOT APPLE)
  # static libraries don't have their debug info stripped, so there is
  # only a separate file when we are building shared objects
  if (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
	# on MacOS X, debug files are actually bundles (directories)
	if (APPLE)
	  set (_dbg_type DIRECTORY)
	else ()
	  set (_dbg_type FILES)
	endif ()
	install (
	  ${_dbg_type} ${PROJECT_BINARY_DIR}/${${opm}_DEBUG}
	  DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
	  )
  endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
  # note that the DUNE parts that looks for dune.module is currently (2013-09) not
  # multiarch-aware and will thus put in lib64/ on RHEL and lib/ on Debian
  install (
	FILES ${PROJECT_SOURCE_DIR}/dune.module
	DESTINATION lib/${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME}
	)
  install (
        FILES ${PROJECT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}-prereqs.cmake
        DESTINATION ${CMAKE_INSTALL_PREFIX}/share/opm/cmake/Modules
        )
endmacro (opm_install opm)