ErrorsCommon.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # This CMakeLists file is *sometimes expected* to result in a configure error.
  2. #
  3. # expect this to succeed:
  4. # ../bin/Release/cmake -G Xcode
  5. # ../../CMake/Tests/CMakeCommands/build_command
  6. #
  7. # expect this to fail:
  8. # ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode
  9. # ../../CMake/Tests/CMakeCommands/build_command
  10. #
  11. # This project exists merely to test the CMake command 'build_command'...
  12. # ...even purposefully calling it with known-bad argument lists to cover
  13. # error handling code.
  14. #
  15. set(cmd "initial")
  16. message("0. begin")
  17. if(TEST_ERROR_CONDITIONS)
  18. # Test with no arguments (an error):
  19. build_command()
  20. message("1. cmd='${cmd}'")
  21. # Test with unknown arguments (also an error):
  22. build_command(cmd BOGUS STUFF)
  23. message("2. cmd='${cmd}'")
  24. build_command(cmd STUFF BOGUS)
  25. message("3. cmd='${cmd}'")
  26. else()
  27. message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)")
  28. endif()
  29. # Test the one arg signature with none of the optional KEYWORD arguments:
  30. build_command(cmd)
  31. message("4. cmd='${cmd}'")
  32. # Test the two-arg legacy signature:
  33. build_command(legacy_cmd ${CMAKE_MAKE_PROGRAM})
  34. message("5. legacy_cmd='${legacy_cmd}'")
  35. message(" CMAKE_MAKE_PROGRAM='${CMAKE_MAKE_PROGRAM}'")
  36. # Test the optional KEYWORDs:
  37. build_command(cmd CONFIGURATION hoohaaConfig)
  38. message("6. cmd='${cmd}'")
  39. build_command(cmd PROJECT_NAME hoohaaProject)
  40. message("7. cmd='${cmd}'")
  41. build_command(cmd TARGET hoohaaTarget)
  42. message("8. cmd='${cmd}'")
  43. set(cmd "final")
  44. message("9. cmd='${cmd}'")