diff options
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r-- | Modules/ExternalProject.cmake | 213 |
1 files changed, 119 insertions, 94 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 4551cc8..a0f731c 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -65,9 +65,18 @@ Create custom targets to build projects in external trees ``GIT_SUBMODULES <module>...`` Git submodules that shall be updated, all if empty ``GIT_SHALLOW 1`` - Tell Git to clone with ``--depth 1``. Use when ``GIT_TAG`` is not + Tell Git to clone with ``--depth 1``. Use when ``GIT_TAG`` is not specified or when it names a branch in order to download only the tip of the branch without the rest of its history. + ``GIT_PROGRESS 1`` + Tell Git to clone with ``--progress``. For large projects, the clone step + does not output anything which can make the build appear to have stalled. + This option forces Git to output progress information during the clone step + so that forward progress is indicated. + ``GIT_CONFIG <option>...`` + Tell Git to clone with ``--config <option>``. Use additional configuration + parameters when cloning the project (``key=value`` as expected by ``git + config``). ``HG_REPOSITORY <url>`` URL of mercurial repo ``HG_TAG <tag>`` @@ -418,7 +427,7 @@ if(_ep_func) endif() # Save regex matching supported hash algorithm names. -set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512") +set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512") set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$") set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}") @@ -509,7 +518,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED "ExternalProject module." ) -function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow src_name work_dir gitclone_infofile gitclone_stampfile tls_verify) +function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify) if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10) set(git_clone_shallow_options "--depth 1 --no-single-branch") else() @@ -555,6 +564,16 @@ if(git_shallow) list(APPEND git_clone_options ${git_clone_shallow_options}) endif() +set(git_progress \"${git_progress}\") +if(git_progress) + list(APPEND git_clone_options --progress) +endif() + +set(git_config \"${git_config}\") +foreach(config IN LISTS git_config) + list(APPEND git_clone_options --config \${config}) +endforeach() + # try the clone 3 times incase there is an odd git clone issue set(error_code 1) set(number_of_tries 0) @@ -1180,6 +1199,7 @@ function(_ep_write_initial_cache target_name script_filename script_initial_cach # Write out values into an initial cache, that will be passed to CMake with -C # Replace location tags. _ep_replace_location_tags(${target_name} script_initial_cache) + _ep_replace_location_tags(${target_name} script_filename) # Write out the initial cache file to the location specified. file(GENERATE OUTPUT "${script_filename}" CONTENT "${script_initial_cache}") endfunction() @@ -1225,87 +1245,84 @@ endfunction() function(_ep_get_build_command name step cmd_var) - set(cmd "${${cmd_var}}") - if(NOT cmd) - set(args) - _ep_get_configure_command_id(${name} cfg_cmd_id) - if(cfg_cmd_id STREQUAL "cmake") - # CMake project. Select build command based on generator. - get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - if("${CMAKE_GENERATOR}" MATCHES "Make" AND - ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) - # The project uses the same Makefile generator. Use recursive make. - set(cmd "$(MAKE)") - if(step STREQUAL "INSTALL") - set(args install) - endif() - if("x${step}x" STREQUAL "xTESTx") - set(args test) - endif() - else() - # Drive the project with "cmake --build". - get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) - if(cmake_command) - set(cmd "${cmake_command}") - else() - set(cmd "${CMAKE_COMMAND}") - endif() - set(args --build ".") - if(CMAKE_CONFIGURATION_TYPES) - if (CMAKE_CFG_INTDIR AND - NOT CMAKE_CFG_INTDIR STREQUAL "." AND - NOT CMAKE_CFG_INTDIR MATCHES "\\$") - # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value - # provided by multi-configuration generators. Some projects were - # taking advantage of that undocumented implementation detail to - # specify a specific configuration here. They should use - # BUILD_COMMAND to change the default command instead, but for - # compatibility honor the value. - set(config ${CMAKE_CFG_INTDIR}) - message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" - "To get a non-default build command, use the BUILD_COMMAND option.") - else() - set(config $<CONFIG>) - endif() - list(APPEND args --config ${config}) - endif() - if(step STREQUAL "INSTALL") - list(APPEND args --target install) - endif() - # But for "TEST" drive the project with corresponding "ctest". - if("x${step}x" STREQUAL "xTESTx") - string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") - set(args "") - if(CMAKE_CONFIGURATION_TYPES) - list(APPEND args -C ${config}) - endif() - endif() + set(cmd "") + set(args) + _ep_get_configure_command_id(${name} cfg_cmd_id) + if(cfg_cmd_id STREQUAL "cmake") + # CMake project. Select build command based on generator. + get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) + if("${CMAKE_GENERATOR}" MATCHES "Make" AND + ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) + # The project uses the same Makefile generator. Use recursive make. + set(cmd "$(MAKE)") + if(step STREQUAL "INSTALL") + set(args install) + endif() + if("x${step}x" STREQUAL "xTESTx") + set(args test) endif() else() - # Non-CMake project. Guess "make" and "make install" and "make test". - if("${CMAKE_GENERATOR}" MATCHES "Makefiles") - # Try to get the parallel arguments - set(cmd "$(MAKE)") + # Drive the project with "cmake --build". + get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) + if(cmake_command) + set(cmd "${cmake_command}") else() - set(cmd "make") + set(cmd "${CMAKE_COMMAND}") + endif() + set(args --build ".") + if(CMAKE_CONFIGURATION_TYPES) + if (CMAKE_CFG_INTDIR AND + NOT CMAKE_CFG_INTDIR STREQUAL "." AND + NOT CMAKE_CFG_INTDIR MATCHES "\\$") + # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value + # provided by multi-configuration generators. Some projects were + # taking advantage of that undocumented implementation detail to + # specify a specific configuration here. They should use + # BUILD_COMMAND to change the default command instead, but for + # compatibility honor the value. + set(config ${CMAKE_CFG_INTDIR}) + message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" + "To get a non-default build command, use the BUILD_COMMAND option.") + else() + set(config $<CONFIG>) + endif() + list(APPEND args --config ${config}) endif() if(step STREQUAL "INSTALL") - set(args install) + list(APPEND args --target install) endif() + # But for "TEST" drive the project with corresponding "ctest". if("x${step}x" STREQUAL "xTESTx") - set(args test) + string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") + set(args "") + if(CMAKE_CONFIGURATION_TYPES) + list(APPEND args -C ${config}) + endif() endif() endif() - - # Use user-specified arguments instead of default arguments, if any. - get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET) - if(have_args) - get_target_property(args ${name} _EP_${step}_ARGS) + else() + # Non-CMake project. Guess "make" and "make install" and "make test". + if("${CMAKE_GENERATOR}" MATCHES "Makefiles") + # Try to get the parallel arguments + set(cmd "$(MAKE)") + else() + set(cmd "make") + endif() + if(step STREQUAL "INSTALL") + set(args install) endif() + if("x${step}x" STREQUAL "xTESTx") + set(args test) + endif() + endif() - list(APPEND cmd ${args}) + # Use user-specified arguments instead of default arguments, if any. + get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET) + if(have_args) + get_target_property(args ${name} _EP_${step}_ARGS) endif() + list(APPEND cmd ${args}) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction() @@ -1800,6 +1817,8 @@ function(_ep_add_download_command name) set(tls_verify "${CMAKE_TLS_VERIFY}") endif() get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW) + get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS) + get_property(git_config TARGET ${name} PROPERTY _EP_GIT_CONFIG) # For the download step, and the git clone operation, only the repository # should be recorded in a configured RepositoryInfo file. If the repo @@ -1824,7 +1843,7 @@ function(_ep_add_download_command name) # The script will delete the source directory and then call git clone. # _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} - ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" ${src_name} ${work_dir} + ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir} ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}" ) set(comment "Performing download step (git clone) for '${name}'") @@ -2143,12 +2162,12 @@ Update to Mercurial >= 2.1.1. ${uses_terminal} ) - if(always AND update_disconnected) + if(update_disconnected) _ep_get_step_stampfile(${name} skip-update skip-update_stamp_file) string(REPLACE "Performing" "Skipping" comment "${comment}") ExternalProject_Add_Step(${name} skip-update COMMENT ${comment} - ALWAYS 1 + ALWAYS ${always} EXCLUDE_FROM_MAIN 1 WORKING_DIRECTORY ${work_dir} DEPENDEES download @@ -2181,24 +2200,7 @@ function(_ep_add_patch_command name) endfunction() -# TODO: Make sure external projects use the proper compiler -function(_ep_add_configure_command name) - ExternalProject_Get_Property(${name} source_dir source_subdir binary_dir tmp_dir) - - # Depend on other external projects (file-level). - set(file_deps) - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) - foreach(dep IN LISTS deps) - get_property(dep_type TARGET ${dep} PROPERTY TYPE) - if(dep_type STREQUAL "UTILITY") - get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) - if(is_ep) - _ep_get_step_stampfile(${dep} "done" done_stamp_file) - list(APPEND file_deps ${done_stamp_file}) - endif() - endif() - endforeach() - +function(_ep_extract_configure_command var name) get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET) if(cmd_set) get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND) @@ -2219,7 +2221,7 @@ function(_ep_add_configure_command name) get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS) if(cmake_cache_args OR cmake_cache_default_args) - set(_ep_cache_args_script "${tmp_dir}/${name}-cache-$<CONFIG>.cmake") + set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") if(cmake_cache_args) _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) endif() @@ -2261,9 +2263,32 @@ function(_ep_add_configure_command name) endif() endif() - list(APPEND cmd "${source_dir}${source_subdir}") + list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>") endif() + set("${var}" "${cmd}" PARENT_SCOPE) +endfunction() + +# TODO: Make sure external projects use the proper compiler +function(_ep_add_configure_command name) + ExternalProject_Get_Property(${name} binary_dir tmp_dir) + + # Depend on other external projects (file-level). + set(file_deps) + get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + foreach(dep IN LISTS deps) + get_property(dep_type TARGET ${dep} PROPERTY TYPE) + if(dep_type STREQUAL "UTILITY") + get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) + if(is_ep) + _ep_get_step_stampfile(${dep} "done" done_stamp_file) + list(APPEND file_deps ${done_stamp_file}) + endif() + endif() + endforeach() + + _ep_extract_configure_command(cmd ${name}) + # If anything about the configure command changes, (command itself, cmake # used, cmake args or cmake generator) then re-run the configure step. # Fixes issue https://gitlab.kitware.com/cmake/cmake/issues/10258 |