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

catkin share directory vs. workspace directory [closed]

asked 2015-05-05 13:16:16 -0600

Hi,

How can I set a variable inside my CMakeLists.txt to set a variable to point to a file into the workspace which also points to the same file but in the share directory when installed.

Example:

I want to install a "foo.c" inside my_package/src/. Now when installed, it should be in the same directory as the files in the package but in the share folder, so that other later workspaces can compile the source file into there code with a macro this way:

add_executable(foo_node ... ${MY_PACKAGE_SOURCE})

Thanks,

Regards,

Christian

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by cyborg-x1
close date 2015-06-26 04:07:22.016851

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-05 13:40:48 -0600

Dirk Thomas gravatar image

You package can use a custom CFG_EXTRAS file to set arbitrary variables when your package is being found: https://github.com/ros/gencpp/blob/95...

An example package which sets variable to different location in devel-space and in install-space would be: https://github.com/ros/gencpp/blob/95...

edit flag offensive delete link more

Comments

Thanks, I will try that ...

cyborg-x1 gravatar image cyborg-x1  ( 2015-05-05 14:54:08 -0600 )edit

I added it but now it tells me the following on compilation: Parse error. Expected a command name, got unquoted argument with text "@[if".

cyborg-x1 gravatar image cyborg-x1  ( 2015-05-05 15:14:47 -0600 )edit

If I comment out the if and else statements, it works but the @CMAKE_CURRENT_SOURCE_DIR is not translated into a path when I use message() to print it inside the cmake file: Output is like @(CMAKE_CURRENT_SOURCE_DIR)/src/ is that normal?

cyborg-x1 gravatar image cyborg-x1  ( 2015-05-05 15:30:50 -0600 )edit
1

You either gave the filename the wrong extension or have a syntax error in the empy template.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-05-05 15:34:24 -0600 )edit

Ahhh I missed the em! ... (.cmake.em)

cyborg-x1 gravatar image cyborg-x1  ( 2015-05-05 15:43:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-05 13:16:16 -0600

Seen: 2,786 times

Last updated: May 05 '15