Enable parallel tests.
[hoomd-blue.git] / packaging / mac / fixup-bundle.cmake.in
blob1b90a28cff5ff8d13664c5b2cce36f41fd108249
1 include(BundleUtilities)
3 # due to the strange way that gp_resolve_item_override works, need to copy in the whole darn function
4 # the default function needs to be overridden so that cuda's funky linked @rpath/libtlshook.dylib can be resolved
6 function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var)
7   set(resolved 0)
8   set(resolved_item "${item}")
9   
10   # just remove rpath, we don't need it and doing so enables the lib to be found
11   if(item MATCHES "@rpath")
12       string(REPLACE "@rpath" "" ni "${item}")
13       set(item ${ni})
14   endif(item MATCHES "@rpath")
15    
16   # THE REST OF THIS FUNCTION IS AS IS FROM CMAKE, exept where the override is not called and resolved_var is set
18   # Is it already resolved?
19   #
20   if(EXISTS "${resolved_item}")
21     set(resolved 1)
22   endif(EXISTS "${resolved_item}")
24   if(NOT resolved)
25     if(item MATCHES "@executable_path")
26       #
27       # @executable_path references are assumed relative to exepath
28       #
29       string(REPLACE "@executable_path" "${exepath}" ri "${item}")
30       get_filename_component(ri "${ri}" ABSOLUTE)
32       if(EXISTS "${ri}")
33         #message(STATUS "info: embedded item exists (${ri})")
34         set(resolved 1)
35         set(resolved_item "${ri}")
36       else(EXISTS "${ri}")
37         message(STATUS "warning: embedded item does not exist '${ri}'")
38       endif(EXISTS "${ri}")
39     endif(item MATCHES "@executable_path")
40   endif(NOT resolved)
42   if(NOT resolved)
43     if(item MATCHES "@loader_path")
44       #
45       # @loader_path references are assumed relative to the
46       # PATH of the given "context" (presumably another library)
47       #
48       get_filename_component(contextpath "${context}" PATH)
49       string(REPLACE "@loader_path" "${contextpath}" ri "${item}")
50       get_filename_component(ri "${ri}" ABSOLUTE)
52       if(EXISTS "${ri}")
53         #message(STATUS "info: embedded item exists (${ri})")
54         set(resolved 1)
55         set(resolved_item "${ri}")
56       else(EXISTS "${ri}")
57         message(STATUS "warning: embedded item does not exist '${ri}'")
58       endif(EXISTS "${ri}")
59     endif(item MATCHES "@loader_path")
60   endif(NOT resolved)
62   if(NOT resolved)
63     set(ri "ri-NOTFOUND")
64     find_file(ri "${item}" ${exepath} ${dirs} NO_DEFAULT_PATH)
65     find_file(ri "${item}" ${exepath} ${dirs} /usr/lib)
66     if(ri)
67       #message(STATUS "info: 'find_file' in exepath/dirs (${ri})")
68       set(resolved 1)
69       set(resolved_item "${ri}")
70       set(ri "ri-NOTFOUND")
71     endif(ri)
72   endif(NOT resolved)
74   if(NOT resolved)
75     if(item MATCHES "[^/]+\\.framework/")
76       set(fw "fw-NOTFOUND")
77       find_file(fw "${item}"
78         "~/Library/Frameworks"
79         "/Library/Frameworks"
80         "/System/Library/Frameworks"
81       )
82       if(fw)
83         #message(STATUS "info: 'find_file' found framework (${fw})")
84         set(resolved 1)
85         set(resolved_item "${fw}")
86         set(fw "fw-NOTFOUND")
87       endif(fw)
88     endif(item MATCHES "[^/]+\\.framework/")
89   endif(NOT resolved)
91   # Using find_program on Windows will find dll files that are in the PATH.
92   # (Converting simple file names into full path names if found.)
93   #
94   if(WIN32 AND NOT UNIX)
95   if(NOT resolved)
96     set(ri "ri-NOTFOUND")
97     find_program(ri "${item}" PATHS "${exepath};${dirs}" NO_DEFAULT_PATH)
98     find_program(ri "${item}" PATHS "${exepath};${dirs}")
99     if(ri)
100       #message(STATUS "info: 'find_program' in exepath/dirs (${ri})")
101       set(resolved 1)
102       set(resolved_item "${ri}")
103       set(ri "ri-NOTFOUND")
104     endif(ri)
105   endif(NOT resolved)
106   endif(WIN32 AND NOT UNIX)
108   if(NOT resolved)
109     message(STATUS "
110 warning: cannot resolve item '${item}'
112   possible problems:
113     need more directories?
114     need to use InstallRequiredSystemLibraries?
115     run in install tree instead of build tree?
117 #    message(STATUS "
118 #******************************************************************************
119 #warning: cannot resolve item '${item}'
121 #  possible problems:
122 #    need more directories?
123 #    need to use InstallRequiredSystemLibraries?
124 #    run in install tree instead of build tree?
126 #    context='${context}'
127 #    item='${item}'
128 #    exepath='${exepath}'
129 #    dirs='${dirs}'
130 #    resolved_item_var='${resolved_item_var}'
131 #******************************************************************************
133   endif(NOT resolved)
135   set(${resolved_item_var} "${resolved_item}" PARENT_SCOPE)
136   set(${resolved_var} "${resolved}" PARENT_SCOPE)
138 endfunction(gp_resolve_item_override)
140 fixup_bundle("${CMAKE_INSTALL_PREFIX}/HOOMD-blue.app"
141              "${CMAKE_INSTALL_PREFIX}/@BIN_INSTALL_DIR@/hoomd.so"
142              "@_libdirs@")