ExternalProject.cmake 86 KB

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