CommandConcat.cmake 698 B

1234567891011121314
  1. cmake_minimum_required(VERSION 3.7)
  2. project(concat_cmd NONE)
  3. set(output1 ${CMAKE_BINARY_DIR}/out1.txt)
  4. set(output2 ${CMAKE_BINARY_DIR}/out2.txt)
  5. file(REMOVE ${output1} ${output2})
  6. # Check that second command runs if first command contains "||" which has higher precedence than "&&" on Windows
  7. add_custom_target(concat_cmd ALL
  8. COMMAND ${CMAKE_COMMAND} -E echo "Hello || pipe world" && ${CMAKE_COMMAND} -E touch ${output1} || exit 1
  9. COMMAND ${CMAKE_COMMAND} -E touch ${output2})
  10. # Check output
  11. add_custom_target(check_output ALL
  12. COMMAND ${CMAKE_COMMAND} -E copy ${output1} ${output1}.copy
  13. COMMAND ${CMAKE_COMMAND} -E copy ${output2} ${output2}.copy)
  14. add_dependencies(check_output concat_cmd)