summaryrefslogtreecommitdiff
path: root/cmake/macos/fixup_bundle.cmake
blob: 10b82d939f20e3f9c627931b5724859bc4f8c6aa (plain)
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
# Run at build time (cmake -P) to copy non-system dylibs the executable links
# against into the .app's Contents/Frameworks and rewrite the load paths, making
# the bundle self-contained / portable. Invoked from apple_bundle.cmake.
#
# Expects -D APP_BUNDLE=<abs path to SpaghettiKart.app> -D EXECUTABLE_NAME=SpaghettiKart

include(BundleUtilities)

set(APP "${APP_BUNDLE}/Contents/MacOS/${EXECUTABLE_NAME}")
file(REAL_PATH "${APP}" APP)

# Where fixup_bundle should look for the dependencies it needs to copy in.
set(SEARCH_DIRS
    "/opt/homebrew/lib"          # Homebrew (Apple Silicon)
    "/usr/local/lib"             # Homebrew (Intel) / misc
    "/opt/local/lib"             # MacPorts
    "${APP_BUNDLE}/Contents/Frameworks"
)

set(RESOLVED_DIRS "")
foreach(DIR IN LISTS SEARCH_DIRS)
    if (EXISTS "${DIR}")
        file(REAL_PATH "${DIR}" RESOLVED_DIR)
        list(APPEND RESOLVED_DIRS "${RESOLVED_DIR}")
    endif()
endforeach()

message(STATUS "fixup_bundle: ${APP}")
message(STATUS "fixup_bundle search dirs: ${RESOLVED_DIRS}")

fixup_bundle("${APP}" "" "${RESOLVED_DIRS}")