AddCustomTarget.cmake 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. set(CMAKE_CROSSCOMPILING 1)
  2. # Executable: Return error code different from 0
  3. add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
  4. # Executable: Return error code equal to 0
  5. add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx)
  6. # Place the executable in a predictable location.
  7. set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
  8. # Executable: Imported version of above. Fake the imported target to use the above.
  9. add_executable(generated_exe_emulator_unexpected_imported IMPORTED)
  10. set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION
  11. "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}")
  12. add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected)
  13. # DoesNotUseEmulator
  14. add_custom_target(generate_output1 ALL
  15. ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output1)
  16. # DoesNotUseEmulator: The command will fail if emulator is prepended
  17. add_custom_target(generate_output2 ALL
  18. ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:generated_exe_emulator_unexpected>"
  19. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output2
  20. DEPENDS generated_exe_emulator_unexpected)
  21. # DoesNotUseEmulator: The command will fail if emulator is prepended
  22. add_custom_target(generate_output3 ALL
  23. $<TARGET_FILE:generated_exe_emulator_unexpected>
  24. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
  25. DEPENDS generated_exe_emulator_unexpected)
  26. # DoesNotUseEmulator: The command will fail if emulator is prepended
  27. add_custom_target(generate_outputImp ALL
  28. COMMAND generated_exe_emulator_unexpected_imported
  29. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
  30. )
  31. # UsesEmulator: The command only succeeds if the emulator is prepended
  32. # to the command.
  33. add_custom_target(generate_output4 ALL
  34. generated_exe_emulator_expected
  35. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
  36. DEPENDS generated_exe_emulator_expected)