ExternalProject.cmake 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. ExternalProject
  5. ---------------
  6. Create custom targets to build projects in external trees
  7. .. command:: ExternalProject_Add
  8. The ``ExternalProject_Add`` function creates a custom target to drive
  9. download, update/patch, configure, build, install and test steps of an
  10. external project::
  11. ExternalProject_Add(<name> [<option>...])
  12. General options are:
  13. ``DEPENDS <projects>...``
  14. Targets on which the project depends
  15. ``PREFIX <dir>``
  16. Root dir for entire project
  17. ``LIST_SEPARATOR <sep>``
  18. Sep to be replaced by ; in cmd lines
  19. ``TMP_DIR <dir>``
  20. Directory to store temporary files
  21. ``STAMP_DIR <dir>``
  22. Directory to store step timestamps
  23. ``EXCLUDE_FROM_ALL 1``
  24. The "all" target does not depend on this
  25. Download step options are:
  26. ``DOWNLOAD_NAME <fname>``
  27. File name to store (if not end of URL)
  28. ``DOWNLOAD_DIR <dir>``
  29. Directory to store downloaded files
  30. ``DOWNLOAD_COMMAND <cmd>...``
  31. Command to download source tree
  32. ``DOWNLOAD_NO_PROGRESS 1``
  33. Disable download progress reports
  34. ``CVS_REPOSITORY <cvsroot>``
  35. CVSROOT of CVS repository
  36. ``CVS_MODULE <mod>``
  37. Module to checkout from CVS repo
  38. ``CVS_TAG <tag>``
  39. Tag to checkout from CVS repo
  40. ``SVN_REPOSITORY <url>``
  41. URL of Subversion repo
  42. ``SVN_REVISION -r<rev>``
  43. Revision to checkout from Subversion repo
  44. ``SVN_USERNAME <username>``
  45. Username for Subversion checkout and update
  46. ``SVN_PASSWORD <password>``
  47. Password for Subversion checkout and update
  48. ``SVN_TRUST_CERT 1``
  49. Trust the Subversion server site certificate
  50. ``GIT_REPOSITORY <url>``
  51. URL of git repo
  52. ``GIT_TAG <tag>``
  53. Git branch name, commit id or tag
  54. ``GIT_REMOTE_NAME <name>``
  55. The optional name of the remote, default to ``origin``
  56. ``GIT_SUBMODULES <module>...``
  57. Git submodules that shall be updated, all if empty
  58. ``GIT_SHALLOW 1``
  59. Tell Git to clone with ``--depth 1``. Use when ``GIT_TAG`` is not
  60. specified or when it names a branch in order to download only the
  61. tip of the branch without the rest of its history.
  62. ``GIT_PROGRESS 1``
  63. Tell Git to clone with ``--progress``. For large projects, the clone step
  64. does not output anything which can make the build appear to have stalled.
  65. This option forces Git to output progress information during the clone step
  66. so that forward progress is indicated.
  67. ``HG_REPOSITORY <url>``
  68. URL of mercurial repo
  69. ``HG_TAG <tag>``
  70. Mercurial branch name, commit id or tag
  71. ``URL /.../src.tgz [/.../src.tgz]...``
  72. Full path or URL(s) of source. Multiple URLs are allowed as mirrors.
  73. ``URL_HASH ALGO=value``
  74. Hash of file at URL
  75. ``URL_MD5 md5``
  76. Equivalent to URL_HASH MD5=md5
  77. ``HTTP_USERNAME <username>``
  78. Username for download operation
  79. ``HTTP_PASSWORD <username>``
  80. Password for download operation
  81. ``HTTP_HEADER <header>``
  82. HTTP header for download operation. Suboption can be repeated several times.
  83. ``TLS_VERIFY <bool>``
  84. Should certificate for https be checked
  85. ``TLS_CAINFO <file>``
  86. Path to a certificate authority file
  87. ``TIMEOUT <seconds>``
  88. Time allowed for file download operations
  89. ``DOWNLOAD_NO_EXTRACT 1``
  90. Just download the file and do not extract it; the full path to the
  91. downloaded file is available as ``<DOWNLOADED_FILE>``.
  92. Update/Patch step options are:
  93. ``UPDATE_COMMAND <cmd>...``
  94. Source work-tree update command
  95. ``UPDATE_DISCONNECTED 1``
  96. Never update automatically from the remote repository
  97. ``PATCH_COMMAND <cmd>...``
  98. Command to patch downloaded source
  99. Configure step options are:
  100. ``SOURCE_DIR <dir>``
  101. Source dir to be used for build
  102. ``SOURCE_SUBDIR <dir>``
  103. Path to source CMakeLists.txt relative to ``SOURCE_DIR``
  104. ``CONFIGURE_COMMAND <cmd>...``
  105. Build tree configuration command
  106. ``CMAKE_COMMAND /.../cmake``
  107. Specify alternative cmake executable
  108. ``CMAKE_GENERATOR <gen>``
  109. Specify generator for native build
  110. ``CMAKE_GENERATOR_PLATFORM <platform>``
  111. Generator-specific platform name
  112. ``CMAKE_GENERATOR_TOOLSET <toolset>``
  113. Generator-specific toolset name
  114. ``CMAKE_ARGS <arg>...``
  115. Arguments to CMake command line.
  116. These arguments are passed to CMake command line, and can contain
  117. arguments other than cache values, see also
  118. :manual:`CMake Options <cmake(1)>`. Arguments in the form
  119. ``-Dvar:string=on`` are always passed to the command line, and
  120. therefore cannot be changed by the user.
  121. Arguments may use
  122. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  123. ``CMAKE_CACHE_ARGS <arg>...``
  124. Initial cache arguments, of the form ``-Dvar:string=on``.
  125. These arguments are written in a pre-load a script that populates
  126. CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
  127. overcome command line length limits.
  128. These arguments are :command:`set` using the ``FORCE`` argument,
  129. and therefore cannot be changed by the user.
  130. Arguments may use
  131. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  132. ``CMAKE_CACHE_DEFAULT_ARGS <arg>...``
  133. Initial default cache arguments, of the form ``-Dvar:string=on``.
  134. These arguments are written in a pre-load a script that populates
  135. CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
  136. overcome command line length limits.
  137. These arguments can be used as default value that will be set if no
  138. previous value is found in the cache, and that the user can change
  139. later.
  140. Arguments may use
  141. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  142. Build step options are:
  143. ``BINARY_DIR <dir>``
  144. Specify build dir location
  145. ``BUILD_COMMAND <cmd>...``
  146. Command to drive the native build
  147. ``BUILD_IN_SOURCE 1``
  148. Use source dir for build dir
  149. ``BUILD_ALWAYS 1``
  150. No stamp file, build step always runs
  151. ``BUILD_BYPRODUCTS <file>...``
  152. Files that will be generated by the build command but may or may
  153. not have their modification time updated by subsequent builds.
  154. Install step options are:
  155. ``INSTALL_DIR <dir>``
  156. Installation prefix
  157. ``INSTALL_COMMAND <cmd>...``
  158. Command to drive install after build
  159. Test step options are:
  160. ``TEST_BEFORE_INSTALL 1``
  161. Add test step executed before install step
  162. ``TEST_AFTER_INSTALL 1``
  163. Add test step executed after install step
  164. ``TEST_EXCLUDE_FROM_MAIN 1``
  165. Main target does not depend on the test step
  166. ``TEST_COMMAND <cmd>...``
  167. Command to drive test
  168. Output logging options are:
  169. ``LOG_DOWNLOAD 1``
  170. Wrap download in script to log output
  171. ``LOG_UPDATE 1``
  172. Wrap update in script to log output
  173. ``LOG_CONFIGURE 1``
  174. Wrap configure in script to log output
  175. ``LOG_BUILD 1``
  176. Wrap build in script to log output
  177. ``LOG_TEST 1``
  178. Wrap test in script to log output
  179. ``LOG_INSTALL 1``
  180. Wrap install in script to log output
  181. Steps can be given direct access to the terminal if possible. With
  182. the :generator:`Ninja` generator, this places the steps in the
  183. ``console`` :prop_gbl:`pool <JOB_POOLS>`. Options are:
  184. ``USES_TERMINAL_DOWNLOAD 1``
  185. Give download terminal access.
  186. ``USES_TERMINAL_UPDATE 1``
  187. Give update terminal access.
  188. ``USES_TERMINAL_CONFIGURE 1``
  189. Give configure terminal access.
  190. ``USES_TERMINAL_BUILD 1``
  191. Give build terminal access.
  192. ``USES_TERMINAL_TEST 1``
  193. Give test terminal access.
  194. ``USES_TERMINAL_INSTALL 1``
  195. Give install terminal access.
  196. Other options are:
  197. ``STEP_TARGETS <step-target>...``
  198. Generate custom targets for these steps
  199. ``INDEPENDENT_STEP_TARGETS <step-target>...``
  200. Generate custom targets for these steps that do not depend on other
  201. external projects even if a dependency is set
  202. The ``*_DIR`` options specify directories for the project, with default
  203. directories computed as follows. If the ``PREFIX`` option is given to
  204. ``ExternalProject_Add()`` or the ``EP_PREFIX`` directory property is set,
  205. then an external project is built and installed under the specified prefix::
  206. TMP_DIR = <prefix>/tmp
  207. STAMP_DIR = <prefix>/src/<name>-stamp
  208. DOWNLOAD_DIR = <prefix>/src
  209. SOURCE_DIR = <prefix>/src/<name>
  210. BINARY_DIR = <prefix>/src/<name>-build
  211. INSTALL_DIR = <prefix>
  212. Otherwise, if the ``EP_BASE`` directory property is set then components
  213. of an external project are stored under the specified base::
  214. TMP_DIR = <base>/tmp/<name>
  215. STAMP_DIR = <base>/Stamp/<name>
  216. DOWNLOAD_DIR = <base>/Download/<name>
  217. SOURCE_DIR = <base>/Source/<name>
  218. BINARY_DIR = <base>/Build/<name>
  219. INSTALL_DIR = <base>/Install/<name>
  220. If no ``PREFIX``, ``EP_PREFIX``, or ``EP_BASE`` is specified then the
  221. default is to set ``PREFIX`` to ``<name>-prefix``. Relative paths are
  222. interpreted with respect to the build directory corresponding to the
  223. source directory in which ``ExternalProject_Add`` is invoked.
  224. If ``SOURCE_SUBDIR`` is set and no ``CONFIGURE_COMMAND`` is specified, the
  225. configure command will run CMake using the ``CMakeLists.txt`` located in the
  226. relative path specified by ``SOURCE_SUBDIR``, relative to the ``SOURCE_DIR``.
  227. If no ``SOURCE_SUBDIR`` is given, ``SOURCE_DIR`` is used.
  228. If ``SOURCE_DIR`` is explicitly set to an existing directory the project
  229. will be built from it. Otherwise a download step must be specified
  230. using one of the ``DOWNLOAD_COMMAND``, ``CVS_*``, ``SVN_*``, or ``URL``
  231. options. The ``URL`` option may refer locally to a directory or source
  232. tarball, or refer to a remote tarball (e.g. ``http://.../src.tgz``).
  233. If ``UPDATE_DISCONNECTED`` is set, the update step is not executed
  234. automatically when building the main target. The update step can still
  235. be added as a step target and called manually. This is useful if you
  236. want to allow one to build the project when you are disconnected from the
  237. network (you might still need the network for the download step).
  238. This is disabled by default.
  239. The directory property ``EP_UPDATE_DISCONNECTED`` can be used to change
  240. the default value for all the external projects in the current
  241. directory and its subdirectories.
  242. .. command:: ExternalProject_Add_Step
  243. The ``ExternalProject_Add_Step`` function adds a custom step to an
  244. external project::
  245. ExternalProject_Add_Step(<name> <step> [<option>...])
  246. Options are:
  247. ``COMMAND <cmd>...``
  248. Command line invoked by this step
  249. ``COMMENT "<text>..."``
  250. Text printed when step executes
  251. ``DEPENDEES <step>...``
  252. Steps on which this step depends
  253. ``DEPENDERS <step>...``
  254. Steps that depend on this step
  255. ``DEPENDS <file>...``
  256. Files on which this step depends
  257. ``BYPRODUCTS <file>...``
  258. Files that will be generated by this step but may or may not
  259. have their modification time updated by subsequent builds.
  260. ``ALWAYS 1``
  261. No stamp file, step always runs
  262. ``EXCLUDE_FROM_MAIN 1``
  263. Main target does not depend on this step
  264. ``WORKING_DIRECTORY <dir>``
  265. Working directory for command
  266. ``LOG 1``
  267. Wrap step in script to log output
  268. ``USES_TERMINAL 1``
  269. Give the step direct access to the terminal if possible.
  270. The command line, comment, working directory, and byproducts of every
  271. standard and custom step are processed to replace tokens ``<SOURCE_DIR>``,
  272. ``<SOURCE_SUBDIR>``, ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>``
  273. with corresponding property values.
  274. Any builtin step that specifies a ``<step>_COMMAND cmd...`` or custom
  275. step that specifies a ``COMMAND cmd...`` may specify additional command
  276. lines using the form ``COMMAND cmd...``. At build time the commands
  277. will be executed in order and aborted if any one fails. For example::
  278. ... BUILD_COMMAND make COMMAND echo done ...
  279. specifies to run ``make`` and then ``echo done`` during the build step.
  280. Whether the current working directory is preserved between commands is
  281. not defined. Behavior of shell operators like ``&&`` is not defined.
  282. Arguments to ``<step>_COMMAND`` or ``COMMAND`` options may use
  283. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  284. .. command:: ExternalProject_Get_Property
  285. The ``ExternalProject_Get_Property`` function retrieves external project
  286. target properties::
  287. ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]])
  288. It stores property values in variables of the same name. Property
  289. names correspond to the keyword argument names of
  290. ``ExternalProject_Add``.
  291. .. command:: ExternalProject_Add_StepTargets
  292. The ``ExternalProject_Add_StepTargets`` function generates custom
  293. targets for the steps listed::
  294. ExternalProject_Add_StepTargets(<name> [NO_DEPENDS] [step1 [step2 [...]]])
  295. If ``NO_DEPENDS`` is set, the target will not depend on the
  296. dependencies of the complete project. This is usually safe to use for
  297. the download, update, and patch steps that do not require that all the
  298. dependencies are updated and built. Using ``NO_DEPENDS`` for other
  299. of the default steps might break parallel builds, so you should avoid,
  300. it. For custom steps, you should consider whether or not the custom
  301. commands requires that the dependencies are configured, built and
  302. installed.
  303. If ``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` is set then
  304. ``ExternalProject_Add_StepTargets`` is automatically called at the end
  305. of matching calls to ``ExternalProject_Add_Step``. Pass
  306. ``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` explicitly to
  307. individual ``ExternalProject_Add`` calls, or implicitly to all
  308. ``ExternalProject_Add`` calls by setting the directory properties
  309. ``EP_STEP_TARGETS`` and ``EP_INDEPENDENT_STEP_TARGETS``. The
  310. ``INDEPENDENT`` version of the argument and of the property will call
  311. ``ExternalProject_Add_StepTargets`` with the ``NO_DEPENDS`` argument.
  312. If ``STEP_TARGETS`` and ``INDEPENDENT_STEP_TARGETS`` are not set,
  313. clients may still manually call ``ExternalProject_Add_StepTargets``
  314. after calling ``ExternalProject_Add`` or ``ExternalProject_Add_Step``.
  315. This functionality is provided to make it easy to drive the steps
  316. independently of each other by specifying targets on build command
  317. lines. For example, you may be submitting to a sub-project based
  318. dashboard, where you want to drive the configure portion of the build,
  319. then submit to the dashboard, followed by the build portion, followed
  320. by tests. If you invoke a custom target that depends on a step
  321. halfway through the step dependency chain, then all the previous steps
  322. will also run to ensure everything is up to date.
  323. For example, to drive configure, build and test steps independently
  324. for each ``ExternalProject_Add`` call in your project, write the following
  325. line prior to any ``ExternalProject_Add`` calls in your ``CMakeLists.txt``
  326. file::
  327. set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
  328. .. command:: ExternalProject_Add_StepDependencies
  329. The ``ExternalProject_Add_StepDependencies`` function add some
  330. dependencies for some external project step::
  331. ExternalProject_Add_StepDependencies(<name> <step> [target1 [target2 [...]]])
  332. This function takes care to set both target and file level
  333. dependencies, and will ensure that parallel builds will not break.
  334. It should be used instead of :command:`add_dependencies()` when adding
  335. a dependency for some of the step targets generated by
  336. ``ExternalProject``.
  337. #]=======================================================================]
  338. # Pre-compute a regex to match documented keywords for each command.
  339. math(EXPR _ep_documentation_line_count "${CMAKE_CURRENT_LIST_LINE} - 16")
  340. file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines
  341. LIMIT_COUNT ${_ep_documentation_line_count}
  342. REGEX "^\\.\\. command:: [A-Za-z0-9_]+|^ ``[A-Z0-9_]+ .*``$")
  343. foreach(line IN LISTS lines)
  344. if("${line}" MATCHES "^\\.\\. command:: ([A-Za-z0-9_]+)")
  345. if(_ep_func)
  346. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  347. endif()
  348. set(_ep_func "${CMAKE_MATCH_1}")
  349. #message("function [${_ep_func}]")
  350. set(_ep_keywords_${_ep_func} "^(")
  351. set(_ep_keyword_sep)
  352. elseif("${line}" MATCHES "^ ``([A-Z0-9_]+) .*``$")
  353. set(_ep_key "${CMAKE_MATCH_1}")
  354. #message(" keyword [${_ep_key}]")
  355. set(_ep_keywords_${_ep_func}
  356. "${_ep_keywords_${_ep_func}}${_ep_keyword_sep}${_ep_key}")
  357. set(_ep_keyword_sep "|")
  358. endif()
  359. endforeach()
  360. if(_ep_func)
  361. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  362. endif()
  363. # Save regex matching supported hash algorithm names.
  364. set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512")
  365. set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$")
  366. set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}")
  367. get_filename_component(_ExternalProject_SELF_DIR "${_ExternalProject_SELF}" PATH)
  368. function(_ep_parse_arguments f name ns args)
  369. # Transfer the arguments to this function into target properties for the
  370. # new custom target we just added so that we can set up all the build steps
  371. # correctly based on target properties.
  372. #
  373. # We loop through ARGN and consider the namespace starting with an
  374. # upper-case letter followed by at least two more upper-case letters,
  375. # numbers or underscores to be keywords.
  376. set(key)
  377. foreach(arg IN LISTS args)
  378. set(is_value 1)
  379. if(arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND
  380. NOT (("x${arg}x" STREQUAL "x${key}x") AND ("x${key}x" STREQUAL "xCOMMANDx")) AND
  381. NOT arg MATCHES "^(TRUE|FALSE)$")
  382. if(_ep_keywords_${f} AND arg MATCHES "${_ep_keywords_${f}}")
  383. set(is_value 0)
  384. endif()
  385. endif()
  386. if(is_value)
  387. if(key)
  388. # Value
  389. if(NOT arg STREQUAL "")
  390. set_property(TARGET ${name} APPEND PROPERTY ${ns}${key} "${arg}")
  391. else()
  392. get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
  393. if(have_key)
  394. get_property(value TARGET ${name} PROPERTY ${ns}${key})
  395. set_property(TARGET ${name} PROPERTY ${ns}${key} "${value};${arg}")
  396. else()
  397. set_property(TARGET ${name} PROPERTY ${ns}${key} "${arg}")
  398. endif()
  399. endif()
  400. else()
  401. # Missing Keyword
  402. message(AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}")
  403. endif()
  404. else()
  405. set(key "${arg}")
  406. endif()
  407. endforeach()
  408. endfunction()
  409. define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED
  410. BRIEF_DOCS "Base directory for External Project storage."
  411. FULL_DOCS
  412. "See documentation of the ExternalProject_Add() function in the "
  413. "ExternalProject module."
  414. )
  415. define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED
  416. BRIEF_DOCS "Top prefix for External Project storage."
  417. FULL_DOCS
  418. "See documentation of the ExternalProject_Add() function in the "
  419. "ExternalProject module."
  420. )
  421. define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
  422. BRIEF_DOCS
  423. "List of ExternalProject steps that automatically get corresponding targets"
  424. FULL_DOCS
  425. "These targets will be dependent on the main target dependencies"
  426. "See documentation of the ExternalProject_Add_StepTargets() function in the "
  427. "ExternalProject module."
  428. )
  429. define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED
  430. BRIEF_DOCS
  431. "List of ExternalProject steps that automatically get corresponding targets"
  432. FULL_DOCS
  433. "These targets will not be dependent on the main target dependencies"
  434. "See documentation of the ExternalProject_Add_StepTargets() function in the "
  435. "ExternalProject module."
  436. )
  437. define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
  438. BRIEF_DOCS "Never update automatically from the remote repo."
  439. FULL_DOCS
  440. "See documentation of the ExternalProject_Add() function in the "
  441. "ExternalProject module."
  442. )
  443. function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
  444. if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
  445. set(git_clone_shallow_options "--depth 1 --no-single-branch")
  446. else()
  447. set(git_clone_shallow_options "--depth 1")
  448. endif()
  449. file(WRITE ${script_filename}
  450. "if(\"${git_tag}\" STREQUAL \"\")
  451. message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
  452. endif()
  453. set(run 0)
  454. if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
  455. set(run 1)
  456. endif()
  457. if(NOT run)
  458. message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\")
  459. return()
  460. endif()
  461. execute_process(
  462. COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
  463. RESULT_VARIABLE error_code
  464. )
  465. if(error_code)
  466. message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
  467. endif()
  468. set(git_options)
  469. # disable cert checking if explicitly told not to do it
  470. set(tls_verify \"${tls_verify}\")
  471. if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify)
  472. list(APPEND git_options
  473. -c http.sslVerify=false)
  474. endif()
  475. set(git_clone_options)
  476. set(git_shallow \"${git_shallow}\")
  477. if(git_shallow)
  478. list(APPEND git_clone_options ${git_clone_shallow_options})
  479. endif()
  480. set(git_progress \"${git_progress}\")
  481. if(git_progress)
  482. list(APPEND git_clone_options --progress)
  483. endif()
  484. # try the clone 3 times incase there is an odd git clone issue
  485. set(error_code 1)
  486. set(number_of_tries 0)
  487. while(error_code AND number_of_tries LESS 3)
  488. execute_process(
  489. COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
  490. WORKING_DIRECTORY \"${work_dir}\"
  491. RESULT_VARIABLE error_code
  492. )
  493. math(EXPR number_of_tries \"\${number_of_tries} + 1\")
  494. endwhile()
  495. if(number_of_tries GREATER 1)
  496. message(STATUS \"Had to git clone more than once:
  497. \${number_of_tries} times.\")
  498. endif()
  499. if(error_code)
  500. message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
  501. endif()
  502. execute_process(
  503. COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag}
  504. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  505. RESULT_VARIABLE error_code
  506. )
  507. if(error_code)
  508. message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
  509. endif()
  510. execute_process(
  511. COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule init ${git_submodules}
  512. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  513. RESULT_VARIABLE error_code
  514. )
  515. if(error_code)
  516. message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\")
  517. endif()
  518. execute_process(
  519. COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule update --recursive --init ${git_submodules}
  520. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  521. RESULT_VARIABLE error_code
  522. )
  523. if(error_code)
  524. message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
  525. endif()
  526. # Complete success, update the script-last-run stamp file:
  527. #
  528. execute_process(
  529. COMMAND \${CMAKE_COMMAND} -E copy
  530. \"${gitclone_infofile}\"
  531. \"${gitclone_stampfile}\"
  532. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  533. RESULT_VARIABLE error_code
  534. )
  535. if(error_code)
  536. message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${gitclone_stampfile}'\")
  537. endif()
  538. "
  539. )
  540. endfunction()
  541. function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile)
  542. file(WRITE ${script_filename}
  543. "if(\"${hg_tag}\" STREQUAL \"\")
  544. message(FATAL_ERROR \"Tag for hg checkout should not be empty.\")
  545. endif()
  546. set(run 0)
  547. if(\"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\")
  548. set(run 1)
  549. endif()
  550. if(NOT run)
  551. message(STATUS \"Avoiding repeated hg clone, stamp file is up to date: '${hgclone_stampfile}'\")
  552. return()
  553. endif()
  554. execute_process(
  555. COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
  556. RESULT_VARIABLE error_code
  557. )
  558. if(error_code)
  559. message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
  560. endif()
  561. execute_process(
  562. COMMAND \"${hg_EXECUTABLE}\" clone -U \"${hg_repository}\" \"${src_name}\"
  563. WORKING_DIRECTORY \"${work_dir}\"
  564. RESULT_VARIABLE error_code
  565. )
  566. if(error_code)
  567. message(FATAL_ERROR \"Failed to clone repository: '${hg_repository}'\")
  568. endif()
  569. execute_process(
  570. COMMAND \"${hg_EXECUTABLE}\" update ${hg_tag}
  571. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  572. RESULT_VARIABLE error_code
  573. )
  574. if(error_code)
  575. message(FATAL_ERROR \"Failed to checkout tag: '${hg_tag}'\")
  576. endif()
  577. # Complete success, update the script-last-run stamp file:
  578. #
  579. execute_process(
  580. COMMAND \${CMAKE_COMMAND} -E copy
  581. \"${hgclone_infofile}\"
  582. \"${hgclone_stampfile}\"
  583. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  584. RESULT_VARIABLE error_code
  585. )
  586. if(error_code)
  587. message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${hgclone_stampfile}'\")
  588. endif()
  589. "
  590. )
  591. endfunction()
  592. function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
  593. if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.6)
  594. set(git_stash_save_options --all --quiet)
  595. else()
  596. set(git_stash_save_options --quiet)
  597. endif()
  598. file(WRITE ${script_filename}
  599. "if(\"${git_tag}\" STREQUAL \"\")
  600. message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
  601. endif()
  602. execute_process(
  603. COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 HEAD
  604. WORKING_DIRECTORY \"${work_dir}\"
  605. RESULT_VARIABLE error_code
  606. OUTPUT_VARIABLE head_sha
  607. OUTPUT_STRIP_TRAILING_WHITESPACE
  608. )
  609. if(error_code)
  610. message(FATAL_ERROR \"Failed to get the hash for HEAD\")
  611. endif()
  612. execute_process(
  613. COMMAND \"${git_EXECUTABLE}\" show-ref ${git_tag}
  614. WORKING_DIRECTORY \"${work_dir}\"
  615. OUTPUT_VARIABLE show_ref_output
  616. )
  617. # If a remote ref is asked for, which can possibly move around,
  618. # we must always do a fetch and checkout.
  619. if(\"\${show_ref_output}\" MATCHES \"remotes\")
  620. set(is_remote_ref 1)
  621. else()
  622. set(is_remote_ref 0)
  623. endif()
  624. # Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip
  625. # the remote from the tag.
  626. if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\")
  627. string(REGEX MATCH \"^([^/]+)/(.+)$\" _unused \"${git_tag}\")
  628. set(git_remote \"\${CMAKE_MATCH_1}\")
  629. set(git_tag \"\${CMAKE_MATCH_2}\")
  630. else()
  631. set(git_remote \"${git_remote_name}\")
  632. set(git_tag \"${git_tag}\")
  633. endif()
  634. # This will fail if the tag does not exist (it probably has not been fetched
  635. # yet).
  636. execute_process(
  637. COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 ${git_tag}
  638. WORKING_DIRECTORY \"${work_dir}\"
  639. RESULT_VARIABLE error_code
  640. OUTPUT_VARIABLE tag_sha
  641. OUTPUT_STRIP_TRAILING_WHITESPACE
  642. )
  643. # Is the hash checkout out that we want?
  644. if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"))
  645. execute_process(
  646. COMMAND \"${git_EXECUTABLE}\" fetch
  647. WORKING_DIRECTORY \"${work_dir}\"
  648. RESULT_VARIABLE error_code
  649. )
  650. if(error_code)
  651. message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\")
  652. endif()
  653. if(is_remote_ref)
  654. # Check if stash is needed
  655. execute_process(
  656. COMMAND \"${git_EXECUTABLE}\" status --porcelain
  657. WORKING_DIRECTORY \"${work_dir}\"
  658. RESULT_VARIABLE error_code
  659. OUTPUT_VARIABLE repo_status
  660. )
  661. if(error_code)
  662. message(FATAL_ERROR \"Failed to get the status\")
  663. endif()
  664. string(LENGTH \"\${repo_status}\" need_stash)
  665. # If not in clean state, stash changes in order to be able to be able to
  666. # perform git pull --rebase
  667. if(need_stash)
  668. execute_process(
  669. COMMAND \"${git_EXECUTABLE}\" stash save ${git_stash_save_options}
  670. WORKING_DIRECTORY \"${work_dir}\"
  671. RESULT_VARIABLE error_code
  672. )
  673. if(error_code)
  674. message(FATAL_ERROR \"Failed to stash changes\")
  675. endif()
  676. endif()
  677. # Pull changes from the remote branch
  678. execute_process(
  679. COMMAND \"${git_EXECUTABLE}\" rebase \${git_remote}/\${git_tag}
  680. WORKING_DIRECTORY \"${work_dir}\"
  681. RESULT_VARIABLE error_code
  682. )
  683. if(error_code)
  684. # Rebase failed: Restore previous state.
  685. execute_process(
  686. COMMAND \"${git_EXECUTABLE}\" rebase --abort
  687. WORKING_DIRECTORY \"${work_dir}\"
  688. )
  689. if(need_stash)
  690. execute_process(
  691. COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
  692. WORKING_DIRECTORY \"${work_dir}\"
  693. )
  694. endif()
  695. message(FATAL_ERROR \"\\nFailed to rebase in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
  696. endif()
  697. if(need_stash)
  698. execute_process(
  699. COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
  700. WORKING_DIRECTORY \"${work_dir}\"
  701. RESULT_VARIABLE error_code
  702. )
  703. if(error_code)
  704. # Stash pop --index failed: Try again dropping the index
  705. execute_process(
  706. COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet
  707. WORKING_DIRECTORY \"${work_dir}\"
  708. RESULT_VARIABLE error_code
  709. )
  710. execute_process(
  711. COMMAND \"${git_EXECUTABLE}\" stash pop --quiet
  712. WORKING_DIRECTORY \"${work_dir}\"
  713. RESULT_VARIABLE error_code
  714. )
  715. if(error_code)
  716. # Stash pop failed: Restore previous state.
  717. execute_process(
  718. COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet \${head_sha}
  719. WORKING_DIRECTORY \"${work_dir}\"
  720. )
  721. execute_process(
  722. COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
  723. WORKING_DIRECTORY \"${work_dir}\"
  724. )
  725. message(FATAL_ERROR \"\\nFailed to unstash changes in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
  726. endif()
  727. endif()
  728. endif()
  729. else()
  730. execute_process(
  731. COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
  732. WORKING_DIRECTORY \"${work_dir}\"
  733. RESULT_VARIABLE error_code
  734. )
  735. if(error_code)
  736. message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
  737. endif()
  738. endif()
  739. execute_process(
  740. COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
  741. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  742. RESULT_VARIABLE error_code
  743. )
  744. if(error_code)
  745. message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
  746. endif()
  747. endif()
  748. "
  749. )
  750. endfunction(_ep_write_gitupdate_script)
  751. function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers)
  752. if(timeout)
  753. set(TIMEOUT_ARGS TIMEOUT ${timeout})
  754. set(TIMEOUT_MSG "${timeout} seconds")
  755. else()
  756. set(TIMEOUT_ARGS "# no TIMEOUT")
  757. set(TIMEOUT_MSG "none")
  758. endif()
  759. if(no_progress)
  760. set(SHOW_PROGRESS "")
  761. else()
  762. set(SHOW_PROGRESS "SHOW_PROGRESS")
  763. endif()
  764. if("${hash}" MATCHES "${_ep_hash_regex}")
  765. set(ALGO "${CMAKE_MATCH_1}")
  766. set(EXPECT_VALUE "${CMAKE_MATCH_2}")
  767. else()
  768. set(ALGO "")
  769. set(EXPECT_VALUE "")
  770. endif()
  771. set(TLS_VERIFY_CODE "")
  772. set(TLS_CAINFO_CODE "")
  773. # check for curl globals in the project
  774. if(DEFINED CMAKE_TLS_VERIFY)
  775. set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})")
  776. endif()
  777. if(DEFINED CMAKE_TLS_CAINFO)
  778. set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
  779. endif()
  780. # now check for curl locals so that the local values
  781. # will override the globals
  782. # check for tls_verify argument
  783. string(LENGTH "${tls_verify}" tls_verify_len)
  784. if(tls_verify_len GREATER 0)
  785. set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${tls_verify})")
  786. endif()
  787. # check for tls_cainfo argument
  788. string(LENGTH "${tls_cainfo}" tls_cainfo_len)
  789. if(tls_cainfo_len GREATER 0)
  790. set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
  791. endif()
  792. if(userpwd STREQUAL ":")
  793. set(USERPWD_ARGS)
  794. else()
  795. set(USERPWD_ARGS USERPWD "${userpwd}")
  796. endif()
  797. set(HTTP_HEADERS_ARGS "")
  798. if(NOT http_headers STREQUAL "")
  799. foreach(header ${http_headers})
  800. set(
  801. HTTP_HEADERS_ARGS
  802. "HTTPHEADER \"${header}\"\n ${HTTP_HEADERS_ARGS}"
  803. )
  804. endforeach()
  805. endif()
  806. # Used variables:
  807. # * TLS_VERIFY_CODE
  808. # * TLS_CAINFO_CODE
  809. # * ALGO
  810. # * EXPECT_VALUE
  811. # * REMOTE
  812. # * LOCAL
  813. # * SHOW_PROGRESS
  814. # * TIMEOUT_ARGS
  815. # * TIMEOUT_MSG
  816. # * USERPWD_ARGS
  817. # * HTTP_HEADERS_ARGS
  818. configure_file(
  819. "${_ExternalProject_SELF_DIR}/ExternalProject-download.cmake.in"
  820. "${script_filename}"
  821. @ONLY
  822. )
  823. endfunction()
  824. function(_ep_write_verifyfile_script script_filename LOCAL hash)
  825. if("${hash}" MATCHES "${_ep_hash_regex}")
  826. set(ALGO "${CMAKE_MATCH_1}")
  827. string(TOLOWER "${CMAKE_MATCH_2}" EXPECT_VALUE)
  828. else()
  829. set(ALGO "")
  830. set(EXPECT_VALUE "")
  831. endif()
  832. # Used variables:
  833. # * ALGO
  834. # * EXPECT_VALUE
  835. # * LOCAL
  836. configure_file(
  837. "${_ExternalProject_SELF_DIR}/ExternalProject-verify.cmake.in"
  838. "${script_filename}"
  839. @ONLY
  840. )
  841. endfunction()
  842. function(_ep_write_extractfile_script script_filename name filename directory)
  843. set(args "")
  844. if(filename MATCHES "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
  845. set(args xfz)
  846. endif()
  847. if(filename MATCHES "(\\.|=)tar$")
  848. set(args xf)
  849. endif()
  850. if(args STREQUAL "")
  851. message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip")
  852. return()
  853. endif()
  854. file(WRITE ${script_filename}
  855. "# Make file names absolute:
  856. #
  857. get_filename_component(filename \"${filename}\" ABSOLUTE)
  858. get_filename_component(directory \"${directory}\" ABSOLUTE)
  859. message(STATUS \"extracting...
  860. src='\${filename}'
  861. dst='\${directory}'\")
  862. if(NOT EXISTS \"\${filename}\")
  863. message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\")
  864. endif()
  865. # Prepare a space for extracting:
  866. #
  867. set(i 1234)
  868. while(EXISTS \"\${directory}/../ex-${name}\${i}\")
  869. math(EXPR i \"\${i} + 1\")
  870. endwhile()
  871. set(ut_dir \"\${directory}/../ex-${name}\${i}\")
  872. file(MAKE_DIRECTORY \"\${ut_dir}\")
  873. # Extract it:
  874. #
  875. message(STATUS \"extracting... [tar ${args}]\")
  876. execute_process(COMMAND \${CMAKE_COMMAND} -E tar ${args} \${filename}
  877. WORKING_DIRECTORY \${ut_dir}
  878. RESULT_VARIABLE rv)
  879. if(NOT rv EQUAL 0)
  880. message(STATUS \"extracting... [error clean up]\")
  881. file(REMOVE_RECURSE \"\${ut_dir}\")
  882. message(FATAL_ERROR \"error: extract of '\${filename}' failed\")
  883. endif()
  884. # Analyze what came out of the tar file:
  885. #
  886. message(STATUS \"extracting... [analysis]\")
  887. file(GLOB contents \"\${ut_dir}/*\")
  888. list(REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\")
  889. list(LENGTH contents n)
  890. if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
  891. set(contents \"\${ut_dir}\")
  892. endif()
  893. # Move \"the one\" directory to the final directory:
  894. #
  895. message(STATUS \"extracting... [rename]\")
  896. file(REMOVE_RECURSE \${directory})
  897. get_filename_component(contents \${contents} ABSOLUTE)
  898. file(RENAME \${contents} \${directory})
  899. # Clean up:
  900. #
  901. message(STATUS \"extracting... [clean up]\")
  902. file(REMOVE_RECURSE \"\${ut_dir}\")
  903. message(STATUS \"extracting... done\")
  904. "
  905. )
  906. endfunction()
  907. function(_ep_set_directories name)
  908. get_property(prefix TARGET ${name} PROPERTY _EP_PREFIX)
  909. if(NOT prefix)
  910. get_property(prefix DIRECTORY PROPERTY EP_PREFIX)
  911. if(NOT prefix)
  912. get_property(base DIRECTORY PROPERTY EP_BASE)
  913. if(NOT base)
  914. set(prefix "${name}-prefix")
  915. endif()
  916. endif()
  917. endif()
  918. if(prefix)
  919. set(tmp_default "${prefix}/tmp")
  920. set(download_default "${prefix}/src")
  921. set(source_default "${prefix}/src/${name}")
  922. set(binary_default "${prefix}/src/${name}-build")
  923. set(stamp_default "${prefix}/src/${name}-stamp")
  924. set(install_default "${prefix}")
  925. else()
  926. set(tmp_default "${base}/tmp/${name}")
  927. set(download_default "${base}/Download/${name}")
  928. set(source_default "${base}/Source/${name}")
  929. set(binary_default "${base}/Build/${name}")
  930. set(stamp_default "${base}/Stamp/${name}")
  931. set(install_default "${base}/Install/${name}")
  932. endif()
  933. get_property(build_in_source TARGET ${name} PROPERTY _EP_BUILD_IN_SOURCE)
  934. if(build_in_source)
  935. get_property(have_binary_dir TARGET ${name} PROPERTY _EP_BINARY_DIR SET)
  936. if(have_binary_dir)
  937. message(FATAL_ERROR
  938. "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!")
  939. endif()
  940. endif()
  941. set(top "${CMAKE_CURRENT_BINARY_DIR}")
  942. set(places stamp download source binary install tmp)
  943. foreach(var ${places})
  944. string(TOUPPER "${var}" VAR)
  945. get_property(${var}_dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  946. if(NOT ${var}_dir)
  947. set(${var}_dir "${${var}_default}")
  948. endif()
  949. if(NOT IS_ABSOLUTE "${${var}_dir}")
  950. get_filename_component(${var}_dir "${top}/${${var}_dir}" ABSOLUTE)
  951. endif()
  952. set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
  953. endforeach()
  954. get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
  955. if(NOT source_subdir)
  956. set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "")
  957. elseif(IS_ABSOLUTE "${source_subdir}")
  958. message(FATAL_ERROR
  959. "External project ${name} has non-relative SOURCE_SUBDIR!")
  960. else()
  961. # Prefix with a slash so that when appended to the source directory, it
  962. # behaves as expected.
  963. set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}")
  964. endif()
  965. if(build_in_source)
  966. get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
  967. set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
  968. endif()
  969. # Make the directories at CMake configure time *and* add a custom command
  970. # to make them at build time. They need to exist at makefile generation
  971. # time for Borland make and wmake so that CMake may generate makefiles
  972. # with "cd C:\short\paths\with\no\spaces" commands in them.
  973. #
  974. # Additionally, the add_custom_command is still used in case somebody
  975. # removes one of the necessary directories and tries to rebuild without
  976. # re-running cmake.
  977. foreach(var ${places})
  978. string(TOUPPER "${var}" VAR)
  979. get_property(dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  980. file(MAKE_DIRECTORY "${dir}")
  981. if(NOT EXISTS "${dir}")
  982. message(FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)")
  983. endif()
  984. endforeach()
  985. endfunction()
  986. # IMPORTANT: this MUST be a macro and not a function because of the
  987. # in-place replacements that occur in each ${var}
  988. #
  989. macro(_ep_replace_location_tags target_name)
  990. set(vars ${ARGN})
  991. foreach(var ${vars})
  992. if(${var})
  993. foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
  994. get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
  995. string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
  996. endforeach()
  997. endif()
  998. endforeach()
  999. endmacro()
  1000. function(_ep_command_line_to_initial_cache var args force)
  1001. set(script_initial_cache "")
  1002. set(regex "^([^:]+):([^=]+)=(.*)$")
  1003. set(setArg "")
  1004. set(forceArg "")
  1005. if(force)
  1006. set(forceArg "FORCE")
  1007. endif()
  1008. foreach(line ${args})
  1009. if("${line}" MATCHES "^-D(.*)")
  1010. set(line "${CMAKE_MATCH_1}")
  1011. if(setArg)
  1012. # This is required to build up lists in variables, or complete an entry
  1013. string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
  1014. string(APPEND script_initial_cache "\n${setArg}")
  1015. set(accumulator "")
  1016. set(setArg "")
  1017. endif()
  1018. if("${line}" MATCHES "${regex}")
  1019. set(name "${CMAKE_MATCH_1}")
  1020. set(type "${CMAKE_MATCH_2}")
  1021. set(value "${CMAKE_MATCH_3}")
  1022. set(setArg "set(${name} \"${value}")
  1023. else()
  1024. message(WARNING "Line '${line}' does not match regex. Ignoring.")
  1025. endif()
  1026. else()
  1027. # Assume this is a list to append to the last var
  1028. string(APPEND accumulator ";${line}")
  1029. endif()
  1030. endforeach()
  1031. # Catch the final line of the args
  1032. if(setArg)
  1033. string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
  1034. string(APPEND script_initial_cache "\n${setArg}")
  1035. endif()
  1036. set(${var} ${script_initial_cache} PARENT_SCOPE)
  1037. endfunction()
  1038. function(_ep_write_initial_cache target_name script_filename script_initial_cache)
  1039. # Write out values into an initial cache, that will be passed to CMake with -C
  1040. # Replace location tags.
  1041. _ep_replace_location_tags(${target_name} script_initial_cache)
  1042. _ep_replace_location_tags(${target_name} script_filename)
  1043. # Write out the initial cache file to the location specified.
  1044. file(GENERATE OUTPUT "${script_filename}" CONTENT "${script_initial_cache}")
  1045. endfunction()
  1046. function(ExternalProject_Get_Property name)
  1047. foreach(var ${ARGN})
  1048. string(TOUPPER "${var}" VAR)
  1049. get_property(is_set TARGET ${name} PROPERTY _EP_${VAR} SET)
  1050. if(NOT is_set)
  1051. message(FATAL_ERROR "External project \"${name}\" has no ${var}")
  1052. endif()
  1053. get_property(${var} TARGET ${name} PROPERTY _EP_${VAR})
  1054. set(${var} "${${var}}" PARENT_SCOPE)
  1055. endforeach()
  1056. endfunction()
  1057. function(_ep_get_configure_command_id name cfg_cmd_id_var)
  1058. get_target_property(cmd ${name} _EP_CONFIGURE_COMMAND)
  1059. if(cmd STREQUAL "")
  1060. # Explicit empty string means no configure step for this project
  1061. set(${cfg_cmd_id_var} "none" PARENT_SCOPE)
  1062. else()
  1063. if(NOT cmd)
  1064. # Default is "use cmake":
  1065. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  1066. else()
  1067. # Otherwise we have to analyze the value:
  1068. if(cmd MATCHES "^[^;]*/configure")
  1069. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  1070. elseif(cmd MATCHES "^[^;]*/cmake" AND NOT cmd MATCHES ";-[PE];")
  1071. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  1072. elseif(cmd MATCHES "config")
  1073. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  1074. else()
  1075. set(${cfg_cmd_id_var} "unknown:${cmd}" PARENT_SCOPE)
  1076. endif()
  1077. endif()
  1078. endif()
  1079. endfunction()
  1080. function(_ep_get_build_command name step cmd_var)
  1081. set(cmd "${${cmd_var}}")
  1082. if(NOT cmd)
  1083. set(args)
  1084. _ep_get_configure_command_id(${name} cfg_cmd_id)
  1085. if(cfg_cmd_id STREQUAL "cmake")
  1086. # CMake project. Select build command based on generator.
  1087. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  1088. if("${CMAKE_GENERATOR}" MATCHES "Make" AND
  1089. ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator))
  1090. # The project uses the same Makefile generator. Use recursive make.
  1091. set(cmd "$(MAKE)")
  1092. if(step STREQUAL "INSTALL")
  1093. set(args install)
  1094. endif()
  1095. if("x${step}x" STREQUAL "xTESTx")
  1096. set(args test)
  1097. endif()
  1098. else()
  1099. # Drive the project with "cmake --build".
  1100. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  1101. if(cmake_command)
  1102. set(cmd "${cmake_command}")
  1103. else()
  1104. set(cmd "${CMAKE_COMMAND}")
  1105. endif()
  1106. set(args --build ".")
  1107. if(CMAKE_CONFIGURATION_TYPES)
  1108. if (CMAKE_CFG_INTDIR AND
  1109. NOT CMAKE_CFG_INTDIR STREQUAL "." AND
  1110. NOT CMAKE_CFG_INTDIR MATCHES "\\$")
  1111. # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value
  1112. # provided by multi-configuration generators. Some projects were
  1113. # taking advantage of that undocumented implementation detail to
  1114. # specify a specific configuration here. They should use
  1115. # BUILD_COMMAND to change the default command instead, but for
  1116. # compatibility honor the value.
  1117. set(config ${CMAKE_CFG_INTDIR})
  1118. message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n"
  1119. "To get a non-default build command, use the BUILD_COMMAND option.")
  1120. else()
  1121. set(config $<CONFIG>)
  1122. endif()
  1123. list(APPEND args --config ${config})
  1124. endif()
  1125. if(step STREQUAL "INSTALL")
  1126. list(APPEND args --target install)
  1127. endif()
  1128. # But for "TEST" drive the project with corresponding "ctest".
  1129. if("x${step}x" STREQUAL "xTESTx")
  1130. string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
  1131. set(args "")
  1132. if(CMAKE_CONFIGURATION_TYPES)
  1133. list(APPEND args -C ${config})
  1134. endif()
  1135. endif()
  1136. endif()
  1137. else()
  1138. # Non-CMake project. Guess "make" and "make install" and "make test".
  1139. if("${CMAKE_GENERATOR}" MATCHES "Makefiles")
  1140. # Try to get the parallel arguments
  1141. set(cmd "$(MAKE)")
  1142. else()
  1143. set(cmd "make")
  1144. endif()
  1145. if(step STREQUAL "INSTALL")
  1146. set(args install)
  1147. endif()
  1148. if("x${step}x" STREQUAL "xTESTx")
  1149. set(args test)
  1150. endif()
  1151. endif()
  1152. # Use user-specified arguments instead of default arguments, if any.
  1153. get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET)
  1154. if(have_args)
  1155. get_target_property(args ${name} _EP_${step}_ARGS)
  1156. endif()
  1157. list(APPEND cmd ${args})
  1158. endif()
  1159. set(${cmd_var} "${cmd}" PARENT_SCOPE)
  1160. endfunction()
  1161. function(_ep_write_log_script name step cmd_var)
  1162. ExternalProject_Get_Property(${name} stamp_dir)
  1163. set(command "${${cmd_var}}")
  1164. set(make "")
  1165. set(code_cygpath_make "")
  1166. if(command MATCHES "^\\$\\(MAKE\\)")
  1167. # GNU make recognizes the string "$(MAKE)" as recursive make, so
  1168. # ensure that it appears directly in the makefile.
  1169. string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}")
  1170. set(make "-Dmake=$(MAKE)")
  1171. if(WIN32 AND NOT CYGWIN)
  1172. set(code_cygpath_make "
  1173. if(\${make} MATCHES \"^/\")
  1174. execute_process(
  1175. COMMAND cygpath -w \${make}
  1176. OUTPUT_VARIABLE cygpath_make
  1177. ERROR_VARIABLE cygpath_make
  1178. RESULT_VARIABLE cygpath_error
  1179. OUTPUT_STRIP_TRAILING_WHITESPACE
  1180. )
  1181. if(NOT cygpath_error)
  1182. set(make \${cygpath_make})
  1183. endif()
  1184. endif()
  1185. ")
  1186. endif()
  1187. endif()
  1188. set(config "")
  1189. if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$")
  1190. string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}")
  1191. set(config "-Dconfig=${CMAKE_CFG_INTDIR}")
  1192. endif()
  1193. # Wrap multiple 'COMMAND' lines up into a second-level wrapper
  1194. # script so all output can be sent to one log file.
  1195. if(command MATCHES "(^|;)COMMAND;")
  1196. set(code_execute_process "
  1197. ${code_cygpath_make}
  1198. execute_process(COMMAND \${command} RESULT_VARIABLE result)
  1199. if(result)
  1200. set(msg \"Command failed (\${result}):\\n\")
  1201. foreach(arg IN LISTS command)
  1202. set(msg \"\${msg} '\${arg}'\")
  1203. endforeach()
  1204. message(FATAL_ERROR \"\${msg}\")
  1205. endif()
  1206. ")
  1207. set(code "")
  1208. set(cmd "")
  1209. set(sep "")
  1210. foreach(arg IN LISTS command)
  1211. if("x${arg}" STREQUAL "xCOMMAND")
  1212. if(NOT "x${cmd}" STREQUAL "x")
  1213. string(APPEND code "set(command \"${cmd}\")${code_execute_process}")
  1214. endif()
  1215. set(cmd "")
  1216. set(sep "")
  1217. else()
  1218. string(APPEND cmd "${sep}${arg}")
  1219. set(sep ";")
  1220. endif()
  1221. endforeach()
  1222. string(APPEND code "set(command \"${cmd}\")${code_execute_process}")
  1223. file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}")
  1224. set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake)
  1225. endif()
  1226. # Wrap the command in a script to log output to files.
  1227. set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake)
  1228. set(logbase ${stamp_dir}/${name}-${step})
  1229. set(code "
  1230. ${code_cygpath_make}
  1231. set(command \"${command}\")
  1232. execute_process(
  1233. COMMAND \${command}
  1234. RESULT_VARIABLE result
  1235. OUTPUT_FILE \"${logbase}-out.log\"
  1236. ERROR_FILE \"${logbase}-err.log\"
  1237. )
  1238. if(result)
  1239. set(msg \"Command failed: \${result}\\n\")
  1240. foreach(arg IN LISTS command)
  1241. set(msg \"\${msg} '\${arg}'\")
  1242. endforeach()
  1243. set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\")
  1244. message(FATAL_ERROR \"\${msg}\")
  1245. else()
  1246. set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\")
  1247. message(STATUS \"\${msg}\")
  1248. endif()
  1249. ")
  1250. file(GENERATE OUTPUT "${script}" CONTENT "${code}")
  1251. set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script})
  1252. set(${cmd_var} "${command}" PARENT_SCOPE)
  1253. endfunction()
  1254. # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced
  1255. # makefiles with "/./" in paths for custom command dependencies. Which
  1256. # resulted in problems with parallel make -j invocations.
  1257. #
  1258. # This function was added so that the suffix (search below for ${cfgdir}) is
  1259. # only set to "/${CMAKE_CFG_INTDIR}" when ${CMAKE_CFG_INTDIR} is not going to
  1260. # be "." (multi-configuration build systems like Visual Studio and Xcode...)
  1261. #
  1262. function(_ep_get_configuration_subdir_suffix suffix_var)
  1263. set(suffix "")
  1264. if(CMAKE_CONFIGURATION_TYPES)
  1265. set(suffix "/${CMAKE_CFG_INTDIR}")
  1266. endif()
  1267. set(${suffix_var} "${suffix}" PARENT_SCOPE)
  1268. endfunction()
  1269. function(_ep_get_step_stampfile name step stampfile_var)
  1270. ExternalProject_Get_Property(${name} stamp_dir)
  1271. _ep_get_configuration_subdir_suffix(cfgdir)
  1272. set(stampfile "${stamp_dir}${cfgdir}/${name}-${step}")
  1273. set(${stampfile_var} "${stampfile}" PARENT_SCOPE)
  1274. endfunction()
  1275. function(ExternalProject_Add_StepTargets name)
  1276. set(steps ${ARGN})
  1277. if(ARGC GREATER 1 AND "${ARGV1}" STREQUAL "NO_DEPENDS")
  1278. set(no_deps 1)
  1279. list(REMOVE_AT steps 0)
  1280. endif()
  1281. foreach(step ${steps})
  1282. if(no_deps AND "${step}" MATCHES "^(configure|build|install|test)$")
  1283. message(AUTHOR_WARNING "Using NO_DEPENDS for \"${step}\" step might break parallel builds")
  1284. endif()
  1285. _ep_get_step_stampfile(${name} ${step} stamp_file)
  1286. add_custom_target(${name}-${step}
  1287. DEPENDS ${stamp_file})
  1288. set_property(TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1)
  1289. set_property(TARGET ${name}-${step} PROPERTY LABELS ${name})
  1290. set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}")
  1291. # Depend on other external projects (target-level).
  1292. if(NOT no_deps)
  1293. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  1294. foreach(arg IN LISTS deps)
  1295. add_dependencies(${name}-${step} ${arg})
  1296. endforeach()
  1297. endif()
  1298. endforeach()
  1299. endfunction()
  1300. function(ExternalProject_Add_Step name step)
  1301. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  1302. _ep_get_configuration_subdir_suffix(cfgdir)
  1303. set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
  1304. _ep_get_step_stampfile(${name} ${step} stamp_file)
  1305. _ep_parse_arguments(ExternalProject_Add_Step
  1306. ${name} _EP_${step}_ "${ARGN}")
  1307. get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN)
  1308. if(NOT exclude_from_main)
  1309. add_custom_command(APPEND
  1310. OUTPUT ${complete_stamp_file}
  1311. DEPENDS ${stamp_file}
  1312. )
  1313. endif()
  1314. # Steps depending on this step.
  1315. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS)
  1316. foreach(depender IN LISTS dependers)
  1317. _ep_get_step_stampfile(${name} ${depender} depender_stamp_file)
  1318. add_custom_command(APPEND
  1319. OUTPUT ${depender_stamp_file}
  1320. DEPENDS ${stamp_file}
  1321. )
  1322. endforeach()
  1323. # Dependencies on files.
  1324. get_property(depends TARGET ${name} PROPERTY _EP_${step}_DEPENDS)
  1325. # Byproducts of the step.
  1326. get_property(byproducts TARGET ${name} PROPERTY _EP_${step}_BYPRODUCTS)
  1327. # Dependencies on steps.
  1328. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES)
  1329. foreach(dependee IN LISTS dependees)
  1330. _ep_get_step_stampfile(${name} ${dependee} dependee_stamp_file)
  1331. list(APPEND depends ${dependee_stamp_file})
  1332. endforeach()
  1333. # The command to run.
  1334. get_property(command TARGET ${name} PROPERTY _EP_${step}_COMMAND)
  1335. if(command)
  1336. set(comment "Performing ${step} step for '${name}'")
  1337. else()
  1338. set(comment "No ${step} step for '${name}'")
  1339. endif()
  1340. get_property(work_dir TARGET ${name} PROPERTY _EP_${step}_WORKING_DIRECTORY)
  1341. # Replace list separators.
  1342. get_property(sep TARGET ${name} PROPERTY _EP_LIST_SEPARATOR)
  1343. if(sep AND command)
  1344. string(REPLACE "${sep}" "\\;" command "${command}")
  1345. endif()
  1346. # Replace location tags.
  1347. _ep_replace_location_tags(${name} comment command work_dir byproducts)
  1348. # Custom comment?
  1349. get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET)
  1350. if(comment_set)
  1351. get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT)
  1352. endif()
  1353. # Uses terminal?
  1354. get_property(uses_terminal TARGET ${name} PROPERTY _EP_${step}_USES_TERMINAL)
  1355. if(uses_terminal)
  1356. set(uses_terminal USES_TERMINAL)
  1357. else()
  1358. set(uses_terminal "")
  1359. endif()
  1360. # Run every time?
  1361. get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS)
  1362. if(always)
  1363. set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
  1364. set(touch)
  1365. # Remove any existing stamp in case the option changed in an existing tree.
  1366. if(CMAKE_CONFIGURATION_TYPES)
  1367. foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
  1368. string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}")
  1369. file(REMOVE ${stamp_file_config})
  1370. endforeach()
  1371. else()
  1372. file(REMOVE ${stamp_file})
  1373. endif()
  1374. else()
  1375. set(touch ${CMAKE_COMMAND} -E touch ${stamp_file})
  1376. endif()
  1377. # Wrap with log script?
  1378. get_property(log TARGET ${name} PROPERTY _EP_${step}_LOG)
  1379. if(command AND log)
  1380. _ep_write_log_script(${name} ${step} command)
  1381. endif()
  1382. if("${command}" STREQUAL "")
  1383. # Some generators (i.e. Xcode) will not generate a file level target
  1384. # if no command is set, and therefore the dependencies on this
  1385. # target will be broken.
  1386. # The empty command is replaced by an echo command here in order to
  1387. # avoid this issue.
  1388. set(command ${CMAKE_COMMAND} -E echo_append)
  1389. endif()
  1390. add_custom_command(
  1391. OUTPUT ${stamp_file}
  1392. BYPRODUCTS ${byproducts}
  1393. COMMENT ${comment}
  1394. COMMAND ${command}
  1395. COMMAND ${touch}
  1396. DEPENDS ${depends}
  1397. WORKING_DIRECTORY ${work_dir}
  1398. VERBATIM
  1399. ${uses_terminal}
  1400. )
  1401. set_property(TARGET ${name} APPEND PROPERTY _EP_STEPS ${step})
  1402. # Add custom "step target"?
  1403. get_property(step_targets TARGET ${name} PROPERTY _EP_STEP_TARGETS)
  1404. if(NOT step_targets)
  1405. get_property(step_targets DIRECTORY PROPERTY EP_STEP_TARGETS)
  1406. endif()
  1407. foreach(st ${step_targets})
  1408. if("${st}" STREQUAL "${step}")
  1409. ExternalProject_Add_StepTargets(${name} ${step})
  1410. break()
  1411. endif()
  1412. endforeach()
  1413. get_property(independent_step_targets TARGET ${name} PROPERTY _EP_INDEPENDENT_STEP_TARGETS)
  1414. if(NOT independent_step_targets)
  1415. get_property(independent_step_targets DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS)
  1416. endif()
  1417. foreach(st ${independent_step_targets})
  1418. if("${st}" STREQUAL "${step}")
  1419. ExternalProject_Add_StepTargets(${name} NO_DEPENDS ${step})
  1420. break()
  1421. endif()
  1422. endforeach()
  1423. endfunction()
  1424. function(ExternalProject_Add_StepDependencies name step)
  1425. set(dependencies ${ARGN})
  1426. # Sanity checks on "name" and "step".
  1427. if(NOT TARGET ${name})
  1428. message(FATAL_ERROR "Cannot find target \"${name}\". Perhaps it has not yet been created using ExternalProject_Add.")
  1429. endif()
  1430. get_property(type TARGET ${name} PROPERTY TYPE)
  1431. if(NOT type STREQUAL "UTILITY")
  1432. message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.")
  1433. endif()
  1434. get_property(is_ep TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT)
  1435. if(NOT is_ep)
  1436. message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.")
  1437. endif()
  1438. get_property(steps TARGET ${name} PROPERTY _EP_STEPS)
  1439. list(FIND steps ${step} is_step)
  1440. if(NOT is_step)
  1441. message(FATAL_ERROR "External project \"${name}\" does not have a step \"${step}\".")
  1442. endif()
  1443. if(TARGET ${name}-${step})
  1444. get_property(type TARGET ${name}-${step} PROPERTY TYPE)
  1445. if(NOT type STREQUAL "UTILITY")
  1446. message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.")
  1447. endif()
  1448. get_property(is_ep_step TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP)
  1449. if(NOT is_ep_step)
  1450. message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.")
  1451. endif()
  1452. endif()
  1453. # Always add file-level dependency, but add target-level dependency
  1454. # only if the target exists for that step.
  1455. _ep_get_step_stampfile(${name} ${step} stamp_file)
  1456. foreach(dep ${dependencies})
  1457. add_custom_command(APPEND
  1458. OUTPUT ${stamp_file}
  1459. DEPENDS ${dep})
  1460. if(TARGET ${name}-${step})
  1461. foreach(dep ${dependencies})
  1462. add_dependencies(${name}-${step} ${dep})
  1463. endforeach()
  1464. endif()
  1465. endforeach()
  1466. endfunction()
  1467. function(_ep_add_mkdir_command name)
  1468. ExternalProject_Get_Property(${name}
  1469. source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
  1470. _ep_get_configuration_subdir_suffix(cfgdir)
  1471. ExternalProject_Add_Step(${name} mkdir
  1472. COMMENT "Creating directories for '${name}'"
  1473. COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
  1474. COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir}
  1475. COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}
  1476. COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
  1477. COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
  1478. COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
  1479. )
  1480. endfunction()
  1481. function(_ep_is_dir_empty dir empty_var)
  1482. file(GLOB gr "${dir}/*")
  1483. if("${gr}" STREQUAL "")
  1484. set(${empty_var} 1 PARENT_SCOPE)
  1485. else()
  1486. set(${empty_var} 0 PARENT_SCOPE)
  1487. endif()
  1488. endfunction()
  1489. function(_ep_add_download_command name)
  1490. ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir)
  1491. get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET)
  1492. get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND)
  1493. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  1494. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  1495. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  1496. get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY )
  1497. get_property(url TARGET ${name} PROPERTY _EP_URL)
  1498. get_property(fname TARGET ${name} PROPERTY _EP_DOWNLOAD_NAME)
  1499. # TODO: Perhaps file:// should be copied to download dir before extraction.
  1500. string(REGEX REPLACE "file://" "" url "${url}")
  1501. set(depends)
  1502. set(comment)
  1503. set(work_dir)
  1504. if(cmd_set)
  1505. set(work_dir ${download_dir})
  1506. elseif(cvs_repository)
  1507. find_package(CVS QUIET)
  1508. if(NOT CVS_EXECUTABLE)
  1509. message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
  1510. endif()
  1511. get_target_property(cvs_module ${name} _EP_CVS_MODULE)
  1512. if(NOT cvs_module)
  1513. message(FATAL_ERROR "error: no CVS_MODULE")
  1514. endif()
  1515. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  1516. set(repository ${cvs_repository})
  1517. set(module ${cvs_module})
  1518. set(tag ${cvs_tag})
  1519. configure_file(
  1520. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1521. "${stamp_dir}/${name}-cvsinfo.txt"
  1522. @ONLY
  1523. )
  1524. get_filename_component(src_name "${source_dir}" NAME)
  1525. get_filename_component(work_dir "${source_dir}" PATH)
  1526. set(comment "Performing download step (CVS checkout) for '${name}'")
  1527. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module})
  1528. list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt)
  1529. elseif(svn_repository)
  1530. find_package(Subversion QUIET)
  1531. if(NOT Subversion_SVN_EXECUTABLE)
  1532. message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
  1533. endif()
  1534. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  1535. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  1536. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  1537. get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT)
  1538. set(repository "${svn_repository} user=${svn_username} password=${svn_password}")
  1539. set(module)
  1540. set(tag ${svn_revision})
  1541. configure_file(
  1542. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1543. "${stamp_dir}/${name}-svninfo.txt"
  1544. @ONLY
  1545. )
  1546. get_filename_component(src_name "${source_dir}" NAME)
  1547. get_filename_component(work_dir "${source_dir}" PATH)
  1548. set(comment "Performing download step (SVN checkout) for '${name}'")
  1549. set(svn_user_pw_args "")
  1550. if(DEFINED svn_username)
  1551. set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}")
  1552. endif()
  1553. if(DEFINED svn_password)
  1554. set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}")
  1555. endif()
  1556. if(svn_trust_cert)
  1557. set(svn_trust_cert_args --trust-server-cert)
  1558. endif()
  1559. set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision}
  1560. --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name})
  1561. list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
  1562. elseif(git_repository)
  1563. unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
  1564. find_package(Git QUIET)
  1565. if(NOT GIT_EXECUTABLE)
  1566. message(FATAL_ERROR "error: could not find git for clone of ${name}")
  1567. endif()
  1568. # The git submodule update '--recursive' flag requires git >= v1.6.5
  1569. #
  1570. if(GIT_VERSION_STRING VERSION_LESS 1.6.5)
  1571. message(FATAL_ERROR "error: git version 1.6.5 or later required for 'git submodule update --recursive': GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
  1572. endif()
  1573. get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG)
  1574. if(NOT git_tag)
  1575. set(git_tag "master")
  1576. endif()
  1577. get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
  1578. get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
  1579. if(NOT git_remote_name)
  1580. set(git_remote_name "origin")
  1581. endif()
  1582. get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
  1583. if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY)
  1584. set(tls_verify "${CMAKE_TLS_VERIFY}")
  1585. endif()
  1586. get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW)
  1587. get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS)
  1588. # For the download step, and the git clone operation, only the repository
  1589. # should be recorded in a configured RepositoryInfo file. If the repo
  1590. # changes, the clone script should be run again. But if only the tag
  1591. # changes, avoid running the clone script again. Let the 'always' running
  1592. # update step checkout the new tag.
  1593. #
  1594. set(repository ${git_repository})
  1595. set(module)
  1596. set(tag)
  1597. configure_file(
  1598. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1599. "${stamp_dir}/${name}-gitinfo.txt"
  1600. @ONLY
  1601. )
  1602. get_filename_component(src_name "${source_dir}" NAME)
  1603. get_filename_component(work_dir "${source_dir}" PATH)
  1604. # Since git clone doesn't succeed if the non-empty source_dir exists,
  1605. # create a cmake script to invoke as download command.
  1606. # The script will delete the source directory and then call git clone.
  1607. #
  1608. _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
  1609. ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" ${src_name} ${work_dir}
  1610. ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
  1611. )
  1612. set(comment "Performing download step (git clone) for '${name}'")
  1613. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
  1614. list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
  1615. elseif(hg_repository)
  1616. find_package(Hg QUIET)
  1617. if(NOT HG_EXECUTABLE)
  1618. message(FATAL_ERROR "error: could not find hg for clone of ${name}")
  1619. endif()
  1620. get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG)
  1621. if(NOT hg_tag)
  1622. set(hg_tag "tip")
  1623. endif()
  1624. # For the download step, and the hg clone operation, only the repository
  1625. # should be recorded in a configured RepositoryInfo file. If the repo
  1626. # changes, the clone script should be run again. But if only the tag
  1627. # changes, avoid running the clone script again. Let the 'always' running
  1628. # update step checkout the new tag.
  1629. #
  1630. set(repository ${hg_repository})
  1631. set(module)
  1632. set(tag)
  1633. configure_file(
  1634. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1635. "${stamp_dir}/${name}-hginfo.txt"
  1636. @ONLY
  1637. )
  1638. get_filename_component(src_name "${source_dir}" NAME)
  1639. get_filename_component(work_dir "${source_dir}" PATH)
  1640. # Since hg clone doesn't succeed if the non-empty source_dir exists,
  1641. # create a cmake script to invoke as download command.
  1642. # The script will delete the source directory and then call hg clone.
  1643. #
  1644. _ep_write_hgclone_script(${tmp_dir}/${name}-hgclone.cmake ${source_dir}
  1645. ${HG_EXECUTABLE} ${hg_repository} ${hg_tag} ${src_name} ${work_dir}
  1646. ${stamp_dir}/${name}-hginfo.txt ${stamp_dir}/${name}-hgclone-lastrun.txt
  1647. )
  1648. set(comment "Performing download step (hg clone) for '${name}'")
  1649. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-hgclone.cmake)
  1650. list(APPEND depends ${stamp_dir}/${name}-hginfo.txt)
  1651. elseif(url)
  1652. get_filename_component(work_dir "${source_dir}" PATH)
  1653. get_property(hash TARGET ${name} PROPERTY _EP_URL_HASH)
  1654. if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}")
  1655. message(FATAL_ERROR "URL_HASH is set to\n ${hash}\n"
  1656. "but must be ALGO=value where ALGO is\n ${_ep_hash_algos}\n"
  1657. "and value is a hex string.")
  1658. endif()
  1659. get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5)
  1660. if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}")
  1661. message(FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string.")
  1662. endif()
  1663. if(md5 AND NOT hash)
  1664. set(hash "MD5=${md5}")
  1665. endif()
  1666. set(repository "external project URL")
  1667. set(module "${url}")
  1668. set(tag "${hash}")
  1669. configure_file(
  1670. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1671. "${stamp_dir}/${name}-urlinfo.txt"
  1672. @ONLY
  1673. )
  1674. list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt)
  1675. list(LENGTH url url_list_length)
  1676. if(NOT "${url_list_length}" STREQUAL "1")
  1677. foreach(entry ${url})
  1678. if(NOT "${entry}" MATCHES "^[a-z]+://")
  1679. message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)")
  1680. endif()
  1681. endforeach()
  1682. if("x${fname}" STREQUAL "x")
  1683. list(GET url 0 fname)
  1684. endif()
  1685. endif()
  1686. if(IS_DIRECTORY "${url}")
  1687. get_filename_component(abs_dir "${url}" ABSOLUTE)
  1688. set(comment "Performing download step (DIR copy) for '${name}'")
  1689. set(cmd ${CMAKE_COMMAND} -E remove_directory ${source_dir}
  1690. COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir})
  1691. else()
  1692. get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT SET)
  1693. if("${url}" MATCHES "^[a-z]+://")
  1694. # TODO: Should download and extraction be different steps?
  1695. if("x${fname}" STREQUAL "x")
  1696. set(fname "${url}")
  1697. endif()
  1698. if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]])
  1699. set(fname "${CMAKE_MATCH_1}")
  1700. elseif(no_extract)
  1701. get_filename_component(fname "${fname}" NAME)
  1702. else()
  1703. # Fall back to a default file name. The actual file name does not
  1704. # matter because it is used only internally and our extraction tool
  1705. # inspects the file content directly. If it turns out the wrong URL
  1706. # was given that will be revealed during the build which is an easier
  1707. # place for users to diagnose than an error here anyway.
  1708. set(fname "archive.tar")
  1709. endif()
  1710. string(REPLACE ";" "-" fname "${fname}")
  1711. set(file ${download_dir}/${fname})
  1712. get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
  1713. get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS)
  1714. get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
  1715. get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
  1716. get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME)
  1717. get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD)
  1718. get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER)
  1719. set(download_script "${stamp_dir}/download-${name}.cmake")
  1720. _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}")
  1721. set(cmd ${CMAKE_COMMAND} -P "${download_script}"
  1722. COMMAND)
  1723. if (no_extract)
  1724. set(steps "download and verify")
  1725. else ()
  1726. set(steps "download, verify and extract")
  1727. endif ()
  1728. set(comment "Performing download step (${steps}) for '${name}'")
  1729. file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # already verified by 'download_script'
  1730. else()
  1731. set(file "${url}")
  1732. if (no_extract)
  1733. set(steps "verify")
  1734. else ()
  1735. set(steps "verify and extract")
  1736. endif ()
  1737. set(comment "Performing download step (${steps}) for '${name}'")
  1738. _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
  1739. endif()
  1740. list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake
  1741. COMMAND)
  1742. if (NOT no_extract)
  1743. _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
  1744. list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
  1745. else ()
  1746. set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file})
  1747. endif ()
  1748. endif()
  1749. else()
  1750. _ep_is_dir_empty("${source_dir}" empty)
  1751. if(${empty})
  1752. message(SEND_ERROR
  1753. "No download info given for '${name}' and its source directory:\n"
  1754. " ${source_dir}\n"
  1755. "is not an existing non-empty directory. Please specify one of:\n"
  1756. " * SOURCE_DIR with an existing non-empty directory\n"
  1757. " * URL\n"
  1758. " * GIT_REPOSITORY\n"
  1759. " * HG_REPOSITORY\n"
  1760. " * CVS_REPOSITORY and CVS_MODULE\n"
  1761. " * SVN_REVISION\n"
  1762. " * DOWNLOAD_COMMAND"
  1763. )
  1764. endif()
  1765. endif()
  1766. get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD)
  1767. if(log)
  1768. set(log LOG 1)
  1769. else()
  1770. set(log "")
  1771. endif()
  1772. get_property(uses_terminal TARGET ${name} PROPERTY
  1773. _EP_USES_TERMINAL_DOWNLOAD)
  1774. if(uses_terminal)
  1775. set(uses_terminal USES_TERMINAL 1)
  1776. else()
  1777. set(uses_terminal "")
  1778. endif()
  1779. ExternalProject_Add_Step(${name} download
  1780. COMMENT ${comment}
  1781. COMMAND ${cmd}
  1782. WORKING_DIRECTORY ${work_dir}
  1783. DEPENDS ${depends}
  1784. DEPENDEES mkdir
  1785. ${log}
  1786. ${uses_terminal}
  1787. )
  1788. endfunction()
  1789. function(_ep_add_update_command name)
  1790. ExternalProject_Get_Property(${name} source_dir tmp_dir)
  1791. get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET)
  1792. get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND)
  1793. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  1794. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  1795. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  1796. get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY )
  1797. get_property(update_disconnected_set TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED SET)
  1798. if(update_disconnected_set)
  1799. get_property(update_disconnected TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED)
  1800. else()
  1801. get_property(update_disconnected DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED)
  1802. endif()
  1803. set(work_dir)
  1804. set(comment)
  1805. set(always)
  1806. if(cmd_set)
  1807. set(work_dir ${source_dir})
  1808. if(NOT "x${cmd}" STREQUAL "x")
  1809. set(always 1)
  1810. endif()
  1811. elseif(cvs_repository)
  1812. if(NOT CVS_EXECUTABLE)
  1813. message(FATAL_ERROR "error: could not find cvs for update of ${name}")
  1814. endif()
  1815. set(work_dir ${source_dir})
  1816. set(comment "Performing update step (CVS update) for '${name}'")
  1817. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  1818. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q up -dP ${cvs_tag})
  1819. set(always 1)
  1820. elseif(svn_repository)
  1821. if(NOT Subversion_SVN_EXECUTABLE)
  1822. message(FATAL_ERROR "error: could not find svn for update of ${name}")
  1823. endif()
  1824. set(work_dir ${source_dir})
  1825. set(comment "Performing update step (SVN update) for '${name}'")
  1826. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  1827. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  1828. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  1829. get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT)
  1830. set(svn_user_pw_args "")
  1831. if(DEFINED svn_username)
  1832. set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}")
  1833. endif()
  1834. if(DEFINED svn_password)
  1835. set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}")
  1836. endif()
  1837. if(svn_trust_cert)
  1838. set(svn_trust_cert_args --trust-server-cert)
  1839. endif()
  1840. set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision}
  1841. --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args})
  1842. set(always 1)
  1843. elseif(git_repository)
  1844. unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
  1845. find_package(Git QUIET)
  1846. if(NOT GIT_EXECUTABLE)
  1847. message(FATAL_ERROR "error: could not find git for fetch of ${name}")
  1848. endif()
  1849. set(work_dir ${source_dir})
  1850. set(comment "Performing update step for '${name}'")
  1851. get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG)
  1852. if(NOT git_tag)
  1853. set(git_tag "master")
  1854. endif()
  1855. get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
  1856. if(NOT git_remote_name)
  1857. set(git_remote_name "origin")
  1858. endif()
  1859. get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
  1860. _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
  1861. ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
  1862. )
  1863. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
  1864. set(always 1)
  1865. elseif(hg_repository)
  1866. if(NOT HG_EXECUTABLE)
  1867. message(FATAL_ERROR "error: could not find hg for pull of ${name}")
  1868. endif()
  1869. set(work_dir ${source_dir})
  1870. set(comment "Performing update step (hg pull) for '${name}'")
  1871. get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG)
  1872. if(NOT hg_tag)
  1873. set(hg_tag "tip")
  1874. endif()
  1875. if("${HG_VERSION_STRING}" STREQUAL "2.1")
  1876. message(WARNING "Mercurial 2.1 does not distinguish an empty pull from a failed pull:
  1877. http://mercurial.selenic.com/wiki/UpgradeNotes#A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X
  1878. http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/47656
  1879. Update to Mercurial >= 2.1.1.
  1880. ")
  1881. endif()
  1882. set(cmd ${HG_EXECUTABLE} pull
  1883. COMMAND ${HG_EXECUTABLE} update ${hg_tag}
  1884. )
  1885. set(always 1)
  1886. endif()
  1887. get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE)
  1888. if(log)
  1889. set(log LOG 1)
  1890. else()
  1891. set(log "")
  1892. endif()
  1893. get_property(uses_terminal TARGET ${name} PROPERTY
  1894. _EP_USES_TERMINAL_UPDATE)
  1895. if(uses_terminal)
  1896. set(uses_terminal USES_TERMINAL 1)
  1897. else()
  1898. set(uses_terminal "")
  1899. endif()
  1900. ExternalProject_Add_Step(${name} update
  1901. COMMENT ${comment}
  1902. COMMAND ${cmd}
  1903. ALWAYS ${always}
  1904. EXCLUDE_FROM_MAIN ${update_disconnected}
  1905. WORKING_DIRECTORY ${work_dir}
  1906. DEPENDEES download
  1907. ${log}
  1908. ${uses_terminal}
  1909. )
  1910. if(always AND update_disconnected)
  1911. _ep_get_step_stampfile(${name} skip-update skip-update_stamp_file)
  1912. string(REPLACE "Performing" "Skipping" comment "${comment}")
  1913. ExternalProject_Add_Step(${name} skip-update
  1914. COMMENT ${comment}
  1915. ALWAYS 1
  1916. EXCLUDE_FROM_MAIN 1
  1917. WORKING_DIRECTORY ${work_dir}
  1918. DEPENDEES download
  1919. ${log}
  1920. ${uses_terminal}
  1921. )
  1922. set_property(SOURCE ${skip-update_stamp_file} PROPERTY SYMBOLIC 1)
  1923. endif()
  1924. endfunction()
  1925. function(_ep_add_patch_command name)
  1926. ExternalProject_Get_Property(${name} source_dir)
  1927. get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
  1928. get_property(cmd TARGET ${name} PROPERTY _EP_PATCH_COMMAND)
  1929. set(work_dir)
  1930. if(cmd_set)
  1931. set(work_dir ${source_dir})
  1932. endif()
  1933. ExternalProject_Add_Step(${name} patch
  1934. COMMAND ${cmd}
  1935. WORKING_DIRECTORY ${work_dir}
  1936. DEPENDEES download
  1937. )
  1938. endfunction()
  1939. function(_ep_extract_configure_command var name)
  1940. get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET)
  1941. if(cmd_set)
  1942. get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND)
  1943. else()
  1944. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  1945. if(cmake_command)
  1946. set(cmd "${cmake_command}")
  1947. else()
  1948. set(cmd "${CMAKE_COMMAND}")
  1949. endif()
  1950. get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS)
  1951. list(APPEND cmd ${cmake_args})
  1952. # If there are any CMAKE_CACHE_ARGS or CMAKE_CACHE_DEFAULT_ARGS,
  1953. # write an initial cache and use it
  1954. get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
  1955. get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS)
  1956. if(cmake_cache_args OR cmake_cache_default_args)
  1957. set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake")
  1958. if(cmake_cache_args)
  1959. _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
  1960. endif()
  1961. if(cmake_cache_default_args)
  1962. _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
  1963. endif()
  1964. _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
  1965. list(APPEND cmd "-C${_ep_cache_args_script}")
  1966. endif()
  1967. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  1968. get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM)
  1969. get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET)
  1970. if(cmake_generator)
  1971. list(APPEND cmd "-G${cmake_generator}")
  1972. if(cmake_generator_platform)
  1973. list(APPEND cmd "-A${cmake_generator_platform}")
  1974. endif()
  1975. if(cmake_generator_toolset)
  1976. list(APPEND cmd "-T${cmake_generator_toolset}")
  1977. endif()
  1978. else()
  1979. if(CMAKE_EXTRA_GENERATOR)
  1980. list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
  1981. else()
  1982. list(APPEND cmd "-G${CMAKE_GENERATOR}")
  1983. endif()
  1984. if(cmake_generator_platform)
  1985. message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.")
  1986. endif()
  1987. if(CMAKE_GENERATOR_PLATFORM)
  1988. list(APPEND cmd "-A${CMAKE_GENERATOR_PLATFORM}")
  1989. endif()
  1990. if(cmake_generator_toolset)
  1991. message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.")
  1992. endif()
  1993. if(CMAKE_GENERATOR_TOOLSET)
  1994. list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}")
  1995. endif()
  1996. endif()
  1997. list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>")
  1998. endif()
  1999. set("${var}" "${cmd}" PARENT_SCOPE)
  2000. endfunction()
  2001. # TODO: Make sure external projects use the proper compiler
  2002. function(_ep_add_configure_command name)
  2003. ExternalProject_Get_Property(${name} binary_dir tmp_dir)
  2004. # Depend on other external projects (file-level).
  2005. set(file_deps)
  2006. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  2007. foreach(dep IN LISTS deps)
  2008. get_property(dep_type TARGET ${dep} PROPERTY TYPE)
  2009. if(dep_type STREQUAL "UTILITY")
  2010. get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT)
  2011. if(is_ep)
  2012. _ep_get_step_stampfile(${dep} "done" done_stamp_file)
  2013. list(APPEND file_deps ${done_stamp_file})
  2014. endif()
  2015. endif()
  2016. endforeach()
  2017. _ep_extract_configure_command(cmd ${name})
  2018. # If anything about the configure command changes, (command itself, cmake
  2019. # used, cmake args or cmake generator) then re-run the configure step.
  2020. # Fixes issue https://gitlab.kitware.com/cmake/cmake/issues/10258
  2021. #
  2022. if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
  2023. file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='\@cmd\@'\n")
  2024. endif()
  2025. configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
  2026. list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
  2027. list(APPEND file_deps ${_ep_cache_args_script})
  2028. get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE)
  2029. if(log)
  2030. set(log LOG 1)
  2031. else()
  2032. set(log "")
  2033. endif()
  2034. get_property(uses_terminal TARGET ${name} PROPERTY
  2035. _EP_USES_TERMINAL_CONFIGURE)
  2036. if(uses_terminal)
  2037. set(uses_terminal USES_TERMINAL 1)
  2038. else()
  2039. set(uses_terminal "")
  2040. endif()
  2041. get_property(update_disconnected_set TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED SET)
  2042. if(update_disconnected_set)
  2043. get_property(update_disconnected TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED)
  2044. else()
  2045. get_property(update_disconnected DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED)
  2046. endif()
  2047. if(update_disconnected)
  2048. set(update_dep skip-update)
  2049. else()
  2050. set(update_dep update)
  2051. endif()
  2052. ExternalProject_Add_Step(${name} configure
  2053. COMMAND ${cmd}
  2054. WORKING_DIRECTORY ${binary_dir}
  2055. DEPENDEES ${update_dep} patch
  2056. DEPENDS ${file_deps}
  2057. ${log}
  2058. ${uses_terminal}
  2059. )
  2060. endfunction()
  2061. function(_ep_add_build_command name)
  2062. ExternalProject_Get_Property(${name} binary_dir)
  2063. get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET)
  2064. if(cmd_set)
  2065. get_property(cmd TARGET ${name} PROPERTY _EP_BUILD_COMMAND)
  2066. else()
  2067. _ep_get_build_command(${name} BUILD cmd)
  2068. endif()
  2069. get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD)
  2070. if(log)
  2071. set(log LOG 1)
  2072. else()
  2073. set(log "")
  2074. endif()
  2075. get_property(uses_terminal TARGET ${name} PROPERTY
  2076. _EP_USES_TERMINAL_BUILD)
  2077. if(uses_terminal)
  2078. set(uses_terminal USES_TERMINAL 1)
  2079. else()
  2080. set(uses_terminal "")
  2081. endif()
  2082. get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS)
  2083. if(build_always)
  2084. set(always 1)
  2085. else()
  2086. set(always 0)
  2087. endif()
  2088. get_property(build_byproducts TARGET ${name} PROPERTY _EP_BUILD_BYPRODUCTS)
  2089. ExternalProject_Add_Step(${name} build
  2090. COMMAND ${cmd}
  2091. BYPRODUCTS ${build_byproducts}
  2092. WORKING_DIRECTORY ${binary_dir}
  2093. DEPENDEES configure
  2094. ALWAYS ${always}
  2095. ${log}
  2096. ${uses_terminal}
  2097. )
  2098. endfunction()
  2099. function(_ep_add_install_command name)
  2100. ExternalProject_Get_Property(${name} binary_dir)
  2101. get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET)
  2102. if(cmd_set)
  2103. get_property(cmd TARGET ${name} PROPERTY _EP_INSTALL_COMMAND)
  2104. else()
  2105. _ep_get_build_command(${name} INSTALL cmd)
  2106. endif()
  2107. get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL)
  2108. if(log)
  2109. set(log LOG 1)
  2110. else()
  2111. set(log "")
  2112. endif()
  2113. get_property(uses_terminal TARGET ${name} PROPERTY
  2114. _EP_USES_TERMINAL_INSTALL)
  2115. if(uses_terminal)
  2116. set(uses_terminal USES_TERMINAL 1)
  2117. else()
  2118. set(uses_terminal "")
  2119. endif()
  2120. ExternalProject_Add_Step(${name} install
  2121. COMMAND ${cmd}
  2122. WORKING_DIRECTORY ${binary_dir}
  2123. DEPENDEES build
  2124. ${log}
  2125. ${uses_terminal}
  2126. )
  2127. endfunction()
  2128. function(_ep_add_test_command name)
  2129. ExternalProject_Get_Property(${name} binary_dir)
  2130. get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
  2131. get_property(after TARGET ${name} PROPERTY _EP_TEST_AFTER_INSTALL)
  2132. get_property(exclude TARGET ${name} PROPERTY _EP_TEST_EXCLUDE_FROM_MAIN)
  2133. get_property(cmd_set TARGET ${name} PROPERTY _EP_TEST_COMMAND SET)
  2134. # Only actually add the test step if one of the test related properties is
  2135. # explicitly set. (i.e. the test step is omitted unless requested...)
  2136. #
  2137. if(cmd_set OR before OR after OR exclude)
  2138. if(cmd_set)
  2139. get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND)
  2140. else()
  2141. _ep_get_build_command(${name} TEST cmd)
  2142. endif()
  2143. if(before)
  2144. set(dependees_args DEPENDEES build)
  2145. else()
  2146. set(dependees_args DEPENDEES install)
  2147. endif()
  2148. if(exclude)
  2149. set(dependers_args "")
  2150. set(exclude_args EXCLUDE_FROM_MAIN 1)
  2151. else()
  2152. if(before)
  2153. set(dependers_args DEPENDERS install)
  2154. else()
  2155. set(dependers_args "")
  2156. endif()
  2157. set(exclude_args "")
  2158. endif()
  2159. get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST)
  2160. if(log)
  2161. set(log LOG 1)
  2162. else()
  2163. set(log "")
  2164. endif()
  2165. get_property(uses_terminal TARGET ${name} PROPERTY
  2166. _EP_USES_TERMINAL_TEST)
  2167. if(uses_terminal)
  2168. set(uses_terminal USES_TERMINAL 1)
  2169. else()
  2170. set(uses_terminal "")
  2171. endif()
  2172. ExternalProject_Add_Step(${name} test
  2173. COMMAND ${cmd}
  2174. WORKING_DIRECTORY ${binary_dir}
  2175. ${dependees_args}
  2176. ${dependers_args}
  2177. ${exclude_args}
  2178. ${log}
  2179. ${uses_terminal}
  2180. )
  2181. endif()
  2182. endfunction()
  2183. function(ExternalProject_Add name)
  2184. _ep_get_configuration_subdir_suffix(cfgdir)
  2185. # Add a custom target for the external project.
  2186. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  2187. set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
  2188. # The "ALL" option to add_custom_target just tells it to not set the
  2189. # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
  2190. # argument was passed, we explicitly set it for the target.
  2191. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
  2192. set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
  2193. set_property(TARGET ${name} PROPERTY LABELS ${name})
  2194. set_property(TARGET ${name} PROPERTY FOLDER "ExternalProjectTargets/${name}")
  2195. _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
  2196. _ep_set_directories(${name})
  2197. _ep_get_step_stampfile(${name} "done" done_stamp_file)
  2198. _ep_get_step_stampfile(${name} "install" install_stamp_file)
  2199. # Set the EXCLUDE_FROM_ALL target property if required.
  2200. get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL)
  2201. if(exclude_from_all)
  2202. set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE)
  2203. endif()
  2204. # The 'complete' step depends on all other steps and creates a
  2205. # 'done' mark. A dependent external project's 'configure' step
  2206. # depends on the 'done' mark so that it rebuilds when this project
  2207. # rebuilds. It is important that 'done' is not the output of any
  2208. # custom command so that CMake does not propagate build rules to
  2209. # other external project targets, which may cause problems during
  2210. # parallel builds. However, the Ninja generator needs to see the entire
  2211. # dependency graph, and can cope with custom commands belonging to
  2212. # multiple targets, so we add the 'done' mark as an output for Ninja only.
  2213. set(complete_outputs ${complete_stamp_file})
  2214. if(${CMAKE_GENERATOR} MATCHES "Ninja")
  2215. set(complete_outputs ${complete_outputs} ${done_stamp_file})
  2216. endif()
  2217. add_custom_command(
  2218. OUTPUT ${complete_outputs}
  2219. COMMENT "Completed '${name}'"
  2220. COMMAND ${CMAKE_COMMAND} -E make_directory ${cmf_dir}${cfgdir}
  2221. COMMAND ${CMAKE_COMMAND} -E touch ${complete_stamp_file}
  2222. COMMAND ${CMAKE_COMMAND} -E touch ${done_stamp_file}
  2223. DEPENDS ${install_stamp_file}
  2224. VERBATIM
  2225. )
  2226. # Depend on other external projects (target-level).
  2227. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  2228. foreach(arg IN LISTS deps)
  2229. add_dependencies(${name} ${arg})
  2230. endforeach()
  2231. # Set up custom build steps based on the target properties.
  2232. # Each step depends on the previous one.
  2233. #
  2234. # The target depends on the output of the final step.
  2235. # (Already set up above in the DEPENDS of the add_custom_target command.)
  2236. #
  2237. _ep_add_mkdir_command(${name})
  2238. _ep_add_download_command(${name})
  2239. _ep_add_update_command(${name})
  2240. _ep_add_patch_command(${name})
  2241. _ep_add_configure_command(${name})
  2242. _ep_add_build_command(${name})
  2243. _ep_add_install_command(${name})
  2244. # Test is special in that it might depend on build, or it might depend
  2245. # on install.
  2246. #
  2247. _ep_add_test_command(${name})
  2248. endfunction()