ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Catkin (which I assume you're using to build your pkg although I don't see any mention of build tool) is cmake extension and any cmake macro can be used as defined in cmake, and execute_process shouldn't be an exception. With CMakeLists.txt in your sample, what are in ${HON_SCRIPT}, ${HON_CSV} should be called.

I checked with something similar with catkin-tools. Posting pretty much the whole thing as it's short enough.

cmake_minimum_required(VERSION 2.8.3)
project(catkin_pkg_a)
find_package(catkin REQUIRED)
catkin_package()

set(SCRIPT_SETUP_SAMPLE "${PROJECT_SOURCE_DIR}/setup_sample.sh")
execute_process(
  COMMAND ${SCRIPT_SETUP_SAMPLE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  )

setup_sample.sh file:

#!/bin/bash
touch /tmp/file_made_via_cmake

Command executed:

date
Thu Oct 23 18:37:57 PDT 2019
ll /tmp/file_made_via_cmake
ls: cannot access '/tmp/file_made_via_cmake': No such file or directory

catkin config --install
catkin build

ll /tmp/file_made_via_cmake
-rw-r--r-- 1 root root 0 Oct 23 18:38 /tmp/file_made_via_cmake

(Btw, I'm seeing when running catkin build -DCMAKE_BUILD_TYPE=Release, the file doesn't always get created. Not yet sure why.)

Catkin (which I assume you're using to build your pkg although I don't see any mention of build tool) is cmake extension and any cmake macro can be used as defined in cmake, and execute_process shouldn't be an exception. With CMakeLists.txt in your sample, what are in ${HON_SCRIPT}, ${HON_CSV} cmake should be called.able to reference to what's defined in ${HON_SCRIPT}, ${HON_CSV}.

I checked with something similar with catkin-tools. Posting pretty much the whole thing as it's short enough.

cmake_minimum_required(VERSION 2.8.3)
project(catkin_pkg_a)
find_package(catkin REQUIRED)
catkin_package()

set(SCRIPT_SETUP_SAMPLE "${PROJECT_SOURCE_DIR}/setup_sample.sh")
execute_process(
  COMMAND ${SCRIPT_SETUP_SAMPLE}
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  )

setup_sample.sh file:

#!/bin/bash
touch /tmp/file_made_via_cmake

Command executed:

date
Thu Oct 23 18:37:57 PDT 2019
ll /tmp/file_made_via_cmake
ls: cannot access '/tmp/file_made_via_cmake': No such file or directory

catkin config --install
catkin build

ll /tmp/file_made_via_cmake
-rw-r--r-- 1 root root 0 Oct 23 18:38 /tmp/file_made_via_cmake

(Btw, I'm seeing when running catkin build -DCMAKE_BUILD_TYPE=Release, the file doesn't always get created. Not yet sure why.)