CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright 2016 Open Source Robotics Foundation, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Unlike other generators, this custom command depends on the target
  15. # ${rosidl_generate_interfaces_TARGET} and not the IDL files.
  16. # The IDL files could be generated files,as they are for .action files.
  17. # CMake does not allow `add_custom_command()` to depend on files generated in
  18. # a different CMake subdirectory, and this command is invoked after an
  19. # add_subdirectory() call.
  20. add_custom_command(
  21. OUTPUT ${_generated_extension_files} ${_generated_py_files} ${_generated_c_files}
  22. COMMAND ${PYTHON_EXECUTABLE} ${rosidl_generator_py_BIN}
  23. --generator-arguments-file "${generator_arguments_file}"
  24. --typesupport-impls "${_typesupport_impls}"
  25. DEPENDS ${target_dependencies} ${rosidl_generate_interfaces_TARGET}
  26. COMMENT "Generating Python code for ROS interfaces"
  27. VERBATIM
  28. )
  29. if(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix})
  30. message(WARNING "Custom target ${rosidl_generate_interfaces_TARGET}${_target_suffix} already exists")
  31. else()
  32. add_custom_target(
  33. ${rosidl_generate_interfaces_TARGET}${_target_suffix}
  34. DEPENDS
  35. ${_generated_extension_files}
  36. ${_generated_py_files}
  37. ${_generated_c_files}
  38. )
  39. endif()