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

Cannot override a CMake variable via catkin_make

asked 2018-09-21 04:15:27 -0500

Nordlöw gravatar image

updated 2022-01-22 16:16:23 -0500

Evgeny gravatar image

I'm trying to override a CMake variable defined in a CMakeLists.txt

set(ANTLR4_ROOT /usr/local)

via a, say,

catkin_make -DANTLR4_ROOT=$HOME/.local

. But it the value isn't changed.

I do know that the value is set because

message(STATUS "Using ANTLR4 version ${ANTLR4_VERSION}: ${ANTLR4_ROOT}")

always prints

-- Using ANTLR4 version 4.7.1: /usr/local

I am however able to alter, say,

catkin_make -DCMAKE_PREFIX_PATH=/xx

so then why can't I alter ANTLR4_ROOT in a similar way?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2018-09-21 08:44:36 -0500

allenh1 gravatar image

updated 2018-09-21 08:45:19 -0500

You can pass arguments to cmake through catkin like this.

catkin_make --cmake-args -DANTLR4_ROOT:STRING=$HOME/.local -DCMAKE_OTHER_STUFF=STUFF --

the -- at the end is to allow other catkin arguments to go through, should you need to add more.

edit flag offensive delete link more
0

answered 2018-09-21 06:28:01 -0500

l4ncelot gravatar image

updated 2018-09-21 06:29:31 -0500

I think here is your answer.

You must set your variable as cached string like this:

set(ANTLR4_ROOT "/usr/local" CACHE STRING "ANTLR4_ROOT variable")

And then you make the project with:

catkin_make -DANTLR4_ROOT:STRING=$HOME/.local
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-09-21 04:04:24 -0500

Seen: 427 times

Last updated: Sep 21 '18