[Cmake-commits] [cmake-commits] david.cole committed ExternalProject.cmake 1.7 1.8

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Sep 8 15:37:17 EDT 2009


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv28105/Modules

Modified Files:
	ExternalProject.cmake 
Log Message:
Use more verbose/descriptive names for the "public API" functions in the ExternalProject.cmake module. Follow the cmake function naming convention, using a ModuleFileName_ prefix. Locate stamp files under a CMAKE_CFG_INTDIR subdir of the stamp dir so that debug and release builds have separate stamp files for Visual Studio builds. If no CMAKE_GENERATOR argument is given to ExternalProject_Add, default to using the parent project's cmake generator.


Index: ExternalProject.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/ExternalProject.cmake,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** ExternalProject.cmake	3 Sep 2009 16:11:13 -0000	1.7
--- ExternalProject.cmake	8 Sep 2009 19:37:14 -0000	1.8
***************
*** 1,7 ****
  # - Create custom targets to build projects in external trees
! # The 'ep_add' function creates a custom target to drive download,
! # update/patch, configure, build, and install steps of an external
! # project:
! #  ep_add(<name>                 # Name for custom target
  #    [DEPENDS projects...]       # Targets on which the project depends
  #    [PREFIX dir]                # Root dir for entire project
--- 1,7 ----
  # - Create custom targets to build projects in external trees
! # The 'ExternalProject_Add' function creates a custom target to drive
! # download, update/patch, configure, build, install and test steps of an
! # external project:
! #  ExternalProject_Add(<name>    # Name for custom target
  #    [DEPENDS projects...]       # Targets on which the project depends
  #    [PREFIX dir]                # Root dir for entire project
***************
*** 41,46 ****
  # The *_DIR options specify directories for the project, with default
  # directories computed as follows.
! # If the PREFIX option is given to ep_add() or the EP_PREFIX directory
! # property is set, then an external project is built and installed
  # under the specified prefix:
  #   TMP_DIR      = <prefix>/tmp
--- 41,46 ----
  # The *_DIR options specify directories for the project, with default
  # directories computed as follows.
! # If the PREFIX option is given to ExternalProject_Add() or the EP_PREFIX
! # directory property is set, then an external project is built and installed
  # under the specified prefix:
  #   TMP_DIR      = <prefix>/tmp
***************
*** 61,65 ****
  # is to set PREFIX to "<name>-prefix".
  # Relative paths are interpreted with respect to the build directory
! # corresponding to the source directory in which ep_add is invoked.
  #
  # If SOURCE_DIR is explicitly set to an existing directory the project
--- 61,66 ----
  # is to set PREFIX to "<name>-prefix".
  # Relative paths are interpreted with respect to the build directory
! # corresponding to the source directory in which ExternalProject_Add is
! # invoked.
  #
  # If SOURCE_DIR is explicitly set to an existing directory the project
***************
*** 70,75 ****
  # or refer to a remote tarball (e.g. http://.../src.tgz).
  #
! # The 'ep_add_step' function adds a custom steps to an external project:
! #  ep_add_step(<name> <step> # Names of project and custom step
  #    [COMMAND cmd...]        # Command line invoked by this step
  #    [COMMENT "text..."]     # Text printed when step executes
--- 71,77 ----
  # or refer to a remote tarball (e.g. http://.../src.tgz).
  #
! # The 'ExternalProject_Add_Step' function adds a custom step to an external
! # project:
! #  ExternalProject_Add_Step(<name> <step> # Names of project and custom step
  #    [COMMAND cmd...]        # Command line invoked by this step
  #    [COMMENT "text..."]     # Text printed when step executes
***************
*** 88,106 ****
  # with corresponding property values.
  #
! # The 'ep_get' function retrieves external project target properties:
! #  ep_get(<name> [prop1 [prop2 [...]]])
  # It stores property values in variables of the same name.
! # Property names correspond to the keyword argument names of 'ep_add'.
  
  
  # Pre-compute a regex to match documented keywords for each command.
  file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 100
!      REGEX "^#  (  \\[[A-Z_]+ [^]]*\\] +#.*$|[a-z_]+\\()")
  foreach(line IN LISTS lines)
!   if("${line}" MATCHES "^#  [a-z_]+\\(")
      if(_ep_func)
        set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
      endif()
