Imported Upstream version 2.8.11.2
[platform/upstream/cmake.git] / Tests / ExternalProject / CMakeLists.txt
index 7a76261..602ff0f 100644 (file)
@@ -6,6 +6,7 @@ include(ExternalProject)
 find_package(CVS)
 find_package(Subversion)
 find_package(Git)
+find_package(Hg)
 
 option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON)
 if(ExternalProjectTest_USE_FOLDERS)
@@ -49,6 +50,8 @@ if(NOT DEFINED can_build_tutorial_step5)
   endif()
 endif()
 
+add_custom_target(NonExternalProjectTarget
+  COMMAND ${CMAKE_COMMAND} -E echo NonExternalProjectTarget)
 
 # Empty projects that test all the known ExternalProject_Add argument key words:
 #
@@ -93,7 +96,7 @@ ExternalProject_Add(${proj}
   CVS_REPOSITORY ""
   CVS_MODULE ""
   CVS_TAG ""
-  DEPENDS "MinimalNoOpProject"
+  DEPENDS "MinimalNoOpProject" NonExternalProjectTarget
   DOWNLOAD_COMMAND ""
   INSTALL_COMMAND ""
   PATCH_COMMAND ""
@@ -188,7 +191,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ")
 set(proj TutorialStep1-LocalNoDirTGZ)
 ExternalProject_Add(${proj}
   URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz"
-  URL_MD5 0b8182edcecdf40bf1c9d71d7d259f78
+  URL_HASH SHA256=496229e2a5ed620a37c385ad9406004a18026beab8b55dd2c4565d4b7f1d5383
   CMAKE_GENERATOR "${CMAKE_GENERATOR}"
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
   INSTALL_COMMAND ""
@@ -511,6 +514,76 @@ if(do_git_tests)
   set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
 endif()
 
+set(do_hg_tests 0)
+
+if(HG_EXECUTABLE)
+  set(do_hg_tests 1)
+endif()
+
+if(do_hg_tests)
+  set(local_hg_repo "../../LocalRepositories/HG")
+
+  # Unzip/untar the hg repository in our source folder so that other
+  # projects below may use it to test hg args of ExternalProject_Add
+  #
+  set(proj SetupLocalHGRepository)
+  ExternalProject_Add(${proj}
+    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/HG
+    URL ${CMAKE_CURRENT_SOURCE_DIR}/hgrepo.tgz
+    BUILD_COMMAND ""
+    CONFIGURE_COMMAND "${HG_EXECUTABLE}" --version
+    INSTALL_COMMAND ""
+  )
+  set_property(TARGET ${proj}
+    PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing")
+
+
+  # hg by commit id:
+  #
+  set(proj TutorialStep1-HG-byhash)
+  ExternalProject_Add(${proj}
+    HG_REPOSITORY "${local_hg_repo}"
+    HG_TAG dd2ce38a6b8a
+    UPDATE_COMMAND ""
+    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+    INSTALL_COMMAND ""
+    DEPENDS "SetupLocalHGRepository"
+  )
+  set_property(TARGET ${proj} PROPERTY FOLDER "HG")
+
+  # hg by explicit branch/tag name:
+  #
+  set(proj TutorialStep1-HG-bytag)
+  ExternalProject_Add(${proj}
+    HG_REPOSITORY "${local_hg_repo}"
+    HG_TAG "default"
+    UPDATE_COMMAND ""
+    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+    INSTALL_COMMAND ""
+    DEPENDS "SetupLocalHGRepository"
+  )
+  set_property(TARGET ${proj} PROPERTY FOLDER "HG")
+
+  # Live hg / tip (no HG_TAG):
+  #
+  # Mercurial 2.1 does not distinguish an empty pull from a failed pull,
+  # so do not run the test with that version.
+  if(NOT "${HG_VERSION_STRING}" STREQUAL "2.1")
+    set(proj TutorialStep1-HG-tip)
+    ExternalProject_Add(${proj}
+      HG_REPOSITORY "${local_hg_repo}"
+      CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+      CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+      INSTALL_COMMAND ""
+      DEPENDS "SetupLocalHGRepository"
+      LOG_UPDATE 1
+    )
+    set_property(TARGET ${proj} PROPERTY FOLDER "HG")
+  endif()
+endif()
+
 
 # Test the testable built/installed products:
 #
@@ -567,6 +640,17 @@ if(do_svn_tests)
     "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98)
 endif()
 
+if(do_git_tests)
+  add_test(TutorialStep1-GIT-byhash
+    "${binary_base}/TutorialStep1-GIT-byhash/Tutorial" 100)
+
+  add_test(TutorialStep1-GIT-bytag
+    "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99)
+
+  add_test(TutorialStep1-GIT-master
+    "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98)
+endif()
+
 
 # InstallTree tests:
 #
@@ -581,5 +665,5 @@ endif()
 message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'")
 message(STATUS "do_cvs_tests='${do_cvs_tests}'")
 message(STATUS "do_svn_tests='${do_svn_tests}'")
-message(STATUS "do_git_tests='${do_git_tests}'")
-message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
+message(STATUS "do_git_tests='${do_git_tests}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
+message(STATUS "do_hg_tests='${do_hg_tests}'   HG_EXECUTABLE='${HG_EXECUTABLE}'")