summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake
blob: d5319282d056039ca0ab3c5e6cba102e85c5d095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
include(ExternalProject)

if(CMAKE_GENERATOR STREQUAL "Borland Makefiles" OR
   CMAKE_GENERATOR STREQUAL "Watcom WMake")
  set(fs_delay 3)
else()
  set(fs_delay 1.125)
endif()

# Given this setup, on the first build, both configure steps and both build
# steps will run. On a noop rebuild, only the build steps will run. Without
# CONFIGURE_HANDLED_BY_BUILD, the configure step of proj2 would also run on a
# noop rebuild.

ExternalProject_Add(proj1
  DOWNLOAD_COMMAND ""
  SOURCE_DIR ""
  CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something"
  # file(TIMESTAMP) gives back the timestamp in seconds so we sleep a second to
  # make sure we get a different timestamp on the stamp file
  BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}
  INSTALL_COMMAND ""
  BUILD_ALWAYS ON
  STAMP_DIR "stamp"
)
ExternalProject_Add(proj2
  DOWNLOAD_COMMAND ""
  SOURCE_DIR ""
  CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something"
  BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}
  INSTALL_COMMAND ""
  CONFIGURE_HANDLED_BY_BUILD ON
  DEPENDS proj1
  STAMP_DIR "stamp"
)