RunCMakeTest.cmake 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. include(RunCMake)
  2. if(RunCMake_GENERATOR STREQUAL "Borland Makefiles")
  3. set(fs_delay 3)
  4. else()
  5. set(fs_delay 1.125)
  6. endif()
  7. function(run_BuildDepends CASE)
  8. # Use a single build tree for a few tests without cleaning.
  9. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build)
  10. set(RunCMake_TEST_NO_CLEAN 1)
  11. if(RunCMake_GENERATOR MATCHES "Make|Ninja")
  12. set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  13. endif()
  14. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  15. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  16. include(${RunCMake_SOURCE_DIR}/${CASE}.step1.cmake OPTIONAL)
  17. run_cmake(${CASE})
  18. set(RunCMake-check-file check.cmake)
  19. set(check_step 1)
  20. run_cmake_command(${CASE}-build1 ${CMAKE_COMMAND} --build . --config Debug)
  21. if(run_BuildDepends_skip_step_2)
  22. return()
  23. endif()
  24. execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) # handle 1s resolution
  25. include(${RunCMake_SOURCE_DIR}/${CASE}.step2.cmake OPTIONAL)
  26. set(check_step 2)
  27. run_cmake_command(${CASE}-build2 ${CMAKE_COMMAND} --build . --config Debug)
  28. endfunction()
  29. run_BuildDepends(C-Exe)
  30. if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode")
  31. if(RunCMake_GENERATOR MATCHES "Visual Studio 10")
  32. # VS 10 forgets to re-link when a manifest changes
  33. set(run_BuildDepends_skip_step_2 1)
  34. endif()
  35. run_BuildDepends(C-Exe-Manifest)
  36. unset(run_BuildDepends_skip_step_2)
  37. endif()
  38. run_BuildDepends(Custom-Always)