forked from cmakelib/cmakelib-component-cmdef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMDEF_INSTALL.cmake
79 lines (70 loc) · 1.91 KB
/
CMDEF_INSTALL.cmake
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
75
76
77
78
79
## Main
#
# Install library targets created by CMDEF_ADD_LIBRARY
#
IF(DEFINED CMDEF_INSTALL_MODULE)
RETURN()
ENDIF()
SET(CMDEF_INSTALL_MODULE 1)
FIND_PACKAGE(CMLIB)
##
# Installs given target.
#
# If the CONFIGURATIONS is specified function installs
# target only for given list of build types.
# If no CONFIGURATIONS is specified that the target is installed
# for each build type
#
# Workflow:
# - If the given target has INSTALL_INCLUDE_DIRECTORIES property
# (created by CMDEF_ADD_LIBRARY)
# - Set DESTINATION for all types
# - Export this
#
# <function>(
# TARGET <target>
# [CONFIGURATIONS <configurations>]
# )
#
FUNCTION(CMDEF_INSTALL)
CMLIB_PARSE_ARGUMENTS(
MULTI_VALUE
CONFIGURATIONS
ONE_VALUE
TARGET
REQUIRED
TARGET
P_ARGN ${ARGN}
)
IF(NOT DEFINED __CONFIGURATIONS)
SET(__CONFIGURATIONS ${CMDEF_BUILD_TYPE_LIST_UPPERCASE})
ENDIF()
SET(original_target ${__TARGET})
CMDEF_ADD_LIBRARY_CHECK(${__TARGET} cmdef_target)
IF(cmdef_target)
SET(original_target ${cmdef_target})
GET_PROPERTY(include_dirs TARGET ${original_target} PROPERTY CMDEF_INSTALL_INCLUDE_DIRECTORIES)
IF(NOT include_dirs STREQUAL "NOTFOUND")
TARGET_INCLUDE_DIRECTORIES(${original_target} INTERFACE $<INSTALL_INTERFACE:${CMDEF_INCLUDE_INSTALL_DIR}>)
FOREACH(dir IN LISTS include_dirs)
INSTALL(DIRECTORY ${dir}
CONFIGURATIONS ${__CONFIGURATIONS}
DESTINATION "${CMDEF_INCLUDE_INSTALL_DIR}"
)
ENDFOREACH()
ENDIF()
ENDIF()
INSTALL(TARGETS ${original_target}
CONFIGURATIONS ${__CONFIGURATIONS}
EXPORT ${original_target}
ARCHIVE DESTINATION "${CMDEF_LIBRARY_INSTALL_DIR}"
LIBRARY DESTINATION "${CMDEF_LIBRARY_INSTALL_DIR}"
RUNTIME DESTINATION "${CMDEF_BINARY_INSTALL_DIR}"
BUNDLE DESTINATION "${CMDEF_BINARY_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${CMDEF_INCLUDE_INSTALL_DIR}"
)
INSTALL(EXPORT ${original_target}
CONFIGURATIONS ${__CONFIGURATIONS}
DESTINATION "cmake/"
)
ENDFUNCTION()