-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.cmake
55 lines (48 loc) · 2.2 KB
/
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
# ==============================================================================
# Install the library
# ==============================================================================
# for CMAKE_INSTALL_INCLUDEDIR and others definition
include(GNUInstallDirs)
# define the dircetory where the library will be installed CMAKE_INSTALL_PREFIX
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}-${PROJECT_VERSION}" CACHE PATH "Where the library will be installed to" FORCE)
# ==============================================================================
# Install specific compile definition
# ==============================================================================
if(ANIRA_WITH_INSTALL)
target_compile_definitions(${TARGET_NAME}
PUBLIC
INSTALL_VERSION
)
endif()
set(INSTALL_TARGETS ${TARGET_NAME}_Standalone ${TARGET_NAME}_VST3)
# at install the rpath is cleared by default so we have to set it again for the installed shared library to find the other libraries
# in this case we set the rpath to the directories where the other libraries are installed
# $ORIGIN in Linux is a special token that gets replaced by the directory of the library at runtime from that point we could navigate to the other libraries
# The same token for macOS is @loader_path
if(UNIX AND NOT APPLE)
foreach(TARGET ${INSTALL_TARGETS})
set_target_properties(${TARGET}
PROPERTIES
INSTALL_RPATH "$ORIGIN/../lib"
)
endforeach()
elseif(APPLE)
set(OSX_RPATHS "@loader_path/../lib;@loader_path/../../../../lib;@loader_path/../../../")
list(APPEND INSTALL_TARGETS ${TARGET_NAME}_AU)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
list(APPEND OSX_RPATHS "/opt/intel/oneapi/mkl/latest/lib")
endif()
foreach(TARGET ${INSTALL_TARGETS})
set_target_properties(${TARGET}
PROPERTIES
INSTALL_RPATH "${OSX_RPATHS}"
)
endforeach()
endif()
# install the target and create export-set
install(TARGETS ${INSTALL_TARGETS}
# these get default values from GNUInstallDirs
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
)