ExternalProject.cmake 87 KB

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