As far as I've understood, I need to use at least CMake 3.1 in order to use C++11. Ubuntu 14.04 comes with 2.8.x.
I followed a guide suggesting that one should install CMake to /opt
, so I have CMake installed to /opt/cmake-3.2.1-Linux-x86_64
and added /opt/cmake-3.2.1-Linux-x86_64/bin
to path (as the first element) in .bashrc.
If I try to apt-get remove cmake
the process wants to remove not only CMake but also ROS (so yes, I've stopped by ubuntu: upgrading software (cmake) - version disambiguation (local compile), only to conclude that I couldn't use the answers)
Result of cmake --version
:
cmake version 3.2.1
Setting minimum required version to 3.1 and running catkin_make
in the same terminal yields:
CMake 3.1 or higher is required. You are running version 2.8.12.2
How can I make catkin
use the new (/correct) version of CMake?
Two things going on here:
catkin_make:
...
if args.no_color:
run_command(cmd, build_path)
else:
run_command_colorized(cmd, build_path)
builder.py:
def run_command(cmd, cwd, quiet=False, colorize=False, add_env=None):
...
env = None
if add_env:
env = copy.copy(os.environ)
env.update(add_env)
try:
proc = subprocess.Popen(
cmd, cwd=cwd, shell=False,
stdout=stdout_pipe, stderr=stderr_pipe,
env=env
)
You can modify the appropriate lines in the catkin_make script to properly pass an empty dictionary for add_env, and it should attempt to copy the environment to the spawned sub process:
if args.no_color:
run_command(cmd, build_path, add_env={})
else:
run_command_colorized(cmd, build_path, add_env={})
This should modify the path and let it find the appropriate cmake version, but I'm not sure this alone solves your original question, leading us to...
-std=c++11
compiler flag to CMAKE_CXX_FLAGS
:catkin_make --cmake-flags "-DCMAKE_CXX_FLAGS=\${CMAKE_CXX_FLAGS};-std=c++11"
or modify the CMakeLists.txt: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")