BundleUtilities.cmake 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. #.rst:
  2. # BundleUtilities
  3. # ---------------
  4. #
  5. # Functions to help assemble a standalone bundle application.
  6. #
  7. # A collection of CMake utility functions useful for dealing with .app
  8. # bundles on the Mac and bundle-like directories on any OS.
  9. #
  10. # The following functions are provided by this module:
  11. #
  12. # ::
  13. #
  14. # fixup_bundle
  15. # copy_and_fixup_bundle
  16. # verify_app
  17. # get_bundle_main_executable
  18. # get_dotapp_dir
  19. # get_bundle_and_executable
  20. # get_bundle_all_executables
  21. # get_item_key
  22. # get_item_rpaths
  23. # clear_bundle_keys
  24. # set_bundle_key_values
  25. # get_bundle_keys
  26. # copy_resolved_item_into_bundle
  27. # copy_resolved_framework_into_bundle
  28. # fixup_bundle_item
  29. # verify_bundle_prerequisites
  30. # verify_bundle_symlinks
  31. #
  32. # Requires CMake 2.6 or greater because it uses function, break and
  33. # PARENT_SCOPE. Also depends on GetPrerequisites.cmake.
  34. #
  35. # ::
  36. #
  37. # FIXUP_BUNDLE(<app> <libs> <dirs>)
  38. #
  39. # Fix up a bundle in-place and make it standalone, such that it can be
  40. # drag-n-drop copied to another machine and run on that machine as long
  41. # as all of the system libraries are compatible.
  42. #
  43. # If you pass plugins to fixup_bundle as the libs parameter, you should
  44. # install them or copy them into the bundle before calling fixup_bundle.
  45. # The "libs" parameter is a list of libraries that must be fixed up, but
  46. # that cannot be determined by otool output analysis. (i.e., plugins)
  47. #
  48. # Gather all the keys for all the executables and libraries in a bundle,
  49. # and then, for each key, copy each prerequisite into the bundle. Then
  50. # fix each one up according to its own list of prerequisites.
  51. #
  52. # Then clear all the keys and call verify_app on the final bundle to
  53. # ensure that it is truly standalone.
  54. #
  55. # As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
  56. # which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
  57. #
  58. # ::
  59. #
  60. # COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>)
  61. #
  62. # Makes a copy of the bundle <src> at location <dst> and then fixes up
  63. # the new copied bundle in-place at <dst>...
  64. #
  65. # ::
  66. #
  67. # VERIFY_APP(<app>)
  68. #
  69. # Verifies that an application <app> appears valid based on running
  70. # analysis tools on it. Calls "message(FATAL_ERROR" if the application
  71. # is not verified.
  72. #
  73. # As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
  74. # which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
  75. #
  76. # ::
  77. #
  78. # GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>)
  79. #
  80. # The result will be the full path name of the bundle's main executable
  81. # file or an "error:" prefixed string if it could not be determined.
  82. #
  83. # ::
  84. #
  85. # GET_DOTAPP_DIR(<exe> <dotapp_dir_var>)
  86. #
  87. # Returns the nearest parent dir whose name ends with ".app" given the
  88. # full path to an executable. If there is no such parent dir, then
  89. # simply return the dir containing the executable.
  90. #
  91. # The returned directory may or may not exist.
  92. #
  93. # ::
  94. #
  95. # GET_BUNDLE_AND_EXECUTABLE(<app> <bundle_var> <executable_var> <valid_var>)
  96. #
  97. # Takes either a ".app" directory name or the name of an executable
  98. # nested inside a ".app" directory and returns the path to the ".app"
  99. # directory in <bundle_var> and the path to its main executable in
  100. # <executable_var>
  101. #
  102. # ::
  103. #
  104. # GET_BUNDLE_ALL_EXECUTABLES(<bundle> <exes_var>)
  105. #
  106. # Scans the given bundle recursively for all executable files and
  107. # accumulates them into a variable.
  108. #
  109. # ::
  110. #
  111. # GET_ITEM_KEY(<item> <key_var>)
  112. #
  113. # Given a file (item) name, generate a key that should be unique
  114. # considering the set of libraries that need copying or fixing up to
  115. # make a bundle standalone. This is essentially the file name including
  116. # extension with "." replaced by "_"
  117. #
  118. # This key is used as a prefix for CMake variables so that we can
  119. # associate a set of variables with a given item based on its key.
  120. #
  121. # ::
  122. #
  123. # CLEAR_BUNDLE_KEYS(<keys_var>)
  124. #
  125. # Loop over the list of keys, clearing all the variables associated with
  126. # each key. After the loop, clear the list of keys itself.
  127. #
  128. # Caller of get_bundle_keys should call clear_bundle_keys when done with
  129. # list of keys.
  130. #
  131. # ::
  132. #
  133. # SET_BUNDLE_KEY_VALUES(<keys_var> <context> <item> <exepath> <dirs>
  134. # <copyflag> [<rpaths>])
  135. #
  136. # Add a key to the list (if necessary) for the given item. If added,
  137. # also set all the variables associated with that key.
  138. #
  139. # ::
  140. #
  141. # GET_BUNDLE_KEYS(<app> <libs> <dirs> <keys_var>)
  142. #
  143. # Loop over all the executable and library files within the bundle (and
  144. # given as extra <libs>) and accumulate a list of keys representing
  145. # them. Set values associated with each key such that we can loop over
  146. # all of them and copy prerequisite libs into the bundle and then do
  147. # appropriate install_name_tool fixups.
  148. #
  149. # As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
  150. # which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
  151. #
  152. # ::
  153. #
  154. # COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
  155. #
  156. # Copy a resolved item into the bundle if necessary. Copy is not
  157. # necessary if the resolved_item is "the same as" the
  158. # resolved_embedded_item.
  159. #
  160. # ::
  161. #
  162. # COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
  163. #
  164. # Copy a resolved framework into the bundle if necessary. Copy is not
  165. # necessary if the resolved_item is "the same as" the
  166. # resolved_embedded_item.
  167. #
  168. # By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want
  169. # full frameworks embedded in your bundles, set
  170. # BU_COPY_FULL_FRAMEWORK_CONTENTS to ON before calling fixup_bundle. By
  171. # default, COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework
  172. # dylib itself plus the framework Resources directory.
  173. #
  174. # ::
  175. #
  176. # FIXUP_BUNDLE_ITEM(<resolved_embedded_item> <exepath> <dirs>)
  177. #
  178. # Get the direct/non-system prerequisites of the resolved embedded item.
  179. # For each prerequisite, change the way it is referenced to the value of
  180. # the _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely
  181. # changing to an "@executable_path" style reference.)
  182. #
  183. # This function requires that the resolved_embedded_item be "inside" the
  184. # bundle already. In other words, if you pass plugins to fixup_bundle
  185. # as the libs parameter, you should install them or copy them into the
  186. # bundle before calling fixup_bundle. The "libs" parameter is a list of
  187. # libraries that must be fixed up, but that cannot be determined by
  188. # otool output analysis. (i.e., plugins)
  189. #
  190. # Also, change the id of the item being fixed up to its own
  191. # _EMBEDDED_ITEM value.
  192. #
  193. # Accumulate changes in a local variable and make *one* call to
  194. # install_name_tool at the end of the function with all the changes at
  195. # once.
  196. #
  197. # If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be
  198. # marked writable before install_name_tool tries to change them.
  199. #
  200. # ::
  201. #
  202. # VERIFY_BUNDLE_PREREQUISITES(<bundle> <result_var> <info_var>)
  203. #
  204. # Verifies that the sum of all prerequisites of all files inside the
  205. # bundle are contained within the bundle or are "system" libraries,
  206. # presumed to exist everywhere.
  207. #
  208. # As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
  209. # which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
  210. #
  211. # ::
  212. #
  213. # VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>)
  214. #
  215. # Verifies that any symlinks found in the bundle point to other files
  216. # that are already also in the bundle... Anything that points to an
  217. # external file causes this function to fail the verification.
  218. #=============================================================================
  219. # Copyright 2008-2009 Kitware, Inc.
  220. #
  221. # Distributed under the OSI-approved BSD License (the "License");
  222. # see accompanying file Copyright.txt for details.
  223. #
  224. # This software is distributed WITHOUT ANY WARRANTY; without even the
  225. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  226. # See the License for more information.
  227. #=============================================================================
  228. # (To distribute this file outside of CMake, substitute the full
  229. # License text for the above reference.)
  230. # The functions defined in this file depend on the get_prerequisites function
  231. # (and possibly others) found in:
  232. #
  233. get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
  234. include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake")
  235. function(get_bundle_main_executable bundle result_var)
  236. set(result "error: '${bundle}/Contents/Info.plist' file does not exist")
  237. if(EXISTS "${bundle}/Contents/Info.plist")
  238. set(result "error: no CFBundleExecutable in '${bundle}/Contents/Info.plist' file")
  239. set(line_is_main_executable 0)
  240. set(bundle_executable "")
  241. # Read Info.plist as a list of lines:
  242. #
  243. set(eol_char "E")
  244. file(READ "${bundle}/Contents/Info.plist" info_plist)
  245. string(REPLACE ";" "\\;" info_plist "${info_plist}")
  246. string(REPLACE "\n" "${eol_char};" info_plist "${info_plist}")
  247. string(REPLACE "\r" "${eol_char};" info_plist "${info_plist}")
  248. # Scan the lines for "<key>CFBundleExecutable</key>" - the line after that
  249. # is the name of the main executable.
  250. #
  251. foreach(line ${info_plist})
  252. if(line_is_main_executable)
  253. string(REGEX REPLACE "^.*<string>(.*)</string>.*$" "\\1" bundle_executable "${line}")
  254. break()
  255. endif()
  256. if(line MATCHES "<key>CFBundleExecutable</key>")
  257. set(line_is_main_executable 1)
  258. endif()
  259. endforeach()
  260. if(NOT "${bundle_executable}" STREQUAL "")
  261. if(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}")
  262. set(result "${bundle}/Contents/MacOS/${bundle_executable}")
  263. else()
  264. # Ultimate goal:
  265. # If not in "Contents/MacOS" then scan the bundle for matching files. If
  266. # there is only one executable file that matches, then use it, otherwise
  267. # it's an error...
  268. #
  269. #file(GLOB_RECURSE file_list "${bundle}/${bundle_executable}")
  270. # But for now, pragmatically, it's an error. Expect the main executable
  271. # for the bundle to be in Contents/MacOS, it's an error if it's not:
  272. #
  273. set(result "error: '${bundle}/Contents/MacOS/${bundle_executable}' does not exist")
  274. endif()
  275. endif()
  276. else()
  277. #
  278. # More inclusive technique... (This one would work on Windows and Linux
  279. # too, if a developer followed the typical Mac bundle naming convention...)
  280. #
  281. # If there is no Info.plist file, try to find an executable with the same
  282. # base name as the .app directory:
  283. #
  284. endif()
  285. set(${result_var} "${result}" PARENT_SCOPE)
  286. endfunction()
  287. function(get_dotapp_dir exe dotapp_dir_var)
  288. set(s "${exe}")
  289. if(s MATCHES "/.*\\.app/")
  290. # If there is a ".app" parent directory,
  291. # ascend until we hit it:
  292. # (typical of a Mac bundle executable)
  293. #
  294. set(done 0)
  295. while(NOT ${done})
  296. get_filename_component(snamewe "${s}" NAME_WE)
  297. get_filename_component(sname "${s}" NAME)
  298. get_filename_component(sdir "${s}" PATH)
  299. set(s "${sdir}")
  300. if(sname MATCHES "\\.app$")
  301. set(done 1)
  302. set(dotapp_dir "${sdir}/${sname}")
  303. endif()
  304. endwhile()
  305. else()
  306. # Otherwise use a directory containing the exe
  307. # (typical of a non-bundle executable on Mac, Windows or Linux)
  308. #
  309. is_file_executable("${s}" is_executable)
  310. if(is_executable)
  311. get_filename_component(sdir "${s}" PATH)
  312. set(dotapp_dir "${sdir}")
  313. else()
  314. set(dotapp_dir "${s}")
  315. endif()
  316. endif()
  317. set(${dotapp_dir_var} "${dotapp_dir}" PARENT_SCOPE)
  318. endfunction()
  319. function(get_bundle_and_executable app bundle_var executable_var valid_var)
  320. set(valid 0)
  321. if(EXISTS "${app}")
  322. # Is it a directory ending in .app?
  323. if(IS_DIRECTORY "${app}")
  324. if(app MATCHES "\\.app$")
  325. get_bundle_main_executable("${app}" executable)
  326. if(EXISTS "${app}" AND EXISTS "${executable}")
  327. set(${bundle_var} "${app}" PARENT_SCOPE)
  328. set(${executable_var} "${executable}" PARENT_SCOPE)
  329. set(valid 1)
  330. #message(STATUS "info: handled .app directory case...")
  331. else()
  332. message(STATUS "warning: *NOT* handled - .app directory case...")
  333. endif()
  334. else()
  335. message(STATUS "warning: *NOT* handled - directory but not .app case...")
  336. endif()
  337. else()
  338. # Is it an executable file?
  339. is_file_executable("${app}" is_executable)
  340. if(is_executable)
  341. get_dotapp_dir("${app}" dotapp_dir)
  342. if(EXISTS "${dotapp_dir}")
  343. set(${bundle_var} "${dotapp_dir}" PARENT_SCOPE)
  344. set(${executable_var} "${app}" PARENT_SCOPE)
  345. set(valid 1)
  346. #message(STATUS "info: handled executable file in .app dir case...")
  347. else()
  348. get_filename_component(app_dir "${app}" PATH)
  349. set(${bundle_var} "${app_dir}" PARENT_SCOPE)
  350. set(${executable_var} "${app}" PARENT_SCOPE)
  351. set(valid 1)
  352. #message(STATUS "info: handled executable file in any dir case...")
  353. endif()
  354. else()
  355. message(STATUS "warning: *NOT* handled - not .app dir, not executable file...")
  356. endif()
  357. endif()
  358. else()
  359. message(STATUS "warning: *NOT* handled - directory/file does not exist...")
  360. endif()
  361. if(NOT valid)
  362. set(${bundle_var} "error: not a bundle" PARENT_SCOPE)
  363. set(${executable_var} "error: not a bundle" PARENT_SCOPE)
  364. endif()
  365. set(${valid_var} ${valid} PARENT_SCOPE)
  366. endfunction()
  367. function(get_bundle_all_executables bundle exes_var)
  368. set(exes "")
  369. if(UNIX)
  370. find_program(find_cmd "find")
  371. mark_as_advanced(find_cmd)
  372. endif()
  373. # find command is much quicker than checking every file one by one on Unix
  374. # which can take long time for large bundles, and since anyway we expect
  375. # executable to have execute flag set we can narrow the list much quicker.
  376. if(find_cmd)
  377. execute_process(COMMAND "${find_cmd}" "${bundle}"
  378. -type f \( -perm -0100 -o -perm -0010 -o -perm -0001 \)
  379. OUTPUT_VARIABLE file_list
  380. OUTPUT_STRIP_TRAILING_WHITESPACE
  381. )
  382. string(REPLACE "\n" ";" file_list "${file_list}")
  383. else()
  384. file(GLOB_RECURSE file_list "${bundle}/*")
  385. endif()
  386. foreach(f ${file_list})
  387. is_file_executable("${f}" is_executable)
  388. if(is_executable)
  389. set(exes ${exes} "${f}")
  390. endif()
  391. endforeach()
  392. set(${exes_var} "${exes}" PARENT_SCOPE)
  393. endfunction()
  394. function(get_item_rpaths item rpaths_var)
  395. if(APPLE)
  396. find_program(otool_cmd "otool")
  397. mark_as_advanced(otool_cmd)
  398. endif()
  399. if(otool_cmd)
  400. execute_process(
  401. COMMAND "${otool_cmd}" -l "${item}"
  402. OUTPUT_VARIABLE load_cmds_ov
  403. )
  404. string(REGEX REPLACE "[^\n]+cmd LC_RPATH\n[^\n]+\n[^\n]+path ([^\n]+) \\(offset[^\n]+\n" "rpath \\1\n" load_cmds_ov "${load_cmds_ov}")
  405. string(REGEX MATCHALL "rpath [^\n]+" load_cmds_ov "${load_cmds_ov}")
  406. string(REGEX REPLACE "rpath " "" load_cmds_ov "${load_cmds_ov}")
  407. if(load_cmds_ov)
  408. foreach(rpath ${load_cmds_ov})
  409. gp_append_unique(${rpaths_var} "${rpath}")
  410. endforeach()
  411. endif()
  412. endif()
  413. set(${rpaths_var} ${${rpaths_var}} PARENT_SCOPE)
  414. endfunction()
  415. function(get_item_key item key_var)
  416. get_filename_component(item_name "${item}" NAME)
  417. if(WIN32)
  418. string(TOLOWER "${item_name}" item_name)
  419. endif()
  420. string(REPLACE "." "_" ${key_var} "${item_name}")
  421. set(${key_var} ${${key_var}} PARENT_SCOPE)
  422. endfunction()
  423. function(clear_bundle_keys keys_var)
  424. foreach(key ${${keys_var}})
  425. set(${key}_ITEM PARENT_SCOPE)
  426. set(${key}_RESOLVED_ITEM PARENT_SCOPE)
  427. set(${key}_DEFAULT_EMBEDDED_PATH PARENT_SCOPE)
  428. set(${key}_EMBEDDED_ITEM PARENT_SCOPE)
  429. set(${key}_RESOLVED_EMBEDDED_ITEM PARENT_SCOPE)
  430. set(${key}_COPYFLAG PARENT_SCOPE)
  431. set(${key}_RPATHS PARENT_SCOPE)
  432. endforeach()
  433. set(${keys_var} PARENT_SCOPE)
  434. endfunction()
  435. function(set_bundle_key_values keys_var context item exepath dirs copyflag)
  436. if(ARGC GREATER 6)
  437. set(rpaths "${ARGV6}")
  438. else()
  439. set(rpaths "")
  440. endif()
  441. get_filename_component(item_name "${item}" NAME)
  442. get_item_key("${item}" key)
  443. list(LENGTH ${keys_var} length_before)
  444. gp_append_unique(${keys_var} "${key}")
  445. list(LENGTH ${keys_var} length_after)
  446. if(NOT length_before EQUAL length_after)
  447. gp_resolve_item("${context}" "${item}" "${exepath}" "${dirs}" resolved_item "${rpaths}")
  448. gp_item_default_embedded_path("${item}" default_embedded_path)
  449. get_item_rpaths("${resolved_item}" item_rpaths)
  450. if((NOT item MATCHES "\\.dylib$") AND (item MATCHES "[^/]+\\.framework/"))
  451. # For frameworks, construct the name under the embedded path from the
  452. # opening "${item_name}.framework/" to the closing "/${item_name}":
  453. #
  454. string(REGEX REPLACE "^.*(${item_name}.framework/.*/?${item_name}).*$" "${default_embedded_path}/\\1" embedded_item "${item}")
  455. else()
  456. # For other items, just use the same name as the original, but in the
  457. # embedded path:
  458. #
  459. set(embedded_item "${default_embedded_path}/${item_name}")
  460. endif()
  461. # Replace @executable_path and resolve ".." references:
  462. #
  463. string(REPLACE "@executable_path" "${exepath}" resolved_embedded_item "${embedded_item}")
  464. get_filename_component(resolved_embedded_item "${resolved_embedded_item}" ABSOLUTE)
  465. # *But* -- if we are not copying, then force resolved_embedded_item to be
  466. # the same as resolved_item. In the case of multiple executables in the
  467. # original bundle, using the default_embedded_path results in looking for
  468. # the resolved executable next to the main bundle executable. This is here
  469. # so that exes in the other sibling directories (like "bin") get fixed up
  470. # properly...
  471. #
  472. if(NOT copyflag)
  473. set(resolved_embedded_item "${resolved_item}")
  474. endif()
  475. set(${keys_var} ${${keys_var}} PARENT_SCOPE)
  476. set(${key}_ITEM "${item}" PARENT_SCOPE)
  477. set(${key}_RESOLVED_ITEM "${resolved_item}" PARENT_SCOPE)
  478. set(${key}_DEFAULT_EMBEDDED_PATH "${default_embedded_path}" PARENT_SCOPE)
  479. set(${key}_EMBEDDED_ITEM "${embedded_item}" PARENT_SCOPE)
  480. set(${key}_RESOLVED_EMBEDDED_ITEM "${resolved_embedded_item}" PARENT_SCOPE)
  481. set(${key}_COPYFLAG "${copyflag}" PARENT_SCOPE)
  482. set(${key}_RPATHS "${item_rpaths}" PARENT_SCOPE)
  483. set(${key}_RDEP_RPATHS "${rpaths}" PARENT_SCOPE)
  484. else()
  485. #message("warning: item key '${key}' already in the list, subsequent references assumed identical to first")
  486. endif()
  487. endfunction()
  488. function(get_bundle_keys app libs dirs keys_var)
  489. set(${keys_var} PARENT_SCOPE)
  490. set(options)
  491. set(oneValueArgs)
  492. set(multiValueArgs IGNORE_ITEM)
  493. cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
  494. get_bundle_and_executable("${app}" bundle executable valid)
  495. if(valid)
  496. # Always use the exepath of the main bundle executable for @executable_path
  497. # replacements:
  498. #
  499. get_filename_component(exepath "${executable}" PATH)
  500. # But do fixups on all executables in the bundle:
  501. #
  502. get_bundle_all_executables("${bundle}" exes)
  503. # Set keys for main executable first:
  504. #
  505. set_bundle_key_values(${keys_var} "${executable}" "${executable}" "${exepath}" "${dirs}" 0)
  506. # Get rpaths specified by main executable:
  507. #
  508. get_item_key("${executable}" executable_key)
  509. set(main_rpaths "${${executable_key}_RPATHS}")
  510. # For each extra lib, accumulate a key as well and then also accumulate
  511. # any of its prerequisites. (Extra libs are typically dynamically loaded
  512. # plugins: libraries that are prerequisites for full runtime functionality
  513. # but that do not show up in otool -L output...)
  514. #
  515. foreach(lib ${libs})
  516. set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
  517. set(prereqs "")
  518. set(ignoreFile FALSE)
  519. get_filename_component(prereq_filename ${lib} NAME)
  520. if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
  521. foreach(item ${CFG_IGNORE_ITEM})
  522. if("${item}" STREQUAL "${prereq_filename}")
  523. set(ignoreFile TRUE)
  524. endif()
  525. endforeach()
  526. endif()
  527. if(NOT ignoreFile)
  528. get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
  529. foreach(pr ${prereqs})
  530. set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
  531. endforeach()
  532. else()
  533. message(STATUS "Ignoring file: ${prereq_filename}")
  534. endif()
  535. endforeach()
  536. # For each executable found in the bundle, accumulate keys as we go.
  537. # The list of keys should be complete when all prerequisites of all
  538. # binaries in the bundle have been analyzed.
  539. #
  540. foreach(exe ${exes})
  541. # Main executable is scanned first above:
  542. #
  543. if(NOT "${exe}" STREQUAL "${executable}")
  544. # Add the exe itself to the keys:
  545. #
  546. set_bundle_key_values(${keys_var} "${exe}" "${exe}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
  547. # Get rpaths specified by executable:
  548. #
  549. get_item_key("${exe}" exe_key)
  550. set(exe_rpaths "${main_rpaths}" "${${exe_key}_RPATHS}")
  551. else()
  552. set(exe_rpaths "${main_rpaths}")
  553. endif()
  554. # Add each prerequisite to the keys:
  555. #
  556. set(prereqs "")
  557. set(ignoreFile FALSE)
  558. get_filename_component(prereq_filename ${exe} NAME)
  559. if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
  560. foreach(item ${CFG_IGNORE_ITEM})
  561. if("${item}" STREQUAL "${prereq_filename}")
  562. set(ignoreFile TRUE)
  563. endif()
  564. endforeach()
  565. endif()
  566. if(NOT ignoreFile)
  567. get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
  568. foreach(pr ${prereqs})
  569. set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
  570. endforeach()
  571. else()
  572. message(STATUS "Ignoring file: ${prereq_filename}")
  573. endif()
  574. endforeach()
  575. # Propagate values to caller's scope:
  576. #
  577. set(${keys_var} ${${keys_var}} PARENT_SCOPE)
  578. foreach(key ${${keys_var}})
  579. set(${key}_ITEM "${${key}_ITEM}" PARENT_SCOPE)
  580. set(${key}_RESOLVED_ITEM "${${key}_RESOLVED_ITEM}" PARENT_SCOPE)
  581. set(${key}_DEFAULT_EMBEDDED_PATH "${${key}_DEFAULT_EMBEDDED_PATH}" PARENT_SCOPE)
  582. set(${key}_EMBEDDED_ITEM "${${key}_EMBEDDED_ITEM}" PARENT_SCOPE)
  583. set(${key}_RESOLVED_EMBEDDED_ITEM "${${key}_RESOLVED_EMBEDDED_ITEM}" PARENT_SCOPE)
  584. set(${key}_COPYFLAG "${${key}_COPYFLAG}" PARENT_SCOPE)
  585. set(${key}_RPATHS "${${key}_RPATHS}" PARENT_SCOPE)
  586. set(${key}_RDEP_RPATHS "${${key}_RDEP_RPATHS}" PARENT_SCOPE)
  587. endforeach()
  588. endif()
  589. endfunction()
  590. function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item)
  591. if(WIN32)
  592. # ignore case on Windows
  593. string(TOLOWER "${resolved_item}" resolved_item_compare)
  594. string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare)
  595. else()
  596. set(resolved_item_compare "${resolved_item}")
  597. set(resolved_embedded_item_compare "${resolved_embedded_item}")
  598. endif()
  599. if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
  600. message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
  601. else()
  602. #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
  603. execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
  604. if(UNIX AND NOT APPLE)
  605. file(RPATH_REMOVE FILE "${resolved_embedded_item}")
  606. endif()
  607. endif()
  608. endfunction()
  609. function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_item)
  610. if(WIN32)
  611. # ignore case on Windows
  612. string(TOLOWER "${resolved_item}" resolved_item_compare)
  613. string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare)
  614. else()
  615. set(resolved_item_compare "${resolved_item}")
  616. set(resolved_embedded_item_compare "${resolved_embedded_item}")
  617. endif()
  618. if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
  619. message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
  620. else()
  621. if(BU_COPY_FULL_FRAMEWORK_CONTENTS)
  622. # Full Framework (everything):
  623. get_filename_component(resolved_dir "${resolved_item}" PATH)
  624. get_filename_component(resolved_dir "${resolved_dir}/../.." ABSOLUTE)
  625. get_filename_component(resolved_embedded_dir "${resolved_embedded_item}" PATH)
  626. get_filename_component(resolved_embedded_dir "${resolved_embedded_dir}/../.." ABSOLUTE)
  627. #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_dir}' '${resolved_embedded_dir}'")
  628. execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_dir}" "${resolved_embedded_dir}")
  629. else()
  630. # Framework lib itself:
  631. #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
  632. execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
  633. # Plus Resources, if they exist:
  634. string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}")
  635. string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}")
  636. if(EXISTS "${resolved_resources}")
  637. #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'")
  638. execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}")
  639. endif()
  640. # Some frameworks e.g. Qt put Info.plist in wrong place, so when it is
  641. # missing in resources, copy it from other well known incorrect locations:
  642. if(NOT EXISTS "${resolved_resources}/Info.plist")
  643. # Check for Contents/Info.plist in framework root (older Qt SDK):
  644. string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Contents/Info.plist" resolved_info_plist "${resolved_item}")
  645. string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources/Info.plist" resolved_embedded_info_plist "${resolved_embedded_item}")
  646. if(EXISTS "${resolved_info_plist}")
  647. #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_info_plist}' '${resolved_embedded_info_plist}'")
  648. execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_info_plist}" "${resolved_embedded_info_plist}")
  649. endif()
  650. endif()
  651. # Check if framework is versioned and fix it layout
  652. string(REGEX REPLACE "^.*/([^/]+)/[^/]+$" "\\1" resolved_embedded_version "${resolved_embedded_item}")
  653. string(REGEX REPLACE "^(.*)/[^/]+/[^/]+$" "\\1" resolved_embedded_versions "${resolved_embedded_item}")
  654. string(REGEX REPLACE "^.*/([^/]+)/[^/]+/[^/]+$" "\\1" resolved_embedded_versions_basename "${resolved_embedded_item}")
  655. if(resolved_embedded_versions_basename STREQUAL "Versions")
  656. # Ensure Current symlink points to the framework version
  657. if(NOT EXISTS "${resolved_embedded_versions}/Current")
  658. execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${resolved_embedded_version}" "${resolved_embedded_versions}/Current")
  659. endif()
  660. # Restore symlinks in framework root pointing to current framework
  661. # binary and resources:
  662. string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1" resolved_embedded_root "${resolved_embedded_item}")
  663. string(REGEX REPLACE "^.*/([^/]+)$" "\\1" resolved_embedded_item_basename "${resolved_embedded_item}")
  664. if(NOT EXISTS "${resolved_embedded_root}/${resolved_embedded_item_basename}")
  665. execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "Versions/Current/${resolved_embedded_item_basename}" "${resolved_embedded_root}/${resolved_embedded_item_basename}")
  666. endif()
  667. if(NOT EXISTS "${resolved_embedded_root}/Resources")
  668. execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "Versions/Current/Resources" "${resolved_embedded_root}/Resources")
  669. endif()
  670. endif()
  671. endif()
  672. if(UNIX AND NOT APPLE)
  673. file(RPATH_REMOVE FILE "${resolved_embedded_item}")
  674. endif()
  675. endif()
  676. endfunction()
  677. function(fixup_bundle_item resolved_embedded_item exepath dirs)
  678. # This item's key is "ikey":
  679. #
  680. get_item_key("${resolved_embedded_item}" ikey)
  681. # Ensure the item is "inside the .app bundle" -- it should not be fixed up if
  682. # it is not in the .app bundle... Otherwise, we'll modify files in the build
  683. # tree, or in other varied locations around the file system, with our call to
  684. # install_name_tool. Make sure that doesn't happen here:
  685. #
  686. get_dotapp_dir("${exepath}" exe_dotapp_dir)
  687. string(LENGTH "${exe_dotapp_dir}/" exe_dotapp_dir_length)
  688. string(LENGTH "${resolved_embedded_item}" resolved_embedded_item_length)
  689. set(path_too_short 0)
  690. set(is_embedded 0)
  691. if(${resolved_embedded_item_length} LESS ${exe_dotapp_dir_length})
  692. set(path_too_short 1)
  693. endif()
  694. if(NOT path_too_short)
  695. string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring)
  696. if("${exe_dotapp_dir}/" STREQUAL "${item_substring}")
  697. set(is_embedded 1)
  698. endif()
  699. endif()
  700. if(NOT is_embedded)
  701. message(" exe_dotapp_dir/='${exe_dotapp_dir}/'")
  702. message(" item_substring='${item_substring}'")
  703. message(" resolved_embedded_item='${resolved_embedded_item}'")
  704. message("")
  705. message("Install or copy the item into the bundle before calling fixup_bundle.")
  706. message("Or maybe there's a typo or incorrect path in one of the args to fixup_bundle?")
  707. message("")
  708. message(FATAL_ERROR "cannot fixup an item that is not in the bundle...")
  709. endif()
  710. set(rpaths "${${ikey}_RPATHS}" "${${ikey}_RDEP_RPATHS}")
  711. set(prereqs "")
  712. get_prerequisites("${resolved_embedded_item}" prereqs 1 0 "${exepath}" "${dirs}" "${rpaths}")
  713. set(changes "")
  714. foreach(pr ${prereqs})
  715. # Each referenced item's key is "rkey" in the loop:
  716. #
  717. get_item_key("${pr}" rkey)
  718. if(NOT "${${rkey}_EMBEDDED_ITEM}" STREQUAL "")
  719. set(changes ${changes} "-change" "${pr}" "${${rkey}_EMBEDDED_ITEM}")
  720. else()
  721. message("warning: unexpected reference to '${pr}'")
  722. endif()
  723. endforeach()
  724. if(BU_CHMOD_BUNDLE_ITEMS)
  725. execute_process(COMMAND chmod u+w "${resolved_embedded_item}")
  726. endif()
  727. # Only if install_name_tool supports -delete_rpath:
  728. #
  729. execute_process(COMMAND install_name_tool
  730. OUTPUT_VARIABLE install_name_tool_usage
  731. ERROR_VARIABLE install_name_tool_usage
  732. )
  733. if(install_name_tool_usage MATCHES ".*-delete_rpath.*")
  734. foreach(rpath ${${ikey}_RPATHS})
  735. set(changes ${changes} -delete_rpath "${rpath}")
  736. endforeach()
  737. endif()
  738. if(${ikey}_EMBEDDED_ITEM)
  739. set(changes ${changes} -id "${${ikey}_EMBEDDED_ITEM}")
  740. endif()
  741. # Change this item's id and all of its references in one call
  742. # to install_name_tool:
  743. #
  744. if(changes)
  745. set(cmd install_name_tool ${changes} "${resolved_embedded_item}")
  746. execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
  747. if(NOT install_name_tool_result EQUAL 0)
  748. string(REPLACE ";" "' '" msg "'${cmd}'")
  749. message(FATAL_ERROR "Command failed:\n ${msg}")
  750. endif()
  751. endif()
  752. endfunction()
  753. function(fixup_bundle app libs dirs)
  754. message(STATUS "fixup_bundle")
  755. message(STATUS " app='${app}'")
  756. message(STATUS " libs='${libs}'")
  757. message(STATUS " dirs='${dirs}'")
  758. set(options)
  759. set(oneValueArgs)
  760. set(multiValueArgs IGNORE_ITEM)
  761. cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
  762. message(STATUS " ignoreItems='${CFG_IGNORE_ITEM}'")
  763. get_bundle_and_executable("${app}" bundle executable valid)
  764. if(valid)
  765. get_filename_component(exepath "${executable}" PATH)
  766. message(STATUS "fixup_bundle: preparing...")
  767. get_bundle_keys("${app}" "${libs}" "${dirs}" keys IGNORE_ITEM "${CFG_IGNORE_ITEM}")
  768. message(STATUS "fixup_bundle: copying...")
  769. list(LENGTH keys n)
  770. math(EXPR n ${n}*2)
  771. set(i 0)
  772. foreach(key ${keys})
  773. math(EXPR i ${i}+1)
  774. if(${${key}_COPYFLAG})
  775. message(STATUS "${i}/${n}: copying '${${key}_RESOLVED_ITEM}'")
  776. else()
  777. message(STATUS "${i}/${n}: *NOT* copying '${${key}_RESOLVED_ITEM}'")
  778. endif()
  779. set(show_status 0)
  780. if(show_status)
  781. message(STATUS "key='${key}'")
  782. message(STATUS "item='${${key}_ITEM}'")
  783. message(STATUS "resolved_item='${${key}_RESOLVED_ITEM}'")
  784. message(STATUS "default_embedded_path='${${key}_DEFAULT_EMBEDDED_PATH}'")
  785. message(STATUS "embedded_item='${${key}_EMBEDDED_ITEM}'")
  786. message(STATUS "resolved_embedded_item='${${key}_RESOLVED_EMBEDDED_ITEM}'")
  787. message(STATUS "copyflag='${${key}_COPYFLAG}'")
  788. message(STATUS "")
  789. endif()
  790. if(${${key}_COPYFLAG})
  791. set(item "${${key}_ITEM}")
  792. if(item MATCHES "[^/]+\\.framework/")
  793. copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}"
  794. "${${key}_RESOLVED_EMBEDDED_ITEM}")
  795. else()
  796. copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}"
  797. "${${key}_RESOLVED_EMBEDDED_ITEM}")
  798. endif()
  799. endif()
  800. endforeach()
  801. message(STATUS "fixup_bundle: fixing...")
  802. foreach(key ${keys})
  803. math(EXPR i ${i}+1)
  804. if(APPLE)
  805. message(STATUS "${i}/${n}: fixing up '${${key}_RESOLVED_EMBEDDED_ITEM}'")
  806. fixup_bundle_item("${${key}_RESOLVED_EMBEDDED_ITEM}" "${exepath}" "${dirs}")
  807. else()
  808. message(STATUS "${i}/${n}: fix-up not required on this platform '${${key}_RESOLVED_EMBEDDED_ITEM}'")
  809. endif()
  810. endforeach()
  811. message(STATUS "fixup_bundle: cleaning up...")
  812. clear_bundle_keys(keys)
  813. message(STATUS "fixup_bundle: verifying...")
  814. verify_app("${app}" IGNORE_ITEM "${CFG_IGNORE_ITEM}")
  815. else()
  816. message(SEND_ERROR "error: fixup_bundle: not a valid bundle")
  817. endif()
  818. message(STATUS "fixup_bundle: done")
  819. endfunction()
  820. function(copy_and_fixup_bundle src dst libs dirs)
  821. execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}")
  822. fixup_bundle("${dst}" "${libs}" "${dirs}")
  823. endfunction()
  824. function(verify_bundle_prerequisites bundle result_var info_var)
  825. set(result 1)
  826. set(info "")
  827. set(count 0)
  828. set(options)
  829. set(oneValueArgs)
  830. set(multiValueArgs IGNORE_ITEM)
  831. cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
  832. get_bundle_main_executable("${bundle}" main_bundle_exe)
  833. get_bundle_all_executables("${bundle}" file_list)
  834. foreach(f ${file_list})
  835. get_filename_component(exepath "${f}" PATH)
  836. math(EXPR count "${count} + 1")
  837. message(STATUS "executable file ${count}: ${f}")
  838. set(prereqs "")
  839. set(ignoreFile FALSE)
  840. get_filename_component(prereq_filename ${f} NAME)
  841. if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
  842. foreach(item ${CFG_IGNORE_ITEM})
  843. if("${item}" STREQUAL "${prereq_filename}")
  844. set(ignoreFile TRUE)
  845. endif()
  846. endforeach()
  847. endif()
  848. if(NOT ignoreFile)
  849. get_prerequisites("${f}" prereqs 1 1 "${exepath}" "")
  850. # On the Mac,
  851. # "embedded" and "system" prerequisites are fine... anything else means
  852. # the bundle's prerequisites are not verified (i.e., the bundle is not
  853. # really "standalone")
  854. #
  855. # On Windows (and others? Linux/Unix/...?)
  856. # "local" and "system" prereqs are fine...
  857. #
  858. set(external_prereqs "")
  859. foreach(p ${prereqs})
  860. set(p_type "")
  861. gp_file_type("${f}" "${p}" p_type)
  862. if(APPLE)
  863. if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
  864. set(external_prereqs ${external_prereqs} "${p}")
  865. endif()
  866. else()
  867. if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
  868. set(external_prereqs ${external_prereqs} "${p}")
  869. endif()
  870. endif()
  871. endforeach()
  872. if(external_prereqs)
  873. # Found non-system/somehow-unacceptable prerequisites:
  874. set(result 0)
  875. set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n")
  876. endif()
  877. else()
  878. message(STATUS "Ignoring file: ${prereq_filename}")
  879. endif()
  880. endforeach()
  881. if(result)
  882. set(info "Verified ${count} executable files in '${bundle}'")
  883. endif()
  884. set(${result_var} "${result}" PARENT_SCOPE)
  885. set(${info_var} "${info}" PARENT_SCOPE)
  886. endfunction()
  887. function(verify_bundle_symlinks bundle result_var info_var)
  888. set(result 1)
  889. set(info "")
  890. set(count 0)
  891. # TODO: implement this function for real...
  892. # Right now, it is just a stub that verifies unconditionally...
  893. set(${result_var} "${result}" PARENT_SCOPE)
  894. set(${info_var} "${info}" PARENT_SCOPE)
  895. endfunction()
  896. function(verify_app app)
  897. set(verified 0)
  898. set(info "")
  899. set(options)
  900. set(oneValueArgs)
  901. set(multiValueArgs IGNORE_ITEM)
  902. cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
  903. get_bundle_and_executable("${app}" bundle executable valid)
  904. message(STATUS "===========================================================================")
  905. message(STATUS "Analyzing app='${app}'")
  906. message(STATUS "bundle='${bundle}'")
  907. message(STATUS "executable='${executable}'")
  908. message(STATUS "valid='${valid}'")
  909. # Verify that the bundle does not have any "external" prerequisites:
  910. #
  911. verify_bundle_prerequisites("${bundle}" verified info IGNORE_ITEM "${CFG_IGNORE_ITEM}")
  912. message(STATUS "verified='${verified}'")
  913. message(STATUS "info='${info}'")
  914. message(STATUS "")
  915. if(verified)
  916. # Verify that the bundle does not have any symlinks to external files:
  917. #
  918. verify_bundle_symlinks("${bundle}" verified info)
  919. message(STATUS "verified='${verified}'")
  920. message(STATUS "info='${info}'")
  921. message(STATUS "")
  922. endif()
  923. if(NOT verified)
  924. message(FATAL_ERROR "error: verify_app failed")
  925. endif()
  926. endfunction()