RunCMakeTest.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. include(RunCMake)
  2. # Use a single build tree for a few tests without cleaning.
  3. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandWithOutput-build)
  4. set(RunCMake_TEST_NO_CLEAN 1)
  5. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  6. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  7. set(RunCMake-check-file CommandWithOutput-check.cmake)
  8. set(srcName "test.cs")
  9. set(srcFileName "${CMAKE_CURRENT_LIST_DIR}/${srcName}.in")
  10. set(inputFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}.in")
  11. set(generatedFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}")
  12. set(commandComment "Generating ${srcName}")
  13. # copy the input file to build dir to avoid changing files in cmake
  14. # source tree.
  15. file(COPY "${srcFileName}" DESTINATION "${RunCMake_TEST_BINARY_DIR}")
  16. set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS}
  17. "-DinputFileName=${inputFileName}"
  18. "-DgeneratedFileName=${generatedFileName}"
  19. "-DcommandComment=${commandComment}")
  20. set(checkLevel 0)
  21. run_cmake(CommandWithOutput)
  22. set(checkLevel 1)
  23. run_cmake_command(CommandWithOutput-build1 ${CMAKE_COMMAND} --build . --config Debug)
  24. set(checkLevel 2)
  25. run_cmake_command(CommandWithOutput-build2 ${CMAKE_COMMAND} --build . --config Debug)
  26. # change file content to trigger custom command with next build
  27. file(APPEND ${inputFileName} "\n")
  28. set(checkLevel 3)
  29. run_cmake_command(CommandWithOutput-build3 ${CMAKE_COMMAND} --build . --config Debug)