RunCMakeTest.cmake 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. include(RunCMake)
  2. run_cmake(CommandConflict)
  3. if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode" AND NOT XCODE_BELOW_2)
  4. run_cmake(OutputConflict)
  5. endif()
  6. run_cmake(EmptyCondition1)
  7. run_cmake(EmptyCondition2)
  8. run_cmake(BadCondition)
  9. run_cmake(DebugEvaluate)
  10. set(timeformat "%Y%j%H%M%S")
  11. file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt")
  12. set(RunCMake_TEST_OPTIONS "-DTEST_FILE=WriteIfDifferent.cmake")
  13. set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/WriteIfDifferent-build")
  14. run_cmake(WriteIfDifferent-prepare)
  15. unset(RunCMake_TEST_OPTIONS)
  16. unset(RunCMake_TEST_BINARY_DIR)
  17. file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp ${timeformat})
  18. if(NOT timestamp)
  19. message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
  20. endif()
  21. execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
  22. set(RunCMake_TEST_NO_CLEAN ON)
  23. run_cmake(WriteIfDifferent)
  24. file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp_after ${timeformat})
  25. if(NOT timestamp_after)
  26. message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
  27. endif()
  28. unset(RunCMake_TEST_NO_CLEAN)
  29. if (NOT timestamp_after STREQUAL timestamp)
  30. message(SEND_ERROR "WriteIfDifferent changed output file.")
  31. endif()