How to specify Redhat Developer Toolset compiler?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to specify Redhat Developer Toolset compiler?

David Aldrich-2
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?


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

Andreas Naumann
You could set the environment variables CXX and CC such that they point
to your toolset compiler

Am 20.06.19 um 17:39 schrieb David Aldrich:

> 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?
>
>

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

Eric Noulard
In reply to this post by David Aldrich-2
I would bet that enabling the toolset before launching CMake will do the trick.
Otherwise set CC and/or CXX env var to the desired path before launching CMake.

Le jeu. 20 juin 2019 à 17:39, David Aldrich <[hidden email]> a écrit :
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?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

Scott Bloom
In reply to this post by David Aldrich-2

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 <[hidden email]> On Behalf Of David Aldrich
Sent: Thursday, June 20, 2019 8:40 AM
To: CMake MailingList <[hidden email]>
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?

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

Jim Melton
In reply to this post by Andreas Naumann
I fought with this and ended up with the below approach. Note that these values are cached, so you must start with a clean build directory before changing. Assuming your desired versions are on your path:

CC=$(which gcc) CXX=$(which g++) cmake3 <other args to cmake>

---
Jim Melton
Principal Software Engineer
Sierra Nevada Corporation


-----Original Message-----
From: CMake <[hidden email]> On Behalf Of Andreas Naumann
Sent: Thursday, June 20, 2019 09:52
To: CMake MailingList <[hidden email]>
Subject: [EXTERNAL] Re: [CMake] How to specify Redhat Developer Toolset compiler?

You could set the environment variables CXX and CC such that they point to your toolset compiler

Am 20.06.19 um 17:39 schrieb David Aldrich:

> 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?
>
>

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

CONFIDENTIALITY NOTICE - SNC EMAIL: This email and any attachments are confidential, may contain proprietary, protected, or export controlled information, and are intended for the use of the intended recipients only. Any review, reliance, distribution, disclosure, or forwarding of this email and/or attachments outside of Sierra Nevada Corporation (SNC) without express written approval of the sender, except to the extent required to further properly approved SNC business purposes, is strictly prohibited. If you are not the intended recipient of this email, please notify the sender immediately, and delete all copies without reading, printing, or saving in any manner. --- Thank You.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

Juan E. Sanchez
In reply to this post by David Aldrich-2
Hello,

I use a bash script, like this for devtoolset-6.


Regards,

Juan


On Thu, Jun 20, 2019 at 10:39 AM David Aldrich <[hidden email]> wrote:
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?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to specify Redhat Developer Toolset compiler?

David Aldrich-2
Thanks for all the replies. I decided to set CC and CXX in .bashrc:

source scl_source enable devtoolset-7
export CXX="/opt/rh/devtoolset-7/root/usr/bin/g++"
export CC="/opt/rh/devtoolset-7/root/usr/bin/gcc"


I wonder why it says to avoid using set()?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake