colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

colcon-build for a cmake project doesn't pickup CMAKE_ vars from the environment #132

Closed jfinken closed 2 months ago

jfinken commented 10 months ago

The below describes a reduction exhibiting the symptom:

The solution is to force the set in CMakeLists.txt. But why?

set(CMAKE_C_FLAGS "$ENV{CMAKE_C_FLAGS} $ENV{CFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "$ENV{CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}" CACHE STRING "" FORCE)
$ colcon build
...
CMAKE_C_FLAGS are:   foo 
CMAKE_CXX_FLAGS are: foo; bar; baz
cottsay commented 10 months ago

I can't find any evidence that CMAKE_<LANG>_FLAGS is expected to take it's value from an environment variable with the same name. In fact, the documentation specifically says that CMAKE_C_FLAGS and CMAKE_CXX_FLAGS take their initial value from the CFLAGS and CXXFLAGS environment variables respectively.

When I use the proper environment variables, this seems to work as expected. Also, I can reproduce the behavior you described here outside of colcon by simply invoking cmake directly on the project, so I don't see how this could be a problem in colcon itself.

cottsay commented 2 months ago

@jfinken, do you still believe there is a problem with colcon's behavior here, or can this ticket be closed?

jfinken commented 2 months ago

@jfinken, do you still believe there is a problem with colcon's behavior here, or can this ticket be closed?

My apologies. Yes this ticket can be closed. Thank you.