catkin depend on python package for custom command

asked 2021-01-22 08:54:29 -0500

tompe17 gravatar image

How do I depend on the a python package in a custom command in a CMakeList.txt? I have a command that generates code and that command uses a python packages in another ROS package. It should work both for devel and install builds.

I am now doing as below but shouldthere not be an easier way? It seems that the python files for devel build är not placed in the devel directory. So I cannot use package_PREFIX to write a dependency. Was hoping that the whole __init__.py would be copied to devel but that does not seem to be the case. My current code which seems t work is:

set(codegenbin
  ${PROJECT_SOURCE_DIR}/src/gen_json_bson.py
)

if("${lrs_common_SOURCE_PREFIX}" STREQUAL "")
  set(codegenbindep
     ${codegenbin}
     ${lrs_common_PREFIX}/lib/python3/dist-packages/codegen_json_bson/__init__.py
  )

else()
  set(codegenbindep
     ${codegenbin}
     ${lrs_common_SOURCE_PREFIX}/src/codegen_json_bson/__init__.py
  )
endif()
edit retag flag offensive close merge delete