From 5d2786e7f4bdfaadb83c06e3eaf4a71f6416cb9e Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Sat, 13 Jan 2024 13:59:29 +0900 Subject: [PATCH] -e install rcb4 in virtualenv --- ros/kxr_controller/CMakeLists.txt | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ros/kxr_controller/CMakeLists.txt b/ros/kxr_controller/CMakeLists.txt index a2c9a3f4..e93ebdfd 100644 --- a/ros/kxr_controller/CMakeLists.txt +++ b/ros/kxr_controller/CMakeLists.txt @@ -22,10 +22,6 @@ endif() get_filename_component(RCB4_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE) message(STATUS "RCB4 Directory: ${RCB4_DIR}") -# Command to copy the modified requirements.in to requirements.in.with_rcb4 -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/requirements.in ${CMAKE_CURRENT_SOURCE_DIR}/requirements.in.with_rcb4 COPYONLY) -file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/requirements.in.with_rcb4 "${RCB4_DIR}\n") - find_package(catkin REQUIRED COMPONENTS catkin_virtualenv actionlib @@ -56,13 +52,29 @@ catkin_package( ) catkin_generate_virtualenv( - INPUT_REQUIREMENTS requirements.in.with_rcb4 + INPUT_REQUIREMENTS requirements.in PYTHON_INTERPRETER python3 USE_SYSTEM_PACKAGES TRUE ISOLATE_REQUIREMENTS FALSE CHECK_VENV FALSE ) +set(_python "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/venv/bin/python") +set(_venv_setup "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/venv/bin/activate") + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script" + COMMAND echo "${_python} -m pip install ${RCB4_DIR}" + COMMAND . ${_venv_setup} && ${_python} -m pip install ${RCB4_DIR} + DEPENDS ${PROJECT_NAME}_generate_virtualenv # ${_venv_setup} +) + + +add_custom_target( + run_after_venv ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script" +) + include_directories( include ${catkin_INCLUDE_DIRS}