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

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Sep 3 12:11:16 EDT 2009


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

Modified Files:
	ExternalProject.cmake 
Log Message:
Add test step to ExternalProject builds. Rename SVN_TAG to SVN_REVISION since it is a more accurate name.


Index: ExternalProject.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/ExternalProject.cmake,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** ExternalProject.cmake	26 Aug 2009 10:52:43 -0000	1.6
--- ExternalProject.cmake	3 Sep 2009 16:11:13 -0000	1.7
***************
*** 16,20 ****
  #    [CVS_TAG tag]               # Tag to checkout from CVS repo
  #    [SVN_REPOSITORY url]        # URL of Subversion repo
! #    [SVN_TAG tag]               # Tag to checkout from Subversion repo
  #    [URL /.../src.tgz]          # Full path or URL of source
  #   #--Update/Patch step----------
--- 16,20 ----
  #    [CVS_TAG tag]               # Tag to checkout from CVS repo
  #    [SVN_REPOSITORY url]        # URL of Subversion repo
! #    [SVN_REVISION rev]          # Revision to checkout from Subversion repo
  #    [URL /.../src.tgz]          # Full path or URL of source
  #   #--Update/Patch step----------
***************
*** 34,37 ****
--- 34,41 ----
  #    [INSTALL_DIR dir]           # Installation prefix
  #    [INSTALL_COMMAND cmd...]    # Command to drive install after build
+ #   #--Test step---------------
+ #    [TEST_BEFORE_INSTALL 1]     # Add test step executed before install step
+ #    [TEST_AFTER_INSTALL 1]      # Add test step executed after install step
+ #    [TEST_COMMAND cmd...]       # Command to drive test
  #    )
  # The *_DIR options specify directories for the project, with default
***************
*** 421,424 ****
--- 425,431 ----
            set(args install)
          endif()
+         if(step STREQUAL "TEST")
+           set(args test)
+         endif()
        else()
          # Drive the project with "cmake --build".
***************
*** 433,443 ****
            list(APPEND args --target install)
          endif()
        endif()
      else() # if(cfg_cmd_id STREQUAL "configure")
!       # Non-CMake project.  Guess "make" and "make install".
        set(cmd "make")
        if(step STREQUAL "INSTALL")
          set(args install)
        endif()
      endif()
  
--- 440,458 ----
            list(APPEND args --target install)
          endif()
+         # But for "TEST" drive the project with corresponding "ctest".
+         if(step STREQUAL "TEST")
+           string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
+           set(args "")
+         endif()
        endif()
      else() # if(cfg_cmd_id STREQUAL "configure")
!       # Non-CMake project.  Guess "make" and "make install" and "make test".
        set(cmd "make")
        if(step STREQUAL "INSTALL")
          set(args install)
        endif()
+       if(step STREQUAL "TEST")
+         set(args test)
+       endif()
      endif()
  
***************
*** 602,610 ****
      endif()
  
!     get_property(svn_tag TARGET ${name} PROPERTY _EP_SVN_TAG)
  
      set(repository ${svn_repository})
      set(module)
!     set(tag ${svn_tag})
      configure_file(
        "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
--- 617,625 ----
      endif()
  
!     get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
  
      set(repository ${svn_repository})
      set(module)
!     set(tag ${svn_revision})
      configure_file(
        "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
***************
*** 616,620 ****
      get_filename_component(work_dir "${source_dir}" PATH)
      set(comment "Performing download step (SVN checkout) for '${name}'")
!     set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_tag} ${src_name})
      list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
    elseif(url)
--- 631,635 ----
      get_filename_component(work_dir "${source_dir}" PATH)
      set(comment "Performing download step (SVN checkout) for '${name}'")
!     set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} ${src_name})
      list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
    elseif(url)
***************
*** 697,702 ****
      set(work_dir ${source_dir})
      set(comment "Performing update step (SVN update) for '${name}'")
!     get_property(svn_tag TARGET ${name} PROPERTY _EP_SVN_TAG)
!     set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_tag})
      set(always 1)
    endif()
--- 712,717 ----
      set(work_dir ${source_dir})
      set(comment "Performing update step (SVN update) for '${name}'")
!     get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION)
!     set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision})
      set(always 1)
    endif()
***************
*** 782,785 ****
--- 797,801 ----
      _ep_get_build_command(${name} BUILD cmd)
    endif()
+ 
    ep_add_step(${name} build
      COMMAND ${cmd}
***************
*** 799,802 ****
--- 815,819 ----
      _ep_get_build_command(${name} INSTALL cmd)
    endif()
+ 
    ep_add_step(${name} install
      COMMAND ${cmd}
***************
*** 807,810 ****
--- 824,859 ----
  
  
+ function(_ep_add_test_command name)
+   ep_get(${name} binary_dir)
+ 
+   get_property(before TARGET ${name} PROPERTY _EP_TEST_BEFORE_INSTALL)
+   get_property(after TARGET ${name} PROPERTY _EP_TEST_AFTER_INSTALL)
+   get_property(cmd_set TARGET ${name} PROPERTY _EP_TEST_COMMAND SET)
+ 
+   # Only actually add the test step if one of the test related properties is
+   # explicitly set. (i.e. the test step is omitted unless requested...)
+   #
+   if(cmd_set OR before OR after)
+     if(cmd_set)
+       get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND)
+     else()
+       _ep_get_build_command(${name} TEST cmd)
+     endif()
+ 
+     if(before)
+       set(dep_args DEPENDEES build DEPENDERS install)
+     else()
+       set(dep_args DEPENDEES install)
+     endif()
+ 
+     ep_add_step(${name} test
+       COMMAND ${cmd}
+       WORKING_DIRECTORY ${binary_dir}
+       ${dep_args}
+       )
+   endif()
+ endfunction(_ep_add_test_command)
+ 
+ 
  function(ep_add name)
    # Add a custom target for the external project.
***************
*** 851,853 ****
--- 900,907 ----
    _ep_add_build_command(${name})
    _ep_add_install_command(${name})
+ 
+   # Test is special in that it might depend on build, or it might depend
+   # on install.
+   #
+   _ep_add_test_command(${name})
  endfunction(ep_add)



More information about the Cmake-commits mailing list