ExternalProject.cmake 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. # - Create custom targets to build projects in external trees
  2. # The 'ExternalProject_Add' function creates a custom target to drive
  3. # download, update/patch, configure, build, install and test steps of an
  4. # external project:
  5. # ExternalProject_Add(<name> # Name for custom target
  6. # [DEPENDS projects...] # Targets on which the project depends
  7. # [PREFIX dir] # Root dir for entire project
  8. # [LIST_SEPARATOR sep] # Sep to be replaced by ; in cmd lines
  9. # [TMP_DIR dir] # Directory to store temporary files
  10. # [STAMP_DIR dir] # Directory to store step timestamps
  11. # #--Download step--------------
  12. # [DOWNLOAD_DIR dir] # Directory to store downloaded files
  13. # [DOWNLOAD_COMMAND cmd...] # Command to download source tree
  14. # [CVS_REPOSITORY cvsroot] # CVSROOT of CVS repository
  15. # [CVS_MODULE mod] # Module to checkout from CVS repo
  16. # [CVS_TAG tag] # Tag to checkout from CVS repo
  17. # [SVN_REPOSITORY url] # URL of Subversion repo
  18. # [SVN_REVISION rev] # Revision to checkout from Subversion repo
  19. # [SVN_USERNAME john ] # Username to use for Subversion checkout and update
  20. # [SVN_PASSWORD doe ] # Password to use for Subversion checkout and update
  21. # [URL /.../src.tgz] # Full path or URL of source
  22. # [TIMEOUT seconds] # Time allowed for file download operations
  23. # [GIT_REPOSITORY url] # URL of GIT repo
  24. # #--Update/Patch step----------
  25. # [UPDATE_COMMAND cmd...] # Source work-tree update command
  26. # [PATCH_COMMAND cmd...] # Command to patch downloaded source
  27. # #--Configure step-------------
  28. # [SOURCE_DIR dir] # Source dir to be used for build
  29. # [CONFIGURE_COMMAND cmd...] # Build tree configuration command
  30. # [CMAKE_COMMAND /.../cmake] # Specify alternative cmake executable
  31. # [CMAKE_GENERATOR gen] # Specify generator for native build
  32. # [CMAKE_ARGS args...] # Arguments to CMake command line
  33. # #--Build step-----------------
  34. # [BINARY_DIR dir] # Specify build dir location
  35. # [BUILD_COMMAND cmd...] # Command to drive the native build
  36. # [BUILD_IN_SOURCE 1] # Use source dir for build dir
  37. # #--Install step---------------
  38. # [INSTALL_DIR dir] # Installation prefix
  39. # [INSTALL_COMMAND cmd...] # Command to drive install after build
  40. # #--Test step---------------
  41. # [TEST_BEFORE_INSTALL 1] # Add test step executed before install step
  42. # [TEST_AFTER_INSTALL 1] # Add test step executed after install step
  43. # [TEST_COMMAND cmd...] # Command to drive test
  44. # )
  45. # The *_DIR options specify directories for the project, with default
  46. # directories computed as follows.
  47. # If the PREFIX option is given to ExternalProject_Add() or the EP_PREFIX
  48. # directory property is set, then an external project is built and installed
  49. # under the specified prefix:
  50. # TMP_DIR = <prefix>/tmp
  51. # STAMP_DIR = <prefix>/src/<name>-stamp
  52. # DOWNLOAD_DIR = <prefix>/src
  53. # SOURCE_DIR = <prefix>/src/<name>
  54. # BINARY_DIR = <prefix>/src/<name>-build
  55. # INSTALL_DIR = <prefix>
  56. # Otherwise, if the EP_BASE directory property is set then components
  57. # of an external project are stored under the specified base:
  58. # TMP_DIR = <base>/tmp/<name>
  59. # STAMP_DIR = <base>/Stamp/<name>
  60. # DOWNLOAD_DIR = <base>/Download/<name>
  61. # SOURCE_DIR = <base>/Source/<name>
  62. # BINARY_DIR = <base>/Build/<name>
  63. # INSTALL_DIR = <base>/Install/<name>
  64. # If no PREFIX, EP_PREFIX, or EP_BASE is specified then the default
  65. # is to set PREFIX to "<name>-prefix".
  66. # Relative paths are interpreted with respect to the build directory
  67. # corresponding to the source directory in which ExternalProject_Add is
  68. # invoked.
  69. #
  70. # If SOURCE_DIR is explicitly set to an existing directory the project
  71. # will be built from it.
  72. # Otherwise a download step must be specified using one of the
  73. # DOWNLOAD_COMMAND, CVS_*, SVN_*, or URL options.
  74. # The URL option may refer locally to a directory or source tarball,
  75. # or refer to a remote tarball (e.g. http://.../src.tgz).
  76. #
  77. # The 'ExternalProject_Add_Step' function adds a custom step to an external
  78. # project:
  79. # ExternalProject_Add_Step(<name> <step> # Names of project and custom step
  80. # [COMMAND cmd...] # Command line invoked by this step
  81. # [COMMENT "text..."] # Text printed when step executes
  82. # [DEPENDEES steps...] # Steps on which this step depends
  83. # [DEPENDERS steps...] # Steps that depend on this step
  84. # [DEPENDS files...] # Files on which this step depends
  85. # [ALWAYS 1] # No stamp file, step always runs
  86. # [WORKING_DIRECTORY dir] # Working directory for command
  87. # )
  88. # The command line, comment, and working directory of every standard
  89. # and custom step is processed to replace tokens
  90. # <SOURCE_DIR>,
  91. # <BINARY_DIR>,
  92. # <INSTALL_DIR>,
  93. # and <TMP_DIR>
  94. # with corresponding property values.
  95. #
  96. # The 'ExternalProject_Get_Property' function retrieves external project
  97. # target properties:
  98. # ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]])
  99. # It stores property values in variables of the same name.
  100. # Property names correspond to the keyword argument names of
  101. # 'ExternalProject_Add'.
  102. #=============================================================================
  103. # Copyright 2008-2009 Kitware, Inc.
  104. #
  105. # Distributed under the OSI-approved BSD License (the "License");
  106. # see accompanying file Copyright.txt for details.
  107. #
  108. # This software is distributed WITHOUT ANY WARRANTY; without even the
  109. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  110. # See the License for more information.
  111. #=============================================================================
  112. # (To distributed this file outside of CMake, substitute the full
  113. # License text for the above reference.)
  114. # Pre-compute a regex to match documented keywords for each command.
  115. file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 103
  116. REGEX "^# ( \\[[A-Z_]+ [^]]*\\] +#.*$|[A-Za-z_]+\\()")
  117. foreach(line IN LISTS lines)
  118. if("${line}" MATCHES "^# [A-Za-z_]+\\(")
  119. if(_ep_func)
  120. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  121. endif()
  122. string(REGEX REPLACE "^# ([A-Za-z_]+)\\(.*" "\\1" _ep_func "${line}")
  123. #message("function [${_ep_func}]")
  124. set(_ep_keywords_${_ep_func} "^(")
  125. set(_ep_keyword_sep)
  126. else()
  127. string(REGEX REPLACE "^# \\[([A-Z_]+) .*" "\\1" _ep_key "${line}")
  128. #message(" keyword [${_ep_key}]")
  129. set(_ep_keywords_${_ep_func}
  130. "${_ep_keywords_${_ep_func}}${_ep_keyword_sep}${_ep_key}")
  131. set(_ep_keyword_sep "|")
  132. endif()
  133. endforeach()
  134. if(_ep_func)
  135. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  136. endif()
  137. function(_ep_parse_arguments f name ns args)
  138. # Transfer the arguments to this function into target properties for the
  139. # new custom target we just added so that we can set up all the build steps
  140. # correctly based on target properties.
  141. #
  142. # We loop through ARGN and consider the namespace starting with an
  143. # upper-case letter followed by at least two more upper-case letters
  144. # or underscores to be keywords.
  145. set(key)
  146. foreach(arg IN LISTS args)
  147. set(is_value 1)
  148. if(arg MATCHES "^[A-Z][A-Z_][A-Z_]+$" AND
  149. NOT ((arg STREQUAL "${key}") AND (key STREQUAL "COMMAND")) AND
  150. NOT arg MATCHES "^(TRUE|FALSE)$")
  151. if(_ep_keywords_${f} AND arg MATCHES "${_ep_keywords_${f}}")
  152. set(is_value 0)
  153. else()
  154. if(NOT (key STREQUAL "COMMAND")
  155. AND NOT (key STREQUAL "CVS_MODULE")
  156. AND NOT (key STREQUAL "DEPENDS")
  157. )
  158. message(AUTHOR_WARNING "unknown ${f} keyword: ${arg}")
  159. endif()
  160. endif()
  161. endif()
  162. if(is_value)
  163. if(key)
  164. # Value
  165. if(NOT arg STREQUAL "")
  166. set_property(TARGET ${name} APPEND PROPERTY ${ns}${key} "${arg}")
  167. else()
  168. get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
  169. if(have_key)
  170. get_property(value TARGET ${name} PROPERTY ${ns}${key})
  171. set_property(TARGET ${name} PROPERTY ${ns}${key} "${value};${arg}")
  172. else()
  173. set_property(TARGET ${name} PROPERTY ${ns}${key} "${arg}")
  174. endif()
  175. endif()
  176. else()
  177. # Missing Keyword
  178. message(AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}")
  179. endif()
  180. else()
  181. set(key "${arg}")
  182. endif()
  183. endforeach()
  184. endfunction(_ep_parse_arguments)
  185. define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED
  186. BRIEF_DOCS "Base directory for External Project storage."
  187. FULL_DOCS
  188. "See documentation of the ExternalProject_Add() function in the "
  189. "ExternalProject module."
  190. )
  191. define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED
  192. BRIEF_DOCS "Top prefix for External Project storage."
  193. FULL_DOCS
  194. "See documentation of the ExternalProject_Add() function in the "
  195. "ExternalProject module."
  196. )
  197. function(_ep_write_downloadfile_script script_filename remote local timeout)
  198. if(timeout)
  199. set(timeout_args TIMEOUT ${timeout})
  200. set(timeout_msg "${timeout} seconds")
  201. else()
  202. set(timeout_args "# no TIMEOUT")
  203. set(timeout_msg "none")
  204. endif()
  205. file(WRITE ${script_filename}
  206. "message(STATUS \"downloading...
  207. src='${remote}'
  208. dst='${local}'
  209. timeout='${timeout_msg}'\")
  210. file(DOWNLOAD
  211. \"${remote}\"
  212. \"${local}\"
  213. ${timeout_args}
  214. STATUS status
  215. LOG log)
  216. list(GET status 0 status_code)
  217. list(GET status 1 status_string)
  218. if(NOT status_code EQUAL 0)
  219. message(FATAL_ERROR \"error: downloading '${remote}' failed
  220. status_code: \${status_code}
  221. status_string: \${status_string}
  222. log: \${log}
  223. \")
  224. endif()
  225. message(STATUS \"downloading... done\")
  226. "
  227. )
  228. endfunction(_ep_write_downloadfile_script)
  229. function(_ep_write_extractfile_script script_filename filename tmp directory)
  230. set(args "")
  231. if(filename MATCHES ".tar$")
  232. set(args xf)
  233. endif()
  234. if(filename MATCHES ".tgz$")
  235. set(args xfz)
  236. endif()
  237. if(filename MATCHES ".tar.gz$")
  238. set(args xfz)
  239. endif()
  240. if(args STREQUAL "")
  241. message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .tar, .tgz and .tar.gz")
  242. return()
  243. endif()
  244. file(WRITE ${script_filename}
  245. "# Make file names absolute:
  246. #
  247. get_filename_component(filename \"${filename}\" ABSOLUTE)
  248. get_filename_component(tmp \"${tmp}\" ABSOLUTE)
  249. get_filename_component(directory \"${directory}\" ABSOLUTE)
  250. message(STATUS \"extracting...
  251. src='\${filename}'
  252. dst='\${directory}'\")
  253. # Prepare a space for extracting:
  254. #
  255. set(i 1)
  256. while(EXISTS \"\${tmp}/extract\${i}\")
  257. math(EXPR i \"\${i} + 1\")
  258. endwhile()
  259. set(ut_dir \"\${tmp}/extract\${i}\")
  260. file(MAKE_DIRECTORY \"\${ut_dir}\")
  261. # Extract it:
  262. #
  263. message(STATUS \"extracting... [tar ${args}]\")
  264. execute_process(COMMAND \${CMAKE_COMMAND} -E tar ${args} \${filename}
  265. WORKING_DIRECTORY \${ut_dir}
  266. RESULT_VARIABLE rv)
  267. if(NOT rv EQUAL 0)
  268. message(STATUS \"extracting... [error clean up]\")
  269. file(REMOVE_RECURSE \"\${ut_dir}\")
  270. message(FATAL_ERROR \"error: extract of '\${filename}' failed\")
  271. endif()
  272. # Analyze what came out of the tar file:
  273. #
  274. message(STATUS \"extracting... [analysis]\")
  275. file(GLOB contents \"\${ut_dir}/*\")
  276. list(LENGTH contents n)
  277. if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
  278. set(contents \"\${ut_dir}\")
  279. endif()
  280. # Copy \"the one\" directory to the final directory:
  281. #
  282. message(STATUS \"extracting... [copy]\")
  283. file(COPY \"\${contents}/\" DESTINATION \${directory})
  284. # Clean up:
  285. #
  286. message(STATUS \"extracting... [clean up]\")
  287. file(REMOVE_RECURSE \"\${ut_dir}\")
  288. message(STATUS \"extracting... done\")
  289. "
  290. )
  291. endfunction(_ep_write_extractfile_script)
  292. function(_ep_set_directories name)
  293. get_property(prefix TARGET ${name} PROPERTY _EP_PREFIX)
  294. if(NOT prefix)
  295. get_property(prefix DIRECTORY PROPERTY EP_PREFIX)
  296. if(NOT prefix)
  297. get_property(base DIRECTORY PROPERTY EP_BASE)
  298. if(NOT base)
  299. set(prefix "${name}-prefix")
  300. endif()
  301. endif()
  302. endif()
  303. if(prefix)
  304. set(tmp_default "${prefix}/tmp")
  305. set(download_default "${prefix}/src")
  306. set(source_default "${prefix}/src/${name}")
  307. set(binary_default "${prefix}/src/${name}-build")
  308. set(stamp_default "${prefix}/src/${name}-stamp")
  309. set(install_default "${prefix}")
  310. else() # assert(base)
  311. set(tmp_default "${base}/tmp/${name}")
  312. set(download_default "${base}/Download/${name}")
  313. set(source_default "${base}/Source/${name}")
  314. set(binary_default "${base}/Build/${name}")
  315. set(stamp_default "${base}/Stamp/${name}")
  316. set(install_default "${base}/Install/${name}")
  317. endif()
  318. get_property(build_in_source TARGET ${name} PROPERTY _EP_BUILD_IN_SOURCE)
  319. if(build_in_source)
  320. get_property(have_binary_dir TARGET ${name} PROPERTY _EP_BINARY_DIR SET)
  321. if(have_binary_dir)
  322. message(FATAL_ERROR
  323. "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!")
  324. endif()
  325. endif()
  326. set(top "${CMAKE_CURRENT_BINARY_DIR}")
  327. set(places stamp download source binary install tmp)
  328. foreach(var ${places})
  329. string(TOUPPER "${var}" VAR)
  330. get_property(${var}_dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  331. if(NOT ${var}_dir)
  332. set(${var}_dir "${${var}_default}")
  333. endif()
  334. if(NOT IS_ABSOLUTE "${${var}_dir}")
  335. get_filename_component(${var}_dir "${top}/${${var}_dir}" ABSOLUTE)
  336. endif()
  337. set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
  338. endforeach()
  339. if(build_in_source)
  340. get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
  341. set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
  342. endif()
  343. # Make the directories at CMake configure time *and* add a custom command
  344. # to make them at build time. They need to exist at makefile generation
  345. # time for Borland make and wmake so that CMake may generate makefiles
  346. # with "cd C:\short\paths\with\no\spaces" commands in them.
  347. #
  348. # Additionally, the add_custom_command is still used in case somebody
  349. # removes one of the necessary directories and tries to rebuild without
  350. # re-running cmake.
  351. foreach(var ${places})
  352. string(TOUPPER "${var}" VAR)
  353. get_property(dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  354. file(MAKE_DIRECTORY "${dir}")
  355. if(NOT EXISTS "${dir}")
  356. message(FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)")
  357. endif()
  358. endforeach()
  359. endfunction(_ep_set_directories)
  360. function(ExternalProject_Get_Property name)
  361. foreach(var ${ARGN})
  362. string(TOUPPER "${var}" VAR)
  363. get_property(${var} TARGET ${name} PROPERTY _EP_${VAR})
  364. if(NOT ${var})
  365. message(FATAL_ERROR "External project \"${name}\" has no ${var}")
  366. endif()
  367. set(${var} "${${var}}" PARENT_SCOPE)
  368. endforeach()
  369. endfunction(ExternalProject_Get_Property)
  370. function(_ep_get_configure_command_id name cfg_cmd_id_var)
  371. get_target_property(cmd ${name} _EP_CONFIGURE_COMMAND)
  372. if(cmd STREQUAL "")
  373. # Explicit empty string means no configure step for this project
  374. set(${cfg_cmd_id_var} "none" PARENT_SCOPE)
  375. else()
  376. if(NOT cmd)
  377. # Default is "use cmake":
  378. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  379. else()
  380. # Otherwise we have to analyze the value:
  381. if(cmd MATCHES "^[^;]*/configure")
  382. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  383. elseif(cmd MATCHES "^[^;]*/cmake" AND NOT cmd MATCHES ";-[PE];")
  384. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  385. elseif(cmd MATCHES "config")
  386. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  387. else()
  388. set(${cfg_cmd_id_var} "unknown:${cmd}" PARENT_SCOPE)
  389. endif()
  390. endif()
  391. endif()
  392. endfunction(_ep_get_configure_command_id)
  393. function(_ep_get_build_command name step cmd_var)
  394. set(cmd "${${cmd_var}}")
  395. if(NOT cmd)
  396. set(args)
  397. _ep_get_configure_command_id(${name} cfg_cmd_id)
  398. if(cfg_cmd_id STREQUAL "cmake")
  399. # CMake project. Select build command based on generator.
  400. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  401. if("${cmake_generator}" MATCHES "Make" AND
  402. "${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}")
  403. # The project uses the same Makefile generator. Use recursive make.
  404. set(cmd "$(MAKE)")
  405. if(step STREQUAL "INSTALL")
  406. set(args install)
  407. endif()
  408. if(step STREQUAL "TEST")
  409. set(args test)
  410. endif()
  411. else()
  412. # Drive the project with "cmake --build".
  413. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  414. if(cmake_command)
  415. set(cmd "${cmake_command}")
  416. else()
  417. set(cmd "${CMAKE_COMMAND}")
  418. endif()
  419. set(args --build ${binary_dir} --config ${CMAKE_CFG_INTDIR})
  420. if(step STREQUAL "INSTALL")
  421. list(APPEND args --target install)
  422. endif()
  423. # But for "TEST" drive the project with corresponding "ctest".
  424. if(step STREQUAL "TEST")
  425. string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
  426. set(args "")
  427. endif()
  428. endif()
  429. else() # if(cfg_cmd_id STREQUAL "configure")
  430. # Non-CMake project. Guess "make" and "make install" and "make test".
  431. set(cmd "make")
  432. if(step STREQUAL "INSTALL")
  433. set(args install)
  434. endif()
  435. if(step STREQUAL "TEST")
  436. set(args test)
  437. endif()
  438. endif()
  439. # Use user-specified arguments instead of default arguments, if any.
  440. get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET)
  441. if(have_args)
  442. get_target_property(args ${name} _EP_${step}_ARGS)
  443. endif()
  444. list(APPEND cmd ${args})
  445. endif()
  446. set(${cmd_var} "${cmd}" PARENT_SCOPE)
  447. endfunction(_ep_get_build_command)
  448. # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced
  449. # makefiles with "/./" in paths for custom command dependencies. Which
  450. # resulted in problems with parallel make -j invocations.
  451. #
  452. # This function was added so that the suffix (search below for ${cfgdir}) is
  453. # only set to "/${CMAKE_CFG_INTDIR}" when ${CMAKE_CFG_INTDIR} is not going to
  454. # be "." (multi-configuration build systems like Visual Studio and Xcode...)
  455. #
  456. function(_ep_get_configuration_subdir_suffix suffix_var)
  457. set(suffix "")
  458. if(CMAKE_CONFIGURATION_TYPES)
  459. set(suffix "/${CMAKE_CFG_INTDIR}")
  460. endif()
  461. set(${suffix_var} "${suffix}" PARENT_SCOPE)
  462. endfunction(_ep_get_configuration_subdir_suffix)
  463. function(ExternalProject_Add_Step name step)
  464. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  465. ExternalProject_Get_Property(${name} stamp_dir)
  466. _ep_get_configuration_subdir_suffix(cfgdir)
  467. add_custom_command(APPEND
  468. OUTPUT ${cmf_dir}${cfgdir}/${name}-complete
  469. DEPENDS ${stamp_dir}${cfgdir}/${name}-${step}
  470. )
  471. _ep_parse_arguments(ExternalProject_Add_Step
  472. ${name} _EP_${step}_ "${ARGN}")
  473. # Steps depending on this step.
  474. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS)
  475. foreach(depender IN LISTS dependers)
  476. add_custom_command(APPEND
  477. OUTPUT ${stamp_dir}${cfgdir}/${name}-${depender}
  478. DEPENDS ${stamp_dir}${cfgdir}/${name}-${step}
  479. )
  480. endforeach()
  481. # Dependencies on files.
  482. get_property(depends TARGET ${name} PROPERTY _EP_${step}_DEPENDS)
  483. # Dependencies on steps.
  484. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES)
  485. foreach(dependee IN LISTS dependees)
  486. list(APPEND depends ${stamp_dir}${cfgdir}/${name}-${dependee})
  487. endforeach()
  488. # The command to run.
  489. get_property(command TARGET ${name} PROPERTY _EP_${step}_COMMAND)
  490. if(command)
  491. set(comment "Performing ${step} step for '${name}'")
  492. else()
  493. set(comment "No ${step} step for '${name}'")
  494. endif()
  495. get_property(work_dir TARGET ${name} PROPERTY _EP_${step}_WORKING_DIRECTORY)
  496. # Replace list separators.
  497. get_property(sep TARGET ${name} PROPERTY _EP_LIST_SEPARATOR)
  498. if(sep AND command)
  499. string(REPLACE "${sep}" "\\;" command "${command}")
  500. endif()
  501. # Replace location tags.
  502. foreach(var comment command work_dir)
  503. if(${var})
  504. foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR)
  505. get_property(val TARGET ${name} PROPERTY _EP_${dir})
  506. string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
  507. endforeach()
  508. endif()
  509. endforeach()
  510. # Custom comment?
  511. get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET)
  512. if(comment_set)
  513. get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT)
  514. endif()
  515. # Run every time?
  516. get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS)
  517. if(always)
  518. set_property(SOURCE ${stamp_dir}${cfgdir}/${name}-${step} PROPERTY SYMBOLIC 1)
  519. set(touch)
  520. else()
  521. set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}${cfgdir}/${name}-${step})
  522. endif()
  523. add_custom_command(
  524. OUTPUT ${stamp_dir}${cfgdir}/${name}-${step}
  525. COMMENT ${comment}
  526. COMMAND ${command}
  527. COMMAND ${touch}
  528. DEPENDS ${depends}
  529. WORKING_DIRECTORY ${work_dir}
  530. VERBATIM
  531. )
  532. endfunction(ExternalProject_Add_Step)
  533. function(_ep_add_mkdir_command name)
  534. ExternalProject_Get_Property(${name}
  535. source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
  536. _ep_get_configuration_subdir_suffix(cfgdir)
  537. ExternalProject_Add_Step(${name} mkdir
  538. COMMENT "Creating directories for '${name}'"
  539. COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
  540. COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir}
  541. COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}
  542. COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
  543. COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
  544. COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
  545. )
  546. endfunction(_ep_add_mkdir_command)
  547. function(_ep_add_download_command name)
  548. ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir)
  549. get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET)
  550. get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND)
  551. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  552. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  553. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  554. get_property(url TARGET ${name} PROPERTY _EP_URL)
  555. # TODO: Perhaps file:// should be copied to download dir before extraction.
  556. string(REGEX REPLACE "^file://" "" url "${url}")
  557. set(depends)
  558. set(comment)
  559. set(work_dir)
  560. if(cmd_set)
  561. set(work_dir ${download_dir})
  562. elseif(cvs_repository)
  563. find_package(CVS)
  564. if(NOT CVS_EXECUTABLE)
  565. message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
  566. endif()
  567. get_target_property(cvs_module ${name} _EP_CVS_MODULE)
  568. if(NOT cvs_module)
  569. message(FATAL_ERROR "error: no CVS_MODULE")
  570. endif()
  571. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  572. set(repository ${cvs_repository})
  573. set(module ${cvs_module})
  574. set(tag ${cvs_tag})
  575. configure_file(
  576. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  577. "${stamp_dir}/${name}-cvsinfo.txt"
  578. @ONLY
  579. )
  580. get_filename_component(src_name "${source_dir}" NAME)
  581. get_filename_component(work_dir "${source_dir}" PATH)
  582. set(comment "Performing download step (CVS checkout) for '${name}'")
  583. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module})
  584. list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt)
  585. elseif(svn_repository)
  586. find_package(Subversion)
  587. if(NOT Subversion_SVN_EXECUTABLE)
  588. message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
  589. endif()
  590. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  591. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  592. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  593. set(repository ${svn_repository})
  594. set(module)
  595. set(tag ${svn_revision})
  596. configure_file(
  597. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  598. "${stamp_dir}/${name}-svninfo.txt"
  599. @ONLY
  600. )
  601. get_filename_component(src_name "${source_dir}" NAME)
  602. get_filename_component(work_dir "${source_dir}" PATH)
  603. set(comment "Performing download step (SVN checkout) for '${name}'")
  604. set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} --username=${svn_username} --password=${svn_password} ${src_name})
  605. list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
  606. elseif(git_repository)
  607. #find_package(Git)
  608. find_program(Git_EXECUTABLE git DOC "git command line client")
  609. mark_as_advanced(Git_EXECUTABLE)
  610. if(NOT Git_EXECUTABLE)
  611. message(FATAL_ERROR "error: could not git svn for clone of ${name}")
  612. endif()
  613. # TODO [GIT_REVISION revision] # Revision to checkout from GIT repo
  614. #get_property(git_revision TARGET ${name} PROPERTY _EP_GIT_REVISION)
  615. set(repository ${git_repository})
  616. set(module)
  617. set(tag ${git_revision})
  618. configure_file(
  619. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  620. "${stamp_dir}/${name}-gitinfo.txt"
  621. @ONLY
  622. )
  623. get_filename_component(src_name "${source_dir}" NAME)
  624. get_filename_component(work_dir "${source_dir}/../" REALPATH)
  625. # Since Git doesn't allow to clone if the repository exists,
  626. # let's create a cmake script that will be invoked as a download command.
  627. # That script will delete the source directory and call the appropriate git clone command
  628. file(WRITE ${tmp_dir}/${name}-gitclone.cmake "
  629. execute_process(
  630. COMMAND ${CMAKE_COMMAND} -E remove_directory ${source_dir}
  631. RESULT_VARIABLE error_code
  632. )
  633. execute_process(
  634. COMMAND ${Git_EXECUTABLE} clone ${git_repository} ${src_name}
  635. WORKING_DIRECTORY ${work_dir}
  636. RESULT_VARIABLE error_code
  637. )
  638. if(error_code)
  639. message(FATAL_ERROR \"Failed to clone repository: ${git_repository}\")
  640. endif()
  641. ")
  642. set(comment "Performing download step (GIT clone) for '${name}'")
  643. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
  644. list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
  645. elseif(url)
  646. get_filename_component(work_dir "${source_dir}" PATH)
  647. set(repository "external project URL")
  648. set(module "${url}")
  649. set(tag "")
  650. configure_file(
  651. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  652. "${stamp_dir}/${name}-urlinfo.txt"
  653. @ONLY
  654. )
  655. list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt)
  656. if(IS_DIRECTORY "${url}")
  657. get_filename_component(abs_dir "${url}" ABSOLUTE)
  658. set(comment "Performing download step (DIR copy) for '${name}'")
  659. set(cmd ${CMAKE_COMMAND} -E remove_directory ${source_dir}
  660. COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir})
  661. else()
  662. if("${url}" MATCHES "^[a-z]+://")
  663. # TODO: Should download and extraction be different steps?
  664. string(REGEX MATCH "[^/]*$" fname "${url}")
  665. if(NOT "${fname}" MATCHES "\\.(tar|tgz|tar\\.gz)$")
  666. message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
  667. endif()
  668. set(file ${download_dir}/${fname})
  669. get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
  670. _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}")
  671. set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake
  672. COMMAND)
  673. set(comment "Performing download step (download and extract) for '${name}'")
  674. else()
  675. set(file "${url}")
  676. set(comment "Performing download step (extract) for '${name}'")
  677. endif()
  678. # TODO: Support other archive formats.
  679. _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${file}" "${tmp_dir}" "${source_dir}")
  680. list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
  681. endif()
  682. else()
  683. message(SEND_ERROR "error: no download info for '${name}' -- please specify existing SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY or DOWNLOAD_COMMAND")
  684. endif()
  685. ExternalProject_Add_Step(${name} download
  686. COMMENT ${comment}
  687. COMMAND ${cmd}
  688. WORKING_DIRECTORY ${work_dir}
  689. DEPENDS ${depends}
  690. DEPENDEES mkdir
  691. )
  692. endfunction(_ep_add_download_command)
  693. function(_ep_add_update_command name)
  694. ExternalProject_Get_Property(${name} source_dir tmp_dir)
  695. get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET)
  696. get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND)
  697. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  698. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  699. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  700. # Patch
  701. get_property(patch_cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
  702. get_property(patch_cmd TARGET ${name} PROPERTY _EP_PATCH_COMMAND)
  703. set(patch_work_dir)
  704. if(patch_cmd_set)
  705. set(patch_work_dir ${source_dir})
  706. endif()
  707. set(work_dir)
  708. set(comment)
  709. set(always)
  710. if(cmd_set)
  711. set(work_dir ${source_dir})
  712. elseif(cvs_repository)
  713. if(NOT CVS_EXECUTABLE)
  714. message(FATAL_ERROR "error: could not find cvs for update of ${name}")
  715. endif()
  716. set(work_dir ${source_dir})
  717. set(comment "Performing update step (CVS update) for '${name}'")
  718. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  719. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q up -dP ${cvs_tag})
  720. set(always 1)
  721. elseif(svn_repository)
  722. if(NOT Subversion_SVN_EXECUTABLE)
  723. message(FATAL_ERROR "error: could not find svn for update of ${name}")
  724. endif()
  725. set(work_dir ${source_dir})
  726. set(comment "Performing update step (SVN update) for '${name}'")
  727. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  728. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  729. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  730. set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} --username=${svn_username} --password=${svn_password})
  731. set(always 1)
  732. elseif(git_repository)
  733. if(NOT Git_EXECUTABLE)
  734. message(FATAL_ERROR "error: could not find git for pull of ${name}")
  735. endif()
  736. set(work_dir ${source_dir})
  737. # The following script will allow to reset, pull and re-apply patches
  738. file(WRITE ${tmp_dir}/${name}-gitupdate.cmake "
  739. execute_process(
  740. COMMAND ${Git_EXECUTABLE} reset --hard HEAD
  741. WORKING_DIRECTORY ${work_dir}
  742. RESULT_VARIABLE error_code
  743. )
  744. execute_process(
  745. COMMAND ${Git_EXECUTABLE} pull
  746. WORKING_DIRECTORY ${work_dir}
  747. RESULT_VARIABLE error_code
  748. )
  749. if(error_code)
  750. message(FATAL_ERROR \"Failed to pull - repository: ${git_repository}\")
  751. endif()
  752. if(${patch_cmd_set})
  753. execute_process(
  754. COMMAND ${patch_cmd}
  755. WORKING_DIRECTORY ${patch_work_dir}
  756. RESULT_VARIABLE error_code
  757. )
  758. if(error_code)
  759. message(FATAL_ERROR \"Failed to apply patch for ${name}\")
  760. endif()
  761. endif()
  762. ")
  763. set(comment "Performing update step (GIT pull) for '${name}'")
  764. #get_property(git_revision TARGET ${name} PROPERTY _EP_GIT_REVISION)
  765. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
  766. set(always 1)
  767. endif()
  768. ExternalProject_Add_Step(${name} update
  769. COMMENT ${comment}
  770. COMMAND ${cmd}
  771. ALWAYS ${always}
  772. WORKING_DIRECTORY ${work_dir}
  773. DEPENDEES download
  774. )
  775. endfunction(_ep_add_update_command)
  776. function(_ep_add_patch_command name)
  777. ExternalProject_Get_Property(${name} source_dir)
  778. get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
  779. get_property(cmd TARGET ${name} PROPERTY _EP_PATCH_COMMAND)
  780. set(work_dir)
  781. if(cmd_set)
  782. set(work_dir ${source_dir})
  783. endif()
  784. ExternalProject_Add_Step(${name} patch
  785. COMMAND ${cmd}
  786. WORKING_DIRECTORY ${work_dir}
  787. DEPENDEES download
  788. )
  789. endfunction(_ep_add_patch_command)
  790. # TODO: Make sure external projects use the proper compiler
  791. function(_ep_add_configure_command name)
  792. ExternalProject_Get_Property(${name} source_dir binary_dir)
  793. _ep_get_configuration_subdir_suffix(cfgdir)
  794. # Depend on other external projects (file-level).
  795. set(file_deps)
  796. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  797. foreach(dep IN LISTS deps)
  798. get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
  799. list(APPEND file_deps ${dep_stamp_dir}${cfgdir}/${dep}-done)
  800. endforeach()
  801. get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET)
  802. if(cmd_set)
  803. get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND)
  804. else()
  805. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  806. if(cmake_command)
  807. set(cmd "${cmake_command}")
  808. else()
  809. set(cmd "${CMAKE_COMMAND}")
  810. endif()
  811. get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS)
  812. list(APPEND cmd ${cmake_args})
  813. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  814. if(cmake_generator)
  815. list(APPEND cmd "-G${cmake_generator}" "${source_dir}")
  816. else()
  817. list(APPEND cmd "-G${CMAKE_GENERATOR}" "${source_dir}")
  818. endif()
  819. endif()
  820. ExternalProject_Add_Step(${name} configure
  821. COMMAND ${cmd}
  822. WORKING_DIRECTORY ${binary_dir}
  823. DEPENDEES update patch
  824. DEPENDS ${file_deps}
  825. )
  826. endfunction(_ep_add_configure_command)
  827. function(_ep_add_build_command name)
  828. ExternalProject_Get_Property(${name} binary_dir)
  829. get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET)
  830. if(cmd_set)
  831. get_property(cmd TARGET ${name} PROPERTY _EP_BUILD_COMMAND)
  832. else()
  833. _ep_get_build_command(${name} BUILD cmd)
  834. endif()
  835. ExternalProject_Add_Step(${name} build
  836. COMMAND ${cmd}
  837. WORKING_DIRECTORY ${binary_dir}
  838. DEPENDEES configure
  839. )
  840. endfunction(_ep_add_build_command)
  841. function(_ep_add_install_command name)
  842. ExternalProject_Get_Property(${name} binary_dir)
  843. get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET)
  844. if(cmd_set)
  845. get_property(cmd TARGET ${name} PROPERTY _EP_INSTALL_COMMAND)
  846. else()
  847. _ep_get_build_command(${name} INSTALL cmd)
  848. endif()
  849. ExternalProject_Add_Step(${name} install
  850. COMMAND ${cmd}
  851. WORKING_DIRECTORY ${binary_dir}
  852. DEPENDEES build
  853. )
  854. endfunction(_ep_add_install_command)
  855. function(_ep_add_test_command name)
  856. ExternalProject_Get_Property(${name} binary_dir)
  857. get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
  858. get_property(after TARGET ${name} PROPERTY _EP_TEST_AFTER_INSTALL)
  859. get_property(cmd_set TARGET ${name} PROPERTY _EP_TEST_COMMAND SET)
  860. # Only actually add the test step if one of the test related properties is
  861. # explicitly set. (i.e. the test step is omitted unless requested...)
  862. #
  863. if(cmd_set OR before OR after)
  864. if(cmd_set)
  865. get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND)
  866. else()
  867. _ep_get_build_command(${name} TEST cmd)
  868. endif()
  869. if(before)
  870. set(dep_args DEPENDEES build DEPENDERS install)
  871. else()
  872. set(dep_args DEPENDEES install)
  873. endif()
  874. ExternalProject_Add_Step(${name} test
  875. COMMAND ${cmd}
  876. WORKING_DIRECTORY ${binary_dir}
  877. ${dep_args}
  878. )
  879. endif()
  880. endfunction(_ep_add_test_command)
  881. function(ExternalProject_Add name)
  882. _ep_get_configuration_subdir_suffix(cfgdir)
  883. # Add a custom target for the external project.
  884. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  885. add_custom_target(${name} ALL DEPENDS ${cmf_dir}${cfgdir}/${name}-complete)
  886. set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
  887. _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
  888. _ep_set_directories(${name})
  889. ExternalProject_Get_Property(${name} stamp_dir)
  890. # The 'complete' step depends on all other steps and creates a
  891. # 'done' mark. A dependent external project's 'configure' step
  892. # depends on the 'done' mark so that it rebuilds when this project
  893. # rebuilds. It is important that 'done' is not the output of any
  894. # custom command so that CMake does not propagate build rules to
  895. # other external project targets.
  896. add_custom_command(
  897. OUTPUT ${cmf_dir}${cfgdir}/${name}-complete
  898. COMMENT "Completed '${name}'"
  899. COMMAND ${CMAKE_COMMAND} -E make_directory ${cmf_dir}${cfgdir}
  900. COMMAND ${CMAKE_COMMAND} -E touch ${cmf_dir}${cfgdir}/${name}-complete
  901. COMMAND ${CMAKE_COMMAND} -E touch ${stamp_dir}${cfgdir}/${name}-done
  902. DEPENDS ${stamp_dir}${cfgdir}/${name}-install
  903. VERBATIM
  904. )
  905. # Depend on other external projects (target-level).
  906. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  907. foreach(arg IN LISTS deps)
  908. add_dependencies(${name} ${arg})
  909. endforeach()
  910. # Set up custom build steps based on the target properties.
  911. # Each step depends on the previous one.
  912. #
  913. # The target depends on the output of the final step.
  914. # (Already set up above in the DEPENDS of the add_custom_target command.)
  915. #
  916. _ep_add_mkdir_command(${name})
  917. _ep_add_download_command(${name})
  918. _ep_add_update_command(${name})
  919. _ep_add_patch_command(${name})
  920. _ep_add_configure_command(${name})
  921. _ep_add_build_command(${name})
  922. _ep_add_install_command(${name})
  923. # Test is special in that it might depend on build, or it might depend
  924. # on install.
  925. #
  926. _ep_add_test_command(${name})
  927. endfunction(ExternalProject_Add)