ExternalProject.cmake 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  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 for Subversion checkout and update
  20. # [SVN_PASSWORD doe ] # Password for Subversion checkout and update
  21. # [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate
  22. # [GIT_REPOSITORY url] # URL of git repo
  23. # [GIT_TAG tag] # Git branch name, commit id or tag
  24. # [URL /.../src.tgz] # Full path or URL of source
  25. # [URL_MD5 md5] # MD5 checksum of file at URL
  26. # [TIMEOUT seconds] # Time allowed for file download operations
  27. # #--Update/Patch step----------
  28. # [UPDATE_COMMAND cmd...] # Source work-tree update command
  29. # [PATCH_COMMAND cmd...] # Command to patch downloaded source
  30. # #--Configure step-------------
  31. # [SOURCE_DIR dir] # Source dir to be used for build
  32. # [CONFIGURE_COMMAND cmd...] # Build tree configuration command
  33. # [CMAKE_COMMAND /.../cmake] # Specify alternative cmake executable
  34. # [CMAKE_GENERATOR gen] # Specify generator for native build
  35. # [CMAKE_ARGS args...] # Arguments to CMake command line
  36. # [CMAKE_CACHE_ARGS args...] # Initial cache arguments, of the form -Dvar:string=on
  37. # #--Build step-----------------
  38. # [BINARY_DIR dir] # Specify build dir location
  39. # [BUILD_COMMAND cmd...] # Command to drive the native build
  40. # [BUILD_IN_SOURCE 1] # Use source dir for build dir
  41. # #--Install step---------------
  42. # [INSTALL_DIR dir] # Installation prefix
  43. # [INSTALL_COMMAND cmd...] # Command to drive install after build
  44. # #--Test step------------------
  45. # [TEST_BEFORE_INSTALL 1] # Add test step executed before install step
  46. # [TEST_AFTER_INSTALL 1] # Add test step executed after install step
  47. # [TEST_COMMAND cmd...] # Command to drive test
  48. # #--Output logging-------------
  49. # [LOG_DOWNLOAD 1] # Wrap download in script to log output
  50. # [LOG_UPDATE 1] # Wrap update in script to log output
  51. # [LOG_CONFIGURE 1] # Wrap configure in script to log output
  52. # [LOG_BUILD 1] # Wrap build in script to log output
  53. # [LOG_TEST 1] # Wrap test in script to log output
  54. # [LOG_INSTALL 1] # Wrap install in script to log output
  55. # #--Custom targets-------------
  56. # [STEP_TARGETS st1 st2 ...] # Generate custom targets for these steps
  57. # )
  58. # The *_DIR options specify directories for the project, with default
  59. # directories computed as follows.
  60. # If the PREFIX option is given to ExternalProject_Add() or the EP_PREFIX
  61. # directory property is set, then an external project is built and installed
  62. # under the specified prefix:
  63. # TMP_DIR = <prefix>/tmp
  64. # STAMP_DIR = <prefix>/src/<name>-stamp
  65. # DOWNLOAD_DIR = <prefix>/src
  66. # SOURCE_DIR = <prefix>/src/<name>
  67. # BINARY_DIR = <prefix>/src/<name>-build
  68. # INSTALL_DIR = <prefix>
  69. # Otherwise, if the EP_BASE directory property is set then components
  70. # of an external project are stored under the specified base:
  71. # TMP_DIR = <base>/tmp/<name>
  72. # STAMP_DIR = <base>/Stamp/<name>
  73. # DOWNLOAD_DIR = <base>/Download/<name>
  74. # SOURCE_DIR = <base>/Source/<name>
  75. # BINARY_DIR = <base>/Build/<name>
  76. # INSTALL_DIR = <base>/Install/<name>
  77. # If no PREFIX, EP_PREFIX, or EP_BASE is specified then the default
  78. # is to set PREFIX to "<name>-prefix".
  79. # Relative paths are interpreted with respect to the build directory
  80. # corresponding to the source directory in which ExternalProject_Add is
  81. # invoked.
  82. #
  83. # If SOURCE_DIR is explicitly set to an existing directory the project
  84. # will be built from it.
  85. # Otherwise a download step must be specified using one of the
  86. # DOWNLOAD_COMMAND, CVS_*, SVN_*, or URL options.
  87. # The URL option may refer locally to a directory or source tarball,
  88. # or refer to a remote tarball (e.g. http://.../src.tgz).
  89. #
  90. # The 'ExternalProject_Add_Step' function adds a custom step to an external
  91. # project:
  92. # ExternalProject_Add_Step(<name> <step> # Names of project and custom step
  93. # [COMMAND cmd...] # Command line invoked by this step
  94. # [COMMENT "text..."] # Text printed when step executes
  95. # [DEPENDEES steps...] # Steps on which this step depends
  96. # [DEPENDERS steps...] # Steps that depend on this step
  97. # [DEPENDS files...] # Files on which this step depends
  98. # [ALWAYS 1] # No stamp file, step always runs
  99. # [WORKING_DIRECTORY dir] # Working directory for command
  100. # [LOG 1] # Wrap step in script to log output
  101. # )
  102. # The command line, comment, and working directory of every standard
  103. # and custom step is processed to replace tokens
  104. # <SOURCE_DIR>,
  105. # <BINARY_DIR>,
  106. # <INSTALL_DIR>,
  107. # and <TMP_DIR>
  108. # with corresponding property values.
  109. #
  110. # The 'ExternalProject_Get_Property' function retrieves external project
  111. # target properties:
  112. # ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]])
  113. # It stores property values in variables of the same name.
  114. # Property names correspond to the keyword argument names of
  115. # 'ExternalProject_Add'.
  116. #
  117. # The 'ExternalProject_Add_StepTargets' function generates custom targets for
  118. # the steps listed:
  119. # ExternalProject_Add_StepTargets(<name> [step1 [step2 [...]]])
  120. #
  121. # If STEP_TARGETS is set then ExternalProject_Add_StepTargets is automatically
  122. # called at the end of matching calls to ExternalProject_Add_Step. Pass
  123. # STEP_TARGETS explicitly to individual ExternalProject_Add calls, or
  124. # implicitly to all ExternalProject_Add calls by setting the directory property
  125. # EP_STEP_TARGETS.
  126. #
  127. # If STEP_TARGETS is not set, clients may still manually call
  128. # ExternalProject_Add_StepTargets after calling ExternalProject_Add or
  129. # ExternalProject_Add_Step.
  130. #
  131. # This functionality is provided to make it easy to drive the steps
  132. # independently of each other by specifying targets on build command lines.
  133. # For example, you may be submitting to a sub-project based dashboard, where
  134. # you want to drive the configure portion of the build, then submit to the
  135. # dashboard, followed by the build portion, followed by tests. If you invoke
  136. # a custom target that depends on a step halfway through the step dependency
  137. # chain, then all the previous steps will also run to ensure everything is
  138. # up to date.
  139. #
  140. # For example, to drive configure, build and test steps independently for each
  141. # ExternalProject_Add call in your project, write the following line prior to
  142. # any ExternalProject_Add calls in your CMakeLists file:
  143. #
  144. # set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
  145. #=============================================================================
  146. # Copyright 2008-2012 Kitware, Inc.
  147. #
  148. # Distributed under the OSI-approved BSD License (the "License");
  149. # see accompanying file Copyright.txt for details.
  150. #
  151. # This software is distributed WITHOUT ANY WARRANTY; without even the
  152. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  153. # See the License for more information.
  154. #=============================================================================
  155. # (To distribute this file outside of CMake, substitute the full
  156. # License text for the above reference.)
  157. # Pre-compute a regex to match documented keywords for each command.
  158. math(EXPR _ep_documentation_line_count "${CMAKE_CURRENT_LIST_LINE} - 16")
  159. file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines
  160. LIMIT_COUNT ${_ep_documentation_line_count}
  161. REGEX "^# ( \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()")
  162. foreach(line IN LISTS lines)
  163. if("${line}" MATCHES "^# [A-Za-z0-9_]+\\(")
  164. if(_ep_func)
  165. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  166. endif()
  167. string(REGEX REPLACE "^# ([A-Za-z0-9_]+)\\(.*" "\\1" _ep_func "${line}")
  168. #message("function [${_ep_func}]")
  169. set(_ep_keywords_${_ep_func} "^(")
  170. set(_ep_keyword_sep)
  171. else()
  172. string(REGEX REPLACE "^# \\[([A-Z0-9_]+) .*" "\\1" _ep_key "${line}")
  173. #message(" keyword [${_ep_key}]")
  174. set(_ep_keywords_${_ep_func}
  175. "${_ep_keywords_${_ep_func}}${_ep_keyword_sep}${_ep_key}")
  176. set(_ep_keyword_sep "|")
  177. endif()
  178. endforeach()
  179. if(_ep_func)
  180. set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
  181. endif()
  182. function(_ep_parse_arguments f name ns args)
  183. # Transfer the arguments to this function into target properties for the
  184. # new custom target we just added so that we can set up all the build steps
  185. # correctly based on target properties.
  186. #
  187. # We loop through ARGN and consider the namespace starting with an
  188. # upper-case letter followed by at least two more upper-case letters,
  189. # numbers or underscores to be keywords.
  190. set(key)
  191. foreach(arg IN LISTS args)
  192. set(is_value 1)
  193. if(arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND
  194. NOT ((arg STREQUAL "${key}") AND (key STREQUAL "COMMAND")) AND
  195. NOT arg MATCHES "^(TRUE|FALSE)$")
  196. if(_ep_keywords_${f} AND arg MATCHES "${_ep_keywords_${f}}")
  197. set(is_value 0)
  198. endif()
  199. endif()
  200. if(is_value)
  201. if(key)
  202. # Value
  203. if(NOT arg STREQUAL "")
  204. set_property(TARGET ${name} APPEND PROPERTY ${ns}${key} "${arg}")
  205. else()
  206. get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
  207. if(have_key)
  208. get_property(value TARGET ${name} PROPERTY ${ns}${key})
  209. set_property(TARGET ${name} PROPERTY ${ns}${key} "${value};${arg}")
  210. else()
  211. set_property(TARGET ${name} PROPERTY ${ns}${key} "${arg}")
  212. endif()
  213. endif()
  214. else()
  215. # Missing Keyword
  216. message(AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}")
  217. endif()
  218. else()
  219. set(key "${arg}")
  220. endif()
  221. endforeach()
  222. endfunction(_ep_parse_arguments)
  223. define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED
  224. BRIEF_DOCS "Base directory for External Project storage."
  225. FULL_DOCS
  226. "See documentation of the ExternalProject_Add() function in the "
  227. "ExternalProject module."
  228. )
  229. define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED
  230. BRIEF_DOCS "Top prefix for External Project storage."
  231. FULL_DOCS
  232. "See documentation of the ExternalProject_Add() function in the "
  233. "ExternalProject module."
  234. )
  235. define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
  236. BRIEF_DOCS
  237. "List of ExternalProject steps that automatically get corresponding targets"
  238. FULL_DOCS
  239. "See documentation of the ExternalProject_Add_StepTargets() function in the "
  240. "ExternalProject module."
  241. )
  242. function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir gitclone_infofile gitclone_stampfile)
  243. file(WRITE ${script_filename}
  244. "if(\"${git_tag}\" STREQUAL \"\")
  245. message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
  246. endif()
  247. set(run 0)
  248. if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
  249. set(run 1)
  250. endif()
  251. if(NOT run)
  252. message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\")
  253. return()
  254. endif()
  255. execute_process(
  256. COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
  257. RESULT_VARIABLE error_code
  258. )
  259. if(error_code)
  260. message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
  261. endif()
  262. execute_process(
  263. COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\"
  264. WORKING_DIRECTORY \"${work_dir}\"
  265. RESULT_VARIABLE error_code
  266. )
  267. if(error_code)
  268. message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
  269. endif()
  270. execute_process(
  271. COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
  272. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  273. RESULT_VARIABLE error_code
  274. )
  275. if(error_code)
  276. message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
  277. endif()
  278. execute_process(
  279. COMMAND \"${git_EXECUTABLE}\" submodule init
  280. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  281. RESULT_VARIABLE error_code
  282. )
  283. if(error_code)
  284. message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\")
  285. endif()
  286. execute_process(
  287. COMMAND \"${git_EXECUTABLE}\" submodule update --recursive
  288. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  289. RESULT_VARIABLE error_code
  290. )
  291. if(error_code)
  292. message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
  293. endif()
  294. # Complete success, update the script-last-run stamp file:
  295. #
  296. execute_process(
  297. COMMAND \${CMAKE_COMMAND} -E copy
  298. \"${gitclone_infofile}\"
  299. \"${gitclone_stampfile}\"
  300. WORKING_DIRECTORY \"${work_dir}/${src_name}\"
  301. RESULT_VARIABLE error_code
  302. )
  303. if(error_code)
  304. message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${gitclone_stampfile}'\")
  305. endif()
  306. "
  307. )
  308. endfunction(_ep_write_gitclone_script)
  309. function(_ep_write_downloadfile_script script_filename remote local timeout md5)
  310. if(timeout)
  311. set(timeout_args TIMEOUT ${timeout})
  312. set(timeout_msg "${timeout} seconds")
  313. else()
  314. set(timeout_args "# no TIMEOUT")
  315. set(timeout_msg "none")
  316. endif()
  317. if(md5)
  318. set(md5_args EXPECTED_MD5 ${md5})
  319. else()
  320. set(md5_args "# no EXPECTED_MD5")
  321. endif()
  322. file(WRITE ${script_filename}
  323. "message(STATUS \"downloading...
  324. src='${remote}'
  325. dst='${local}'
  326. timeout='${timeout_msg}'\")
  327. file(DOWNLOAD
  328. \"${remote}\"
  329. \"${local}\"
  330. SHOW_PROGRESS
  331. ${md5_args}
  332. ${timeout_args}
  333. STATUS status
  334. LOG log)
  335. list(GET status 0 status_code)
  336. list(GET status 1 status_string)
  337. if(NOT status_code EQUAL 0)
  338. message(FATAL_ERROR \"error: downloading '${remote}' failed
  339. status_code: \${status_code}
  340. status_string: \${status_string}
  341. log: \${log}
  342. \")
  343. endif()
  344. message(STATUS \"downloading... done\")
  345. "
  346. )
  347. endfunction(_ep_write_downloadfile_script)
  348. function(_ep_write_verifyfile_script script_filename local md5)
  349. file(WRITE ${script_filename}
  350. "message(STATUS \"verifying file...
  351. file='${local}'\")
  352. set(verified 0)
  353. # If an expected md5 checksum exists, compare against it:
  354. #
  355. if(NOT \"${md5}\" STREQUAL \"\")
  356. execute_process(COMMAND \${CMAKE_COMMAND} -E md5sum \"${local}\"
  357. OUTPUT_VARIABLE ov
  358. OUTPUT_STRIP_TRAILING_WHITESPACE
  359. RESULT_VARIABLE rv)
  360. if(NOT rv EQUAL 0)
  361. message(FATAL_ERROR \"error: computing md5sum of '${local}' failed\")
  362. endif()
  363. string(REGEX MATCH \"^([0-9A-Fa-f]+)\" md5_actual \"\${ov}\")
  364. string(TOLOWER \"\${md5_actual}\" md5_actual)
  365. string(TOLOWER \"${md5}\" md5)
  366. if(NOT \"\${md5}\" STREQUAL \"\${md5_actual}\")
  367. message(FATAL_ERROR \"error: md5sum of '${local}' does not match expected value
  368. md5_expected: \${md5}
  369. md5_actual: \${md5_actual}
  370. \")
  371. endif()
  372. set(verified 1)
  373. endif()
  374. if(verified)
  375. message(STATUS \"verifying file... done\")
  376. else()
  377. message(STATUS \"verifying file... warning: did not verify file - no URL_MD5 checksum argument? corrupt file?\")
  378. endif()
  379. "
  380. )
  381. endfunction(_ep_write_verifyfile_script)
  382. function(_ep_write_extractfile_script script_filename name filename directory)
  383. set(args "")
  384. if(filename MATCHES "(\\.|=)(bz2|tar\\.gz|tgz|zip)$")
  385. set(args xfz)
  386. endif()
  387. if(filename MATCHES "(\\.|=)tar$")
  388. set(args xf)
  389. endif()
  390. if(args STREQUAL "")
  391. message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .bz2, .tar, .tar.gz, .tgz and .zip")
  392. return()
  393. endif()
  394. file(WRITE ${script_filename}
  395. "# Make file names absolute:
  396. #
  397. get_filename_component(filename \"${filename}\" ABSOLUTE)
  398. get_filename_component(directory \"${directory}\" ABSOLUTE)
  399. message(STATUS \"extracting...
  400. src='\${filename}'
  401. dst='\${directory}'\")
  402. if(NOT EXISTS \"\${filename}\")
  403. message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\")
  404. endif()
  405. # Prepare a space for extracting:
  406. #
  407. set(i 1234)
  408. while(EXISTS \"\${directory}/../ex-${name}\${i}\")
  409. math(EXPR i \"\${i} + 1\")
  410. endwhile()
  411. set(ut_dir \"\${directory}/../ex-${name}\${i}\")
  412. file(MAKE_DIRECTORY \"\${ut_dir}\")
  413. # Extract it:
  414. #
  415. message(STATUS \"extracting... [tar ${args}]\")
  416. execute_process(COMMAND \${CMAKE_COMMAND} -E tar ${args} \${filename}
  417. WORKING_DIRECTORY \${ut_dir}
  418. RESULT_VARIABLE rv)
  419. if(NOT rv EQUAL 0)
  420. message(STATUS \"extracting... [error clean up]\")
  421. file(REMOVE_RECURSE \"\${ut_dir}\")
  422. message(FATAL_ERROR \"error: extract of '\${filename}' failed\")
  423. endif()
  424. # Analyze what came out of the tar file:
  425. #
  426. message(STATUS \"extracting... [analysis]\")
  427. file(GLOB contents \"\${ut_dir}/*\")
  428. list(LENGTH contents n)
  429. if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
  430. set(contents \"\${ut_dir}\")
  431. endif()
  432. # Move \"the one\" directory to the final directory:
  433. #
  434. message(STATUS \"extracting... [rename]\")
  435. file(REMOVE_RECURSE \${directory})
  436. get_filename_component(contents \${contents} ABSOLUTE)
  437. file(RENAME \${contents} \${directory})
  438. # Clean up:
  439. #
  440. message(STATUS \"extracting... [clean up]\")
  441. file(REMOVE_RECURSE \"\${ut_dir}\")
  442. message(STATUS \"extracting... done\")
  443. "
  444. )
  445. endfunction(_ep_write_extractfile_script)
  446. function(_ep_set_directories name)
  447. get_property(prefix TARGET ${name} PROPERTY _EP_PREFIX)
  448. if(NOT prefix)
  449. get_property(prefix DIRECTORY PROPERTY EP_PREFIX)
  450. if(NOT prefix)
  451. get_property(base DIRECTORY PROPERTY EP_BASE)
  452. if(NOT base)
  453. set(prefix "${name}-prefix")
  454. endif()
  455. endif()
  456. endif()
  457. if(prefix)
  458. set(tmp_default "${prefix}/tmp")
  459. set(download_default "${prefix}/src")
  460. set(source_default "${prefix}/src/${name}")
  461. set(binary_default "${prefix}/src/${name}-build")
  462. set(stamp_default "${prefix}/src/${name}-stamp")
  463. set(install_default "${prefix}")
  464. else() # assert(base)
  465. set(tmp_default "${base}/tmp/${name}")
  466. set(download_default "${base}/Download/${name}")
  467. set(source_default "${base}/Source/${name}")
  468. set(binary_default "${base}/Build/${name}")
  469. set(stamp_default "${base}/Stamp/${name}")
  470. set(install_default "${base}/Install/${name}")
  471. endif()
  472. get_property(build_in_source TARGET ${name} PROPERTY _EP_BUILD_IN_SOURCE)
  473. if(build_in_source)
  474. get_property(have_binary_dir TARGET ${name} PROPERTY _EP_BINARY_DIR SET)
  475. if(have_binary_dir)
  476. message(FATAL_ERROR
  477. "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!")
  478. endif()
  479. endif()
  480. set(top "${CMAKE_CURRENT_BINARY_DIR}")
  481. set(places stamp download source binary install tmp)
  482. foreach(var ${places})
  483. string(TOUPPER "${var}" VAR)
  484. get_property(${var}_dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  485. if(NOT ${var}_dir)
  486. set(${var}_dir "${${var}_default}")
  487. endif()
  488. if(NOT IS_ABSOLUTE "${${var}_dir}")
  489. get_filename_component(${var}_dir "${top}/${${var}_dir}" ABSOLUTE)
  490. endif()
  491. set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
  492. endforeach()
  493. if(build_in_source)
  494. get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
  495. set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
  496. endif()
  497. # Make the directories at CMake configure time *and* add a custom command
  498. # to make them at build time. They need to exist at makefile generation
  499. # time for Borland make and wmake so that CMake may generate makefiles
  500. # with "cd C:\short\paths\with\no\spaces" commands in them.
  501. #
  502. # Additionally, the add_custom_command is still used in case somebody
  503. # removes one of the necessary directories and tries to rebuild without
  504. # re-running cmake.
  505. foreach(var ${places})
  506. string(TOUPPER "${var}" VAR)
  507. get_property(dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
  508. file(MAKE_DIRECTORY "${dir}")
  509. if(NOT EXISTS "${dir}")
  510. message(FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)")
  511. endif()
  512. endforeach()
  513. endfunction(_ep_set_directories)
  514. # IMPORTANT: this MUST be a macro and not a function because of the
  515. # in-place replacements that occur in each ${var}
  516. #
  517. macro(_ep_replace_location_tags target_name)
  518. set(vars ${ARGN})
  519. foreach(var ${vars})
  520. if(${var})
  521. foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR)
  522. get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
  523. string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
  524. endforeach()
  525. endif()
  526. endforeach()
  527. endmacro()
  528. function(_ep_write_initial_cache target_name script_filename args)
  529. # Write out values into an initial cache, that will be passed to CMake with -C
  530. set(script_initial_cache "")
  531. set(regex "^([^:]+):([^=]+)=(.*)$")
  532. set(setArg "")
  533. foreach(line ${args})
  534. if("${line}" MATCHES "^-D")
  535. if(setArg)
  536. # This is required to build up lists in variables, or complete an entry
  537. set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
  538. set(script_initial_cache "${script_initial_cache}\n${setArg}")
  539. set(accumulator "")
  540. set(setArg "")
  541. endif()
  542. string(REGEX REPLACE "^-D" "" line ${line})
  543. if("${line}" MATCHES "${regex}")
  544. string(REGEX MATCH "${regex}" match "${line}")
  545. set(name "${CMAKE_MATCH_1}")
  546. set(type "${CMAKE_MATCH_2}")
  547. set(value "${CMAKE_MATCH_3}")
  548. set(setArg "set(${name} \"${value}")
  549. else()
  550. message(WARNING "Line '${line}' does not match regex. Ignoring.")
  551. endif()
  552. else()
  553. # Assume this is a list to append to the last var
  554. set(accumulator "${accumulator};${line}")
  555. endif()
  556. endforeach()
  557. # Catch the final line of the args
  558. if(setArg)
  559. set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
  560. set(script_initial_cache "${script_initial_cache}\n${setArg}")
  561. endif()
  562. # Replace location tags.
  563. _ep_replace_location_tags(${target_name} script_initial_cache)
  564. # Write out the initial cache file to the location specified.
  565. if(NOT EXISTS "${script_filename}.in")
  566. file(WRITE "${script_filename}.in" "\@script_initial_cache\@\n")
  567. endif()
  568. configure_file("${script_filename}.in" "${script_filename}")
  569. endfunction(_ep_write_initial_cache)
  570. function(ExternalProject_Get_Property name)
  571. foreach(var ${ARGN})
  572. string(TOUPPER "${var}" VAR)
  573. get_property(${var} TARGET ${name} PROPERTY _EP_${VAR})
  574. if(NOT ${var})
  575. message(FATAL_ERROR "External project \"${name}\" has no ${var}")
  576. endif()
  577. set(${var} "${${var}}" PARENT_SCOPE)
  578. endforeach()
  579. endfunction(ExternalProject_Get_Property)
  580. function(_ep_get_configure_command_id name cfg_cmd_id_var)
  581. get_target_property(cmd ${name} _EP_CONFIGURE_COMMAND)
  582. if(cmd STREQUAL "")
  583. # Explicit empty string means no configure step for this project
  584. set(${cfg_cmd_id_var} "none" PARENT_SCOPE)
  585. else()
  586. if(NOT cmd)
  587. # Default is "use cmake":
  588. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  589. else()
  590. # Otherwise we have to analyze the value:
  591. if(cmd MATCHES "^[^;]*/configure")
  592. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  593. elseif(cmd MATCHES "^[^;]*/cmake" AND NOT cmd MATCHES ";-[PE];")
  594. set(${cfg_cmd_id_var} "cmake" PARENT_SCOPE)
  595. elseif(cmd MATCHES "config")
  596. set(${cfg_cmd_id_var} "configure" PARENT_SCOPE)
  597. else()
  598. set(${cfg_cmd_id_var} "unknown:${cmd}" PARENT_SCOPE)
  599. endif()
  600. endif()
  601. endif()
  602. endfunction(_ep_get_configure_command_id)
  603. function(_ep_get_build_command name step cmd_var)
  604. set(cmd "${${cmd_var}}")
  605. if(NOT cmd)
  606. set(args)
  607. _ep_get_configure_command_id(${name} cfg_cmd_id)
  608. if(cfg_cmd_id STREQUAL "cmake")
  609. # CMake project. Select build command based on generator.
  610. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  611. if("${CMAKE_GENERATOR}" MATCHES "Make" AND
  612. ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator))
  613. # The project uses the same Makefile generator. Use recursive make.
  614. set(cmd "$(MAKE)")
  615. if(step STREQUAL "INSTALL")
  616. set(args install)
  617. endif()
  618. if(step STREQUAL "TEST")
  619. set(args test)
  620. endif()
  621. else()
  622. # Drive the project with "cmake --build".
  623. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  624. if(cmake_command)
  625. set(cmd "${cmake_command}")
  626. else()
  627. set(cmd "${CMAKE_COMMAND}")
  628. endif()
  629. set(args --build ${binary_dir} --config ${CMAKE_CFG_INTDIR})
  630. if(step STREQUAL "INSTALL")
  631. list(APPEND args --target install)
  632. endif()
  633. # But for "TEST" drive the project with corresponding "ctest".
  634. if(step STREQUAL "TEST")
  635. string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
  636. set(args "")
  637. endif()
  638. endif()
  639. else() # if(cfg_cmd_id STREQUAL "configure")
  640. # Non-CMake project. Guess "make" and "make install" and "make test".
  641. # But use "$(MAKE)" to get recursive parallel make.
  642. set(cmd "$(MAKE)")
  643. if(step STREQUAL "INSTALL")
  644. set(args install)
  645. endif()
  646. if(step STREQUAL "TEST")
  647. set(args test)
  648. endif()
  649. endif()
  650. # Use user-specified arguments instead of default arguments, if any.
  651. get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET)
  652. if(have_args)
  653. get_target_property(args ${name} _EP_${step}_ARGS)
  654. endif()
  655. list(APPEND cmd ${args})
  656. endif()
  657. set(${cmd_var} "${cmd}" PARENT_SCOPE)
  658. endfunction(_ep_get_build_command)
  659. function(_ep_write_log_script name step cmd_var)
  660. ExternalProject_Get_Property(${name} stamp_dir)
  661. set(command "${${cmd_var}}")
  662. set(make "")
  663. set(code_cygpath_make "")
  664. if("${command}" MATCHES "^\\$\\(MAKE\\)")
  665. # GNU make recognizes the string "$(MAKE)" as recursive make, so
  666. # ensure that it appears directly in the makefile.
  667. string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}")
  668. set(make "-Dmake=$(MAKE)")
  669. if(WIN32 AND NOT CYGWIN)
  670. set(code_cygpath_make "
  671. if(\${make} MATCHES \"^/\")
  672. execute_process(
  673. COMMAND cygpath -w \${make}
  674. OUTPUT_VARIABLE cygpath_make
  675. ERROR_VARIABLE cygpath_make
  676. RESULT_VARIABLE cygpath_error
  677. OUTPUT_STRIP_TRAILING_WHITESPACE
  678. )
  679. if(NOT cygpath_error)
  680. set(make \${cygpath_make})
  681. endif()
  682. endif()
  683. ")
  684. endif()
  685. endif()
  686. set(config "")
  687. if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$")
  688. string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}")
  689. set(config "-Dconfig=${CMAKE_CFG_INTDIR}")
  690. endif()
  691. # Wrap multiple 'COMMAND' lines up into a second-level wrapper
  692. # script so all output can be sent to one log file.
  693. if("${command}" MATCHES ";COMMAND;")
  694. set(code_execute_process "
  695. ${code_cygpath_make}
  696. execute_process(COMMAND \${command} RESULT_VARIABLE result)
  697. if(result)
  698. set(msg \"Command failed (\${result}):\\n\")
  699. foreach(arg IN LISTS command)
  700. set(msg \"\${msg} '\${arg}'\")
  701. endforeach(arg)
  702. message(FATAL_ERROR \"\${msg}\")
  703. endif()
  704. ")
  705. set(code "")
  706. set(cmd "")
  707. set(sep "")
  708. foreach(arg IN LISTS command)
  709. if("x${arg}" STREQUAL "xCOMMAND")
  710. set(code "${code}set(command \"${cmd}\")${code_execute_process}")
  711. set(cmd "")
  712. set(sep "")
  713. else()
  714. set(cmd "${cmd}${sep}${arg}")
  715. set(sep ";")
  716. endif()
  717. endforeach()
  718. set(code "set(ENV{VS_UNICODE_OUTPUT} \"\")\n${code}set(command \"${cmd}\")${code_execute_process}")
  719. file(WRITE ${stamp_dir}/${name}-${step}-impl.cmake "${code}")
  720. set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-impl.cmake)
  721. endif()
  722. # Wrap the command in a script to log output to files.
  723. set(script ${stamp_dir}/${name}-${step}.cmake)
  724. set(logbase ${stamp_dir}/${name}-${step})
  725. file(WRITE ${script} "
  726. ${code_cygpath_make}
  727. set(ENV{VS_UNICODE_OUTPUT} \"\")
  728. set(command \"${command}\")
  729. execute_process(
  730. COMMAND \${command}
  731. RESULT_VARIABLE result
  732. OUTPUT_FILE \"${logbase}-out.log\"
  733. ERROR_FILE \"${logbase}-err.log\"
  734. )
  735. if(result)
  736. set(msg \"Command failed: \${result}\\n\")
  737. foreach(arg IN LISTS command)
  738. set(msg \"\${msg} '\${arg}'\")
  739. endforeach(arg)
  740. set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\\n\")
  741. message(FATAL_ERROR \"\${msg}\")
  742. else()
  743. set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\\n\")
  744. message(STATUS \"\${msg}\")
  745. endif()
  746. ")
  747. set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script})
  748. set(${cmd_var} "${command}" PARENT_SCOPE)
  749. endfunction(_ep_write_log_script)
  750. # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced
  751. # makefiles with "/./" in paths for custom command dependencies. Which
  752. # resulted in problems with parallel make -j invocations.
  753. #
  754. # This function was added so that the suffix (search below for ${cfgdir}) is
  755. # only set to "/${CMAKE_CFG_INTDIR}" when ${CMAKE_CFG_INTDIR} is not going to
  756. # be "." (multi-configuration build systems like Visual Studio and Xcode...)
  757. #
  758. function(_ep_get_configuration_subdir_suffix suffix_var)
  759. set(suffix "")
  760. if(CMAKE_CONFIGURATION_TYPES)
  761. set(suffix "/${CMAKE_CFG_INTDIR}")
  762. endif()
  763. set(${suffix_var} "${suffix}" PARENT_SCOPE)
  764. endfunction(_ep_get_configuration_subdir_suffix)
  765. function(_ep_get_step_stampfile name step stampfile_var)
  766. ExternalProject_Get_Property(${name} stamp_dir)
  767. _ep_get_configuration_subdir_suffix(cfgdir)
  768. set(stampfile "${stamp_dir}${cfgdir}/${name}-${step}")
  769. set(${stampfile_var} "${stampfile}" PARENT_SCOPE)
  770. endfunction()
  771. function(ExternalProject_Add_StepTargets name)
  772. set(steps ${ARGN})
  773. foreach(step ${steps})
  774. _ep_get_step_stampfile(${name} ${step} stamp_file)
  775. add_custom_target(${name}-${step}
  776. DEPENDS ${stamp_file})
  777. # Depend on other external projects (target-level).
  778. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  779. foreach(arg IN LISTS deps)
  780. add_dependencies(${name}-${step} ${arg})
  781. endforeach()
  782. endforeach()
  783. endfunction(ExternalProject_Add_StepTargets)
  784. function(ExternalProject_Add_Step name step)
  785. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  786. _ep_get_configuration_subdir_suffix(cfgdir)
  787. set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
  788. _ep_get_step_stampfile(${name} ${step} stamp_file)
  789. add_custom_command(APPEND
  790. OUTPUT ${complete_stamp_file}
  791. DEPENDS ${stamp_file}
  792. )
  793. _ep_parse_arguments(ExternalProject_Add_Step
  794. ${name} _EP_${step}_ "${ARGN}")
  795. # Steps depending on this step.
  796. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS)
  797. foreach(depender IN LISTS dependers)
  798. _ep_get_step_stampfile(${name} ${depender} depender_stamp_file)
  799. add_custom_command(APPEND
  800. OUTPUT ${depender_stamp_file}
  801. DEPENDS ${stamp_file}
  802. )
  803. endforeach()
  804. # Dependencies on files.
  805. get_property(depends TARGET ${name} PROPERTY _EP_${step}_DEPENDS)
  806. # Dependencies on steps.
  807. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES)
  808. foreach(dependee IN LISTS dependees)
  809. _ep_get_step_stampfile(${name} ${dependee} dependee_stamp_file)
  810. list(APPEND depends ${dependee_stamp_file})
  811. endforeach()
  812. # The command to run.
  813. get_property(command TARGET ${name} PROPERTY _EP_${step}_COMMAND)
  814. if(command)
  815. set(comment "Performing ${step} step for '${name}'")
  816. else()
  817. set(comment "No ${step} step for '${name}'")
  818. endif()
  819. get_property(work_dir TARGET ${name} PROPERTY _EP_${step}_WORKING_DIRECTORY)
  820. # Replace list separators.
  821. get_property(sep TARGET ${name} PROPERTY _EP_LIST_SEPARATOR)
  822. if(sep AND command)
  823. string(REPLACE "${sep}" "\\;" command "${command}")
  824. endif()
  825. # Replace location tags.
  826. _ep_replace_location_tags(${name} comment command work_dir)
  827. # Custom comment?
  828. get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET)
  829. if(comment_set)
  830. get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT)
  831. endif()
  832. # Run every time?
  833. get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS)
  834. if(always)
  835. set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
  836. set(touch)
  837. else()
  838. set(touch ${CMAKE_COMMAND} -E touch ${stamp_file})
  839. endif()
  840. # Wrap with log script?
  841. get_property(log TARGET ${name} PROPERTY _EP_${step}_LOG)
  842. if(command AND log)
  843. _ep_write_log_script(${name} ${step} command)
  844. endif()
  845. add_custom_command(
  846. OUTPUT ${stamp_file}
  847. COMMENT ${comment}
  848. COMMAND ${command}
  849. COMMAND ${touch}
  850. DEPENDS ${depends}
  851. WORKING_DIRECTORY ${work_dir}
  852. VERBATIM
  853. )
  854. # Add custom "step target"?
  855. get_property(step_targets TARGET ${name} PROPERTY _EP_STEP_TARGETS)
  856. if(NOT step_targets)
  857. get_property(step_targets DIRECTORY PROPERTY EP_STEP_TARGETS)
  858. endif()
  859. foreach(st ${step_targets})
  860. if("${st}" STREQUAL "${step}")
  861. ExternalProject_Add_StepTargets(${name} ${step})
  862. break()
  863. endif()
  864. endforeach()
  865. endfunction(ExternalProject_Add_Step)
  866. function(_ep_add_mkdir_command name)
  867. ExternalProject_Get_Property(${name}
  868. source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
  869. _ep_get_configuration_subdir_suffix(cfgdir)
  870. ExternalProject_Add_Step(${name} mkdir
  871. COMMENT "Creating directories for '${name}'"
  872. COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
  873. COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir}
  874. COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}
  875. COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
  876. COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
  877. COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
  878. )
  879. endfunction(_ep_add_mkdir_command)
  880. function(_ep_get_git_version git_EXECUTABLE git_version_var)
  881. if(git_EXECUTABLE)
  882. execute_process(
  883. COMMAND "${git_EXECUTABLE}" --version
  884. OUTPUT_VARIABLE ov
  885. ERROR_VARIABLE ev
  886. OUTPUT_STRIP_TRAILING_WHITESPACE
  887. )
  888. string(REGEX REPLACE "^git version (.+)$" "\\1" version "${ov}")
  889. set(${git_version_var} "${version}" PARENT_SCOPE)
  890. endif()
  891. endfunction()
  892. function(_ep_is_dir_empty dir empty_var)
  893. file(GLOB gr "${dir}/*")
  894. if("${gr}" STREQUAL "")
  895. set(${empty_var} 1 PARENT_SCOPE)
  896. else()
  897. set(${empty_var} 0 PARENT_SCOPE)
  898. endif()
  899. endfunction()
  900. function(_ep_add_download_command name)
  901. ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir)
  902. get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET)
  903. get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND)
  904. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  905. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  906. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  907. get_property(url TARGET ${name} PROPERTY _EP_URL)
  908. # TODO: Perhaps file:// should be copied to download dir before extraction.
  909. string(REGEX REPLACE "^file://" "" url "${url}")
  910. set(depends)
  911. set(comment)
  912. set(work_dir)
  913. if(cmd_set)
  914. set(work_dir ${download_dir})
  915. elseif(cvs_repository)
  916. find_package(CVS)
  917. if(NOT CVS_EXECUTABLE)
  918. message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
  919. endif()
  920. get_target_property(cvs_module ${name} _EP_CVS_MODULE)
  921. if(NOT cvs_module)
  922. message(FATAL_ERROR "error: no CVS_MODULE")
  923. endif()
  924. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  925. set(repository ${cvs_repository})
  926. set(module ${cvs_module})
  927. set(tag ${cvs_tag})
  928. configure_file(
  929. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  930. "${stamp_dir}/${name}-cvsinfo.txt"
  931. @ONLY
  932. )
  933. get_filename_component(src_name "${source_dir}" NAME)
  934. get_filename_component(work_dir "${source_dir}" PATH)
  935. set(comment "Performing download step (CVS checkout) for '${name}'")
  936. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module})
  937. list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt)
  938. elseif(svn_repository)
  939. find_package(Subversion)
  940. if(NOT Subversion_SVN_EXECUTABLE)
  941. message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
  942. endif()
  943. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  944. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  945. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  946. get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT)
  947. set(repository "${svn_repository} user=${svn_username} password=${svn_password}")
  948. set(module)
  949. set(tag ${svn_revision})
  950. configure_file(
  951. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  952. "${stamp_dir}/${name}-svninfo.txt"
  953. @ONLY
  954. )
  955. get_filename_component(src_name "${source_dir}" NAME)
  956. get_filename_component(work_dir "${source_dir}" PATH)
  957. set(comment "Performing download step (SVN checkout) for '${name}'")
  958. set(svn_user_pw_args "")
  959. if(svn_username)
  960. set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}")
  961. endif()
  962. if(svn_password)
  963. set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}")
  964. endif()
  965. if(svn_trust_cert)
  966. set(svn_trust_cert_args --trust-server-cert)
  967. endif()
  968. set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision}
  969. --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name})
  970. list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
  971. elseif(git_repository)
  972. find_package(Git)
  973. if(NOT GIT_EXECUTABLE)
  974. message(FATAL_ERROR "error: could not find git for clone of ${name}")
  975. endif()
  976. # The git submodule update '--recursive' flag requires git >= v1.6.5
  977. #
  978. _ep_get_git_version("${GIT_EXECUTABLE}" git_version)
  979. if(git_version VERSION_LESS 1.6.5)
  980. message(FATAL_ERROR "error: git version 1.6.5 or later required for 'git submodule update --recursive': git_version='${git_version}'")
  981. endif()
  982. get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG)
  983. if(NOT git_tag)
  984. set(git_tag "master")
  985. endif()
  986. # For the download step, and the git clone operation, only the repository
  987. # should be recorded in a configured RepositoryInfo file. If the repo
  988. # changes, the clone script should be run again. But if only the tag
  989. # changes, avoid running the clone script again. Let the 'always' running
  990. # update step checkout the new tag.
  991. #
  992. set(repository ${git_repository})
  993. set(module)
  994. set(tag)
  995. configure_file(
  996. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  997. "${stamp_dir}/${name}-gitinfo.txt"
  998. @ONLY
  999. )
  1000. get_filename_component(src_name "${source_dir}" NAME)
  1001. get_filename_component(work_dir "${source_dir}" PATH)
  1002. # Since git clone doesn't succeed if the non-empty source_dir exists,
  1003. # create a cmake script to invoke as download command.
  1004. # The script will delete the source directory and then call git clone.
  1005. #
  1006. _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
  1007. ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${src_name} ${work_dir}
  1008. ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
  1009. )
  1010. set(comment "Performing download step (git clone) for '${name}'")
  1011. set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
  1012. list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
  1013. elseif(url)
  1014. get_filename_component(work_dir "${source_dir}" PATH)
  1015. get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5)
  1016. set(repository "external project URL")
  1017. set(module "${url}")
  1018. set(tag "${md5}")
  1019. configure_file(
  1020. "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
  1021. "${stamp_dir}/${name}-urlinfo.txt"
  1022. @ONLY
  1023. )
  1024. list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt)
  1025. if(IS_DIRECTORY "${url}")
  1026. get_filename_component(abs_dir "${url}" ABSOLUTE)
  1027. set(comment "Performing download step (DIR copy) for '${name}'")
  1028. set(cmd ${CMAKE_COMMAND} -E remove_directory ${source_dir}
  1029. COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir})
  1030. else()
  1031. if("${url}" MATCHES "^[a-z]+://")
  1032. # TODO: Should download and extraction be different steps?
  1033. string(REGEX MATCH "[^/\\?]*$" fname "${url}")
  1034. if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$")
  1035. string(REGEX MATCH "([^/\\?]+(\\.|=)(bz2|tar|tgz|tar\\.gz|zip))/.*$" match_result "${url}")
  1036. set(fname "${CMAKE_MATCH_1}")
  1037. endif()
  1038. if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$")
  1039. message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
  1040. endif()
  1041. string(REPLACE ";" "-" fname "${fname}")
  1042. set(file ${download_dir}/${fname})
  1043. get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
  1044. _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}")
  1045. set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake
  1046. COMMAND)
  1047. set(comment "Performing download step (download, verify and extract) for '${name}'")
  1048. else()
  1049. set(file "${url}")
  1050. set(comment "Performing download step (verify and extract) for '${name}'")
  1051. endif()
  1052. _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${md5}")
  1053. list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake
  1054. COMMAND)
  1055. _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
  1056. list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
  1057. endif()
  1058. else()
  1059. _ep_is_dir_empty("${source_dir}" empty)
  1060. if(${empty})
  1061. message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY or DOWNLOAD_COMMAND")
  1062. endif()
  1063. endif()
  1064. get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD)
  1065. if(log)
  1066. set(log LOG 1)
  1067. else()
  1068. set(log "")
  1069. endif()
  1070. ExternalProject_Add_Step(${name} download
  1071. COMMENT ${comment}
  1072. COMMAND ${cmd}
  1073. WORKING_DIRECTORY ${work_dir}
  1074. DEPENDS ${depends}
  1075. DEPENDEES mkdir
  1076. ${log}
  1077. )
  1078. endfunction(_ep_add_download_command)
  1079. function(_ep_add_update_command name)
  1080. ExternalProject_Get_Property(${name} source_dir)
  1081. get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET)
  1082. get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND)
  1083. get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY)
  1084. get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
  1085. get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
  1086. set(work_dir)
  1087. set(comment)
  1088. set(always)
  1089. if(cmd_set)
  1090. set(work_dir ${source_dir})
  1091. elseif(cvs_repository)
  1092. if(NOT CVS_EXECUTABLE)
  1093. message(FATAL_ERROR "error: could not find cvs for update of ${name}")
  1094. endif()
  1095. set(work_dir ${source_dir})
  1096. set(comment "Performing update step (CVS update) for '${name}'")
  1097. get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG)
  1098. set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q up -dP ${cvs_tag})
  1099. set(always 1)
  1100. elseif(svn_repository)
  1101. if(NOT Subversion_SVN_EXECUTABLE)
  1102. message(FATAL_ERROR "error: could not find svn for update of ${name}")
  1103. endif()
  1104. set(work_dir ${source_dir})
  1105. set(comment "Performing update step (SVN update) for '${name}'")
  1106. get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  1107. get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME)
  1108. get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD)
  1109. get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT)
  1110. set(svn_user_pw_args "")
  1111. if(svn_username)
  1112. set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}")
  1113. endif()
  1114. if(svn_password)
  1115. set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}")
  1116. endif()
  1117. if(svn_trust_cert)
  1118. set(svn_trust_cert_args --trust-server-cert)
  1119. endif()
  1120. set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision}
  1121. --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args})
  1122. set(always 1)
  1123. elseif(git_repository)
  1124. if(NOT GIT_EXECUTABLE)
  1125. message(FATAL_ERROR "error: could not find git for fetch of ${name}")
  1126. endif()
  1127. set(work_dir ${source_dir})
  1128. set(comment "Performing update step (git fetch) for '${name}'")
  1129. get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG)
  1130. if(NOT git_tag)
  1131. set(git_tag "master")
  1132. endif()
  1133. set(cmd ${GIT_EXECUTABLE} fetch
  1134. COMMAND ${GIT_EXECUTABLE} checkout ${git_tag}
  1135. COMMAND ${GIT_EXECUTABLE} submodule update --recursive
  1136. )
  1137. set(always 1)
  1138. endif()
  1139. get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE)
  1140. if(log)
  1141. set(log LOG 1)
  1142. else()
  1143. set(log "")
  1144. endif()
  1145. ExternalProject_Add_Step(${name} update
  1146. COMMENT ${comment}
  1147. COMMAND ${cmd}
  1148. ALWAYS ${always}
  1149. WORKING_DIRECTORY ${work_dir}
  1150. DEPENDEES download
  1151. ${log}
  1152. )
  1153. endfunction(_ep_add_update_command)
  1154. function(_ep_add_patch_command name)
  1155. ExternalProject_Get_Property(${name} source_dir)
  1156. get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
  1157. get_property(cmd TARGET ${name} PROPERTY _EP_PATCH_COMMAND)
  1158. set(work_dir)
  1159. if(cmd_set)
  1160. set(work_dir ${source_dir})
  1161. endif()
  1162. ExternalProject_Add_Step(${name} patch
  1163. COMMAND ${cmd}
  1164. WORKING_DIRECTORY ${work_dir}
  1165. DEPENDEES download
  1166. )
  1167. endfunction(_ep_add_patch_command)
  1168. # TODO: Make sure external projects use the proper compiler
  1169. function(_ep_add_configure_command name)
  1170. ExternalProject_Get_Property(${name} source_dir binary_dir tmp_dir)
  1171. # Depend on other external projects (file-level).
  1172. set(file_deps)
  1173. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  1174. foreach(dep IN LISTS deps)
  1175. _ep_get_step_stampfile(${dep} "done" done_stamp_file)
  1176. list(APPEND file_deps ${done_stamp_file})
  1177. endforeach()
  1178. get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET)
  1179. if(cmd_set)
  1180. get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND)
  1181. else()
  1182. get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND)
  1183. if(cmake_command)
  1184. set(cmd "${cmake_command}")
  1185. else()
  1186. set(cmd "${CMAKE_COMMAND}")
  1187. endif()
  1188. get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS)
  1189. list(APPEND cmd ${cmake_args})
  1190. # If there are any CMAKE_CACHE_ARGS, write an initial cache and use it
  1191. get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
  1192. if(cmake_cache_args)
  1193. set(_ep_cache_args_script "${tmp_dir}/${name}-cache.cmake")
  1194. _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${cmake_cache_args}")
  1195. list(APPEND cmd "-C${_ep_cache_args_script}")
  1196. endif()
  1197. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
  1198. if(cmake_generator)
  1199. list(APPEND cmd "-G${cmake_generator}" "${source_dir}")
  1200. else()
  1201. if(CMAKE_EXTRA_GENERATOR)
  1202. list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}"
  1203. "${source_dir}")
  1204. else()
  1205. list(APPEND cmd "-G${CMAKE_GENERATOR}" "${source_dir}")
  1206. endif()
  1207. endif()
  1208. endif()
  1209. # If anything about the configure command changes, (command itself, cmake
  1210. # used, cmake args or cmake generator) then re-run the configure step.
  1211. # Fixes issue http://public.kitware.com/Bug/view.php?id=10258
  1212. #
  1213. if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
  1214. file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='\@cmd\@'\n")
  1215. endif()
  1216. configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
  1217. list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
  1218. list(APPEND file_deps ${_ep_cache_args_script})
  1219. get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE)
  1220. if(log)
  1221. set(log LOG 1)
  1222. else()
  1223. set(log "")
  1224. endif()
  1225. ExternalProject_Add_Step(${name} configure
  1226. COMMAND ${cmd}
  1227. WORKING_DIRECTORY ${binary_dir}
  1228. DEPENDEES update patch
  1229. DEPENDS ${file_deps}
  1230. ${log}
  1231. )
  1232. endfunction(_ep_add_configure_command)
  1233. function(_ep_add_build_command name)
  1234. ExternalProject_Get_Property(${name} binary_dir)
  1235. get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET)
  1236. if(cmd_set)
  1237. get_property(cmd TARGET ${name} PROPERTY _EP_BUILD_COMMAND)
  1238. else()
  1239. _ep_get_build_command(${name} BUILD cmd)
  1240. endif()
  1241. get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD)
  1242. if(log)
  1243. set(log LOG 1)
  1244. else()
  1245. set(log "")
  1246. endif()
  1247. ExternalProject_Add_Step(${name} build
  1248. COMMAND ${cmd}
  1249. WORKING_DIRECTORY ${binary_dir}
  1250. DEPENDEES configure
  1251. ${log}
  1252. )
  1253. endfunction(_ep_add_build_command)
  1254. function(_ep_add_install_command name)
  1255. ExternalProject_Get_Property(${name} binary_dir)
  1256. get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET)
  1257. if(cmd_set)
  1258. get_property(cmd TARGET ${name} PROPERTY _EP_INSTALL_COMMAND)
  1259. else()
  1260. _ep_get_build_command(${name} INSTALL cmd)
  1261. endif()
  1262. get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL)
  1263. if(log)
  1264. set(log LOG 1)
  1265. else()
  1266. set(log "")
  1267. endif()
  1268. ExternalProject_Add_Step(${name} install
  1269. COMMAND ${cmd}
  1270. WORKING_DIRECTORY ${binary_dir}
  1271. DEPENDEES build
  1272. ${log}
  1273. )
  1274. endfunction(_ep_add_install_command)
  1275. function(_ep_add_test_command name)
  1276. ExternalProject_Get_Property(${name} binary_dir)
  1277. get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
  1278. get_property(after TARGET ${name} PROPERTY _EP_TEST_AFTER_INSTALL)
  1279. get_property(cmd_set TARGET ${name} PROPERTY _EP_TEST_COMMAND SET)
  1280. # Only actually add the test step if one of the test related properties is
  1281. # explicitly set. (i.e. the test step is omitted unless requested...)
  1282. #
  1283. if(cmd_set OR before OR after)
  1284. if(cmd_set)
  1285. get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND)
  1286. else()
  1287. _ep_get_build_command(${name} TEST cmd)
  1288. endif()
  1289. if(before)
  1290. set(dep_args DEPENDEES build DEPENDERS install)
  1291. else()
  1292. set(dep_args DEPENDEES install)
  1293. endif()
  1294. get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST)
  1295. if(log)
  1296. set(log LOG 1)
  1297. else()
  1298. set(log "")
  1299. endif()
  1300. ExternalProject_Add_Step(${name} test
  1301. COMMAND ${cmd}
  1302. WORKING_DIRECTORY ${binary_dir}
  1303. ${dep_args}
  1304. ${log}
  1305. )
  1306. endif()
  1307. endfunction(_ep_add_test_command)
  1308. function(ExternalProject_Add name)
  1309. _ep_get_configuration_subdir_suffix(cfgdir)
  1310. # Add a custom target for the external project.
  1311. set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
  1312. set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
  1313. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
  1314. set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
  1315. _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
  1316. _ep_set_directories(${name})
  1317. _ep_get_step_stampfile(${name} "done" done_stamp_file)
  1318. _ep_get_step_stampfile(${name} "install" install_stamp_file)
  1319. # The 'complete' step depends on all other steps and creates a
  1320. # 'done' mark. A dependent external project's 'configure' step
  1321. # depends on the 'done' mark so that it rebuilds when this project
  1322. # rebuilds. It is important that 'done' is not the output of any
  1323. # custom command so that CMake does not propagate build rules to
  1324. # other external project targets, which may cause problems during
  1325. # parallel builds. However, the Ninja generator needs to see the entire
  1326. # dependency graph, and can cope with custom commands belonging to
  1327. # multiple targets, so we add the 'done' mark as an output for Ninja only.
  1328. set(complete_outputs ${complete_stamp_file})
  1329. if(${CMAKE_GENERATOR} MATCHES "Ninja")
  1330. set(complete_outputs ${complete_outputs} ${done_stamp_file})
  1331. endif()
  1332. add_custom_command(
  1333. OUTPUT ${complete_outputs}
  1334. COMMENT "Completed '${name}'"
  1335. COMMAND ${CMAKE_COMMAND} -E make_directory ${cmf_dir}${cfgdir}
  1336. COMMAND ${CMAKE_COMMAND} -E touch ${complete_stamp_file}
  1337. COMMAND ${CMAKE_COMMAND} -E touch ${done_stamp_file}
  1338. DEPENDS ${install_stamp_file}
  1339. VERBATIM
  1340. )
  1341. # Depend on other external projects (target-level).
  1342. get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
  1343. foreach(arg IN LISTS deps)
  1344. add_dependencies(${name} ${arg})
  1345. endforeach()
  1346. # Set up custom build steps based on the target properties.
  1347. # Each step depends on the previous one.
  1348. #
  1349. # The target depends on the output of the final step.
  1350. # (Already set up above in the DEPENDS of the add_custom_target command.)
  1351. #
  1352. _ep_add_mkdir_command(${name})
  1353. _ep_add_download_command(${name})
  1354. _ep_add_update_command(${name})
  1355. _ep_add_patch_command(${name})
  1356. _ep_add_configure_command(${name})
  1357. _ep_add_build_command(${name})
  1358. _ep_add_install_command(${name})
  1359. # Test is special in that it might depend on build, or it might depend
  1360. # on install.
  1361. #
  1362. _ep_add_test_command(${name})
  1363. endfunction(ExternalProject_Add)