!     string(REGEX REPLACE "^#  ([a-z_]+)\\(.*" "\\1" _ep_func "${line}")
      #message("function [${_ep_func}]")
      set(_ep_keywords_${_ep_func} "^(")
--- 90,110 ----
  # with corresponding property values.
  #
! # The 'ExternalProject_Get_Property' function retrieves external project
! # target properties:
! #  ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]])
  # It stores property values in variables of the same name.
! # Property names correspond to the keyword argument names of
! # 'ExternalProject_Add'.
  
  
  # Pre-compute a regex to match documented keywords for each command.
  file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 100
!      REGEX "^#  (  \\[[A-Z_]+ [^]]*\\] +#.*$|[A-Za-z_]+\\()")
  foreach(line IN LISTS lines)
!   if("${line}" MATCHES "^#  [A-Za-z_]+\\(")
      if(_ep_func)
        set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
      endif()
!     string(REGEX REPLACE "^#  ([A-Za-z_]+)\\(.*" "\\1" _ep_func "${line}")
      #message("function [${_ep_func}]")
      set(_ep_keywords_${_ep_func} "^(")
***************
*** 175,179 ****
    BRIEF_DOCS "Base directory for External Project storage."
    FULL_DOCS
!   "See documentation of the ep_add() function in the "
    "ExternalProject module."
    )
--- 179,183 ----
    BRIEF_DOCS "Base directory for External Project storage."
    FULL_DOCS
!   "See documentation of the ExternalProject_Add() function in the "
    "ExternalProject module."
    )
***************
*** 182,186 ****
    BRIEF_DOCS "Top prefix for External Project storage."
    FULL_DOCS
!   "See documentation of the ep_add() function in the "
    "ExternalProject module."
    )
--- 186,190 ----
    BRIEF_DOCS "Top prefix for External Project storage."
    FULL_DOCS
!   "See documentation of the ExternalProject_Add() function in the "
    "ExternalProject module."
    )
***************
*** 372,376 ****
  
  
! function(ep_get name)
    foreach(var ${ARGN})
      string(TOUPPER "${var}" VAR)
--- 376,380 ----
  
  
! function(ExternalProject_Get_Property name)
    foreach(var ${ARGN})
      string(TOUPPER "${var}" VAR)
***************
*** 381,385 ****
      set(${var} "${${var}}" PARENT_SCOPE)
    endforeach()
! endfunction(ep_get)
  
  
--- 385,389 ----
      set(${var} "${${var}}" PARENT_SCOPE)
    endforeach()
! endfunction(ExternalProject_Get_Property)
  
  
***************
*** 470,482 ****
  
  
! function(ep_add_step name step)
    set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
!   ep_get(${name} stamp_dir)
  
    add_custom_command(APPEND
!     OUTPUT ${cmf_dir}/${name}-complete
!     DEPENDS ${stamp_dir}/${name}-${step}
      )
!   _ep_parse_arguments(ep_add_step
                         ${name} _EP_${step}_ "${ARGN}")
  
--- 474,486 ----
  
  
! function(ExternalProject_Add_Step name step)
    set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
!   ExternalProject_Get_Property(${name} stamp_dir)
  
    add_custom_command(APPEND
!     OUTPUT ${cmf_dir}/${CMAKE_CFG_INTDIR}/${name}-complete
!     DEPENDS ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${step}
      )
!   _ep_parse_arguments(ExternalProject_Add_Step
                         ${name} _EP_${step}_ "${ARGN}")
  
***************
*** 485,490 ****
    foreach(depender IN LISTS dependers)
      add_custom_command(APPEND
!       OUTPUT ${stamp_dir}/${name}-${depender}
!       DEPENDS ${stamp_dir}/${name}-${step}
        )
    endforeach()
--- 489,494 ----
    foreach(depender IN LISTS dependers)
      add_custom_command(APPEND
!       OUTPUT ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${depender}
!       DEPENDS ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${step}
        )
    endforeach()
***************
*** 496,500 ****
    get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES)
    foreach(dependee IN LISTS dependees)
!     list(APPEND depends ${stamp_dir}/${name}-${dependee})
    endforeach()
  
--- 500,504 ----
    get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES)
    foreach(dependee IN LISTS dependees)
