RunCMake.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. if(NOT DEFINED CMake_SOURCE_DIR)
  2. message(FATAL_ERROR "CMake_SOURCE_DIR not defined")
  3. endif()
  4. if(NOT DEFINED dir)
  5. message(FATAL_ERROR "dir not defined")
  6. endif()
  7. if(NOT DEFINED gen)
  8. message(FATAL_ERROR "gen not defined")
  9. endif()
  10. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  11. # First setup a source tree to run CMake on.
  12. #
  13. execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory
  14. ${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast
  15. ${dir}/Source
  16. )
  17. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
  18. ${dir}/Build
  19. )
  20. function(RunCMakeWithArgs)
  21. message(STATUS "info: running cmake with ARGN='${ARGN}'")
  22. execute_process(COMMAND ${CMAKE_COMMAND} ${ARGN}
  23. RESULT_VARIABLE result
  24. OUTPUT_VARIABLE stdout
  25. ERROR_VARIABLE stderr
  26. WORKING_DIRECTORY ${dir}/Build
  27. )
  28. message(STATUS "result='${result}'")
  29. message(STATUS "stdout='${stdout}'")
  30. message(STATUS "stderr='${stderr}'")
  31. message(STATUS "")
  32. endfunction()
  33. # Run cmake once with no errors to get a good build tree:
  34. #
  35. RunCMakeWithArgs(-G ${gen} ../Source)
  36. # Run cmake with args that produce some sort of problem to cover the error
  37. # cases in cmake.cxx...
  38. #
  39. # (These are not good examples of cmake command lines. Do not copy and
  40. # paste them elsewhere and expect them to work... See the cmake
  41. # documentation or other real examples of usage instead.)
  42. #
  43. RunCMakeWithArgs()
  44. RunCMakeWithArgs(-C)
  45. RunCMakeWithArgs(-C nosuchcachefile.txt)
  46. RunCMakeWithArgs(--check-stamp-file nostampfile)
  47. RunCMakeWithArgs(--check-stamp-list nostamplist)
  48. RunCMakeWithArgs(nosuchsubdir/CMakeCache.txt)
  49. RunCMakeWithArgs(nosuchsubdir/CMakeLists.txt)
  50. RunCMakeWithArgs(-D)
  51. RunCMakeWithArgs(--debug-output .)
  52. RunCMakeWithArgs(--debug-trycompile .)
  53. RunCMakeWithArgs(-E)
  54. RunCMakeWithArgs(-E create_symlink)
  55. RunCMakeWithArgs(-E echo_append)
  56. RunCMakeWithArgs(-E rename)
  57. RunCMakeWithArgs(-E touch_nocreate)
  58. RunCMakeWithArgs(-G)
  59. RunCMakeWithArgs(--graphviz= ../Source)
  60. RunCMakeWithArgs(--graphviz=g.dot .)
  61. RunCMakeWithArgs(-P)
  62. RunCMakeWithArgs(-P nosuchscriptfile.cmake)
  63. RunCMakeWithArgs(--trace .)
  64. RunCMakeWithArgs(-U)
  65. RunCMakeWithArgs(-U nosuchvariable .)
  66. RunCMakeWithArgs(-V)
  67. RunCMakeWithArgs(-V .)
  68. RunCMakeWithArgs(-Wno-dev .)
  69. RunCMakeWithArgs(-Wdev .)