[CMake] How to specify Redhat Developer Toolset compiler?

Scott Bloom scott at towel42.com
Thu Jun 20 12:23:00 EDT 2019


We have a similar issue at my company, so the call to /opt/rh/devtoolset-X/enable is done in our bashrc files

Then we use CMAKE_<LANG>_COMPILER_VERSION in our cmake file to make sure its set correctly.

Scott

From: CMake <cmake-bounces at cmake.org> On Behalf Of David Aldrich
Sent: Thursday, June 20, 2019 8:40 AM
To: CMake MailingList <cmake at cmake.org>
Subject: [CMake] How to specify Redhat Developer Toolset compiler?

My Centos 7.6 machine has CMake 3.13.5 and g++ 4.8.5 installed:

$ /usr/bin/x86_64-redhat-linux-g++ --version
x86_64-redhat-linux-g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)

I have a very simple CMakeLists.txt:

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(hello_world LANGUAGES CXX)

add_executable(hello_world "")

target_sources(hello_world
  PRIVATE
    main.cpp
    Message.hpp
    Message.cpp)

I also have Redhat Developer Toolset 7 installed which I can enable in my bash shell:

$ scl enable devtoolset-7 bash
$ which g++
/opt/rh/devtoolset-7/root/usr/bin/g++
$ g++ --version
g++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)

How can I get CMake to use the later version of g++ instead of 4.8.5?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190620/3c3a4225/attachment.html>


More information about the CMake mailing list