7 executable_path_postexcluded
10 loader_path_postexcluded
15 rpath_executable_path_bundle
16 rpath_executable_path_postexcluded
18 rpath_loader_path_unresolved
19 rpath_loader_path_postexcluded
26 file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c")
27 add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
28 foreach(name ${testlib_names})
29 if(name STREQUAL "normal")
30 file(WRITE "${CMAKE_BINARY_DIR}/normal.c" "extern void rpath(void);\nvoid normal(void)\n{\n rpath();\n}\n")
32 file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n")
34 add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c")
36 file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "extern void ${name}(void);\n")
38 file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "void testlib(void)\n{\n")
39 foreach(name ${testlib_names})
40 file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" " ${name}();\n")
42 file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "}\n")
43 set_property(TARGET ${testlib_names} PROPERTY BUILD_WITH_INSTALL_NAME_DIR 1)
44 target_link_libraries(normal PRIVATE rpath)
45 set_property(TARGET normal PROPERTY INSTALL_RPATH
46 "${CMAKE_BINARY_DIR}/root-all/executable/lib/normal/../rpath"
49 file(WRITE "${CMAKE_BINARY_DIR}/testlib_conflict.c" "extern void conflict(void);\nvoid testlib_conflict(void)\n{\n conflict();\n}\n")
50 add_library(testlib_conflict SHARED "${CMAKE_BINARY_DIR}/testlib_conflict.c")
51 target_link_libraries(testlib_conflict PRIVATE conflict)
53 set_property(TARGET testlib PROPERTY INSTALL_RPATH
54 "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath"
55 "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_unresolved"
56 "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_postexcluded"
57 "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict"
58 @executable_path/../lib/rpath_executable_path
59 @executable_path/../lib/rpath_executable_path_unresolved
60 @executable_path/../lib/rpath_executable_path_postexcluded
61 @loader_path/rpath_loader_path
62 @loader_path/rpath_loader_path_unresolved
63 @loader_path/rpath_loader_path_postexcluded
65 set_property(TARGET testlib_conflict PROPERTY INSTALL_RPATH
66 "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict2"
71 executable_path_postexcluded
73 loader_path_postexcluded
77 rpath_executable_path_postexcluded
79 rpath_loader_path_postexcluded
82 install(TARGETS ${t} DESTINATION executable/lib/${t})
84 install(TARGETS conflict DESTINATION executable/lib/conflict2)
87 executable_path_bundle
88 executable_path_postexcluded
89 loader_path_postexcluded
91 rpath_executable_path_bundle
92 rpath_executable_path_postexcluded
93 rpath_loader_path_postexcluded
95 install(TARGETS ${t} DESTINATION bundle_executable/lib/${t})
98 foreach(t executable_path executable_path_bundle executable_path_postexcluded)
99 set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @executable_path/../lib/${t})
102 foreach(t loader_path loader_path_unresolved loader_path_postexcluded)
103 set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @loader_path/${t})
110 rpath_executable_path
111 rpath_executable_path_bundle
112 rpath_executable_path_postexcluded
114 rpath_loader_path_unresolved
115 rpath_loader_path_postexcluded
118 set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @rpath)
121 foreach(t normal normal_unresolved normal_postexcluded)
122 set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR "${CMAKE_BINARY_DIR}/root-all/executable/lib/${t}")
123 if(NOT t STREQUAL "normal_unresolved")
124 install(TARGETS ${t} DESTINATION executable/lib/${t})
128 target_link_libraries(testlib PRIVATE ${testlib_names})
130 add_executable(topexe macos/topexe.c)
131 add_library(toplib SHARED macos/toplib.c)
132 add_library(topmod MODULE macos/toplib.c)
133 target_link_libraries(topexe PRIVATE testlib)
134 target_link_libraries(toplib PRIVATE testlib)
135 target_link_libraries(topmod PRIVATE testlib)
137 set_property(TARGET topexe toplib topmod PROPERTY INSTALL_RPATH "${CMAKE_BINARY_DIR}/root-all/executable/lib")
139 install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION executable/bin LIBRARY DESTINATION executable/lib)
140 install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION bundle_executable/bin LIBRARY DESTINATION bundle_executable/lib)
143 function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile)
144 file(GET_RUNTIME_DEPENDENCIES
145 RESOLVED_DEPENDENCIES_VAR deps
146 UNRESOLVED_DEPENDENCIES_VAR udeps
147 CONFLICTING_DEPENDENCIES_PREFIX cdeps
148 PRE_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|executable_path_postexcluded|loader_path|loader_path_unresolved|loader_path_postexcluded|rpath|rpath_unresolved|rpath_postexcluded|rpath_executable_path|rpath_executable_path_bundle|rpath_executable_path_postexcluded|rpath_loader_path|rpath_loader_path_unresolved|rpath_loader_path_postexcluded|normal|normal_unresolved|normal_postexcluded|conflict|System\\.B)\\.dylib$"
149 PRE_EXCLUDE_REGEXES ".*"
150 POST_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|loader_path|rpath|rpath_executable_path|rpath_executable_path_bundle|rpath_loader_path|normal|conflict|System\\.B)\\.dylib$"
151 POST_EXCLUDE_REGEXES ".*"
156 list(SORT cdeps_FILENAMES)
157 file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}")
158 file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}")
159 file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "")
160 foreach(cdep IN LISTS cdeps_FILENAMES)
161 set(cdep_values ${cdeps_${cdep}})
162 list(SORT cdep_values)
163 file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n")
167 exec_get_runtime_dependencies(
168 deps1.txt udeps1.txt cdeps1.txt
170 "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>"
172 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
175 exec_get_runtime_dependencies(
176 deps2.txt udeps2.txt cdeps2.txt
178 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>"
179 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
182 exec_get_runtime_dependencies(
183 deps3.txt udeps3.txt cdeps3.txt
185 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>"
187 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
190 exec_get_runtime_dependencies(
191 deps4.txt udeps4.txt cdeps4.txt
193 "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>"
195 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
197 "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"
200 exec_get_runtime_dependencies(
201 deps5.txt udeps5.txt cdeps5.txt
203 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>"
204 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
205 BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"
208 exec_get_runtime_dependencies(
209 deps6.txt udeps6.txt cdeps6.txt
211 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>"
213 "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
214 BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"