!     list(APPEND depends ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${dependee})
    endforeach()
  
***************
*** 533,544 ****
    get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS)
    if(always)
!     set_property(SOURCE ${stamp_dir}/${name}-${step} PROPERTY SYMBOLIC 1)
      set(touch)
    else()
!     set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}/${name}-${step})
    endif()
  
    add_custom_command(
!     OUTPUT ${stamp_dir}/${name}-${step}
      COMMENT ${comment}
      COMMAND ${command}
--- 537,548 ----
    get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS)
    if(always)
!     set_property(SOURCE ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${step} PROPERTY SYMBOLIC 1)
      set(touch)
    else()
!     set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${step})
    endif()
  
    add_custom_command(
!     OUTPUT ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-${step}
      COMMENT ${comment}
      COMMAND ${command}
***************
*** 548,558 ****
      VERBATIM
      )
! endfunction(ep_add_step)
  
  
  function(_ep_add_mkdir_command name)
!   ep_get(${name}
      source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
!   ep_add_step(${name} mkdir
      COMMENT "Creating directories for '${name}'"
      COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
--- 552,562 ----
      VERBATIM
      )
! endfunction(ExternalProject_Add_Step)
  
  
  function(_ep_add_mkdir_command name)
!   ExternalProject_Get_Property(${name}
      source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
!   ExternalProject_Add_Step(${name} mkdir
      COMMENT "Creating directories for '${name}'"
      COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
***************
*** 567,571 ****
  
  function(_ep_add_download_command name)
!   ep_get(${name} source_dir stamp_dir download_dir tmp_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET)
--- 571,575 ----
  
  function(_ep_add_download_command name)
!   ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET)
***************
*** 673,677 ****
    endif()
  
!   ep_add_step(${name} download
      COMMENT ${comment}
      COMMAND ${cmd}
--- 677,681 ----
    endif()
  
!   ExternalProject_Add_Step(${name} download
      COMMENT ${comment}
      COMMAND ${cmd}
***************
*** 684,688 ****
  
  function(_ep_add_update_command name)
!   ep_get(${name} source_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET)
--- 688,692 ----
  
  function(_ep_add_update_command name)
!   ExternalProject_Get_Property(${name} source_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET)
***************
*** 717,721 ****
    endif()
  
!   ep_add_step(${name} update
      COMMENT ${comment}
      COMMAND ${cmd}
--- 721,725 ----
    endif()
  
!   ExternalProject_Add_Step(${name} update
      COMMENT ${comment}
      COMMAND ${cmd}
***************
*** 728,732 ****
  
  function(_ep_add_patch_command name)
!   ep_get(${name} source_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
--- 732,736 ----
  
  function(_ep_add_patch_command name)
!   ExternalProject_Get_Property(${name} source_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET)
***************
*** 739,743 ****
    endif()
  
!   ep_add_step(${name} patch
      COMMAND ${cmd}
      WORKING_DIRECTORY ${work_dir}
--- 743,747 ----
    endif()
  
!   ExternalProject_Add_Step(${name} patch
      COMMAND ${cmd}
      WORKING_DIRECTORY ${work_dir}
***************
*** 749,753 ****
  # TODO: Make sure external projects use the proper compiler
  function(_ep_add_configure_command name)
!   ep_get(${name} source_dir binary_dir)
  
    # Depend on other external projects (file-level).
--- 753,757 ----
  # TODO: Make sure external projects use the proper compiler
  function(_ep_add_configure_command name)
!   ExternalProject_Get_Property(${name} source_dir binary_dir)
  
    # Depend on other external projects (file-level).
***************
*** 756,760 ****
    foreach(dep IN LISTS deps)
      get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
!     list(APPEND file_deps ${dep_stamp_dir}/${dep}-done)
    endforeach()
  
--- 760,764 ----
    foreach(dep IN LISTS deps)
      get_property(dep_stamp_dir TARGET ${dep} PROPERTY _EP_STAMP_DIR)
!     list(APPEND file_deps ${dep_stamp_dir}/${CMAKE_CFG_INTDIR}/${dep}-done)
    endforeach()
  
***************
*** 776,783 ****
      if(cmake_generator)
        list(APPEND cmd "-G${cmake_generator}" "${source_dir}")
      endif()
    endif()
  
!   ep_add_step(${name} configure
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
--- 780,789 ----
      if(cmake_generator)
        list(APPEND cmd "-G${cmake_generator}" "${source_dir}")
+     else()
+       list(APPEND cmd "-G${CMAKE_GENERATOR}" "${source_dir}")
      endif()
    endif()
  
!   ExternalProject_Add_Step(${name} configure
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
***************
*** 789,793 ****
  
  function(_ep_add_build_command name)
!   ep_get(${name} binary_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET)
--- 795,799 ----
  
  function(_ep_add_build_command name)
!   ExternalProject_Get_Property(${name} binary_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET)
***************
*** 798,802 ****
    endif()
  
!   ep_add_step(${name} build
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
--- 804,808 ----
    endif()
  
!   ExternalProject_Add_Step(${name} build
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
***************
*** 807,811 ****
  
  function(_ep_add_install_command name)
!   ep_get(${name} binary_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET)
--- 813,817 ----
  
  function(_ep_add_install_command name)
!   ExternalProject_Get_Property(${name} binary_dir)
  
    get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET)
***************
*** 816,820 ****
    endif()
  
!   ep_add_step(${name} install
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
--- 822,826 ----
    endif()
  
!   ExternalProject_Add_Step(${name} install
      COMMAND ${cmd}
      WORKING_DIRECTORY ${binary_dir}
***************
*** 825,829 ****
  
  function(_ep_add_test_command name)
!   ep_get(${name} binary_dir)
  
    get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
--- 831,835 ----
  
  function(_ep_add_test_command name)
!   ExternalProject_Get_Property(${name} binary_dir)
  
    get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
***************
*** 847,851 ****
      endif()
  
!     ep_add_step(${name} test
        COMMAND ${cmd}
        WORKING_DIRECTORY ${binary_dir}
--- 853,857 ----
      endif()
  
!     ExternalProject_Add_Step(${name} test
        COMMAND ${cmd}
        WORKING_DIRECTORY ${binary_dir}
***************
*** 856,867 ****
  
  
! function(ep_add name)
    # Add a custom target for the external project.
    set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
!   add_custom_target(${name} ALL DEPENDS ${cmf_dir}/${name}-complete)
    set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
!   _ep_parse_arguments(ep_add ${name} _EP_ "${ARGN}")
    _ep_set_directories(${name})
!   ep_get(${name} stamp_dir)
  
    # The 'complete' step depends on all other steps and creates a
--- 862,873 ----
  
  
! function(ExternalProject_Add name)
    # Add a custom target for the external project.
    set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
!   add_custom_target(${name} ALL DEPENDS ${cmf_dir}/${CMAKE_CFG_INTDIR}/${name}-complete)
    set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
!   _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
    _ep_set_directories(${name})
!   ExternalProject_Get_Property(${name} stamp_dir)
  
    # The 'complete' step depends on all other steps and creates a
***************
*** 872,880 ****
    # other external project targets.
    add_custom_command(
!     OUTPUT ${cmf_dir}/${name}-complete
      COMMENT "Completed '${name}'"
!     COMMAND ${CMAKE_COMMAND} -E touch ${cmf_dir}/${name}-complete
!     COMMAND ${CMAKE_COMMAND} -E touch ${stamp_dir}/${name}-done
!     DEPENDS ${stamp_dir}/${name}-install
      VERBATIM
      )
--- 878,886 ----
    # other external project targets.
    add_custom_command(
!     OUTPUT ${cmf_dir}/${CMAKE_CFG_INTDIR}/${name}-complete
      COMMENT "Completed '${name}'"
!     COMMAND ${CMAKE_COMMAND} -E touch ${cmf_dir}/${CMAKE_CFG_INTDIR}/${name}-complete
!     COMMAND ${CMAKE_COMMAND} -E touch ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-done
!     DEPENDS ${stamp_dir}/${CMAKE_CFG_INTDIR}/${name}-install
      VERBATIM
      )
***************
*** 905,907 ****
    #
    _ep_add_test_command(${name})
! endfunction(ep_add)
--- 911,913 ----
    #
    _ep_add_test_command(${name})
! endfunction(ExternalProject_Add)



More information about the Cmake-commits mailing list