Thanks a lot. Obviously, setting the environment when calling cmake is not 
enough. The command scl enable devtoolset-3 "cmake ../src"
sets the path etc and runs the cmake command, but it seems that cmake opens a 
new subshell with default settings. I've added the settings to .bashrc and it 
now finds the correct ar/ranlib etc.

Unfortunately,  this uncovered a bug in binutils on my system (centos 7) which 
results in a segfault when using ar to create a static lib with 
link-time-optimizations enabled. As a workaround, I tried to convert the 
library targets to OBJECT libraries, which also makes sense because I use the 
libraries to structure my project only. They are not delivered. However, this 
resulted in another problem with generator expressions. I will post another 
question for that.

Thanks,
  Jens

--
Dr. Jens Auer | CGI | Software Engineer
CGI Deutschland Ltd. & Co. KG
Rheinstraße 95 | 64295 Darmstadt | Germany
T: +49 6151 36860 154
jens.a...@cgi.com
Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter 
de.cgi.com/pflichtangaben.

CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI 
Group Inc. and its affiliates may be contained in this message. If you are not 
a recipient indicated or intended in this message (or responsible for delivery 
of this message to such person), or you think for any reason that this message 
may have been addressed to you in error, you may not use or copy or deliver 
this message to anyone else. In such case, you should destroy this message and 
are asked to notify the sender by reply e-mail.


-----Original Message-----
From: CMake [mailto:cmake-boun...@cmake.org] On Behalf Of Bill Hoffman
Sent: 28 July 2015 17:05
To: cmake@cmake.org
Subject: Re: [CMake] CMake finds wrong ar/ranlib/nm

On 7/28/2015 4:39 AM, Auer, Jens wrote:
> Hi,
>
> I am trying to use another compiler than the default one installed on 
> my system. I have to do this because I want to use a newer gcc than 
> the one on centos 7,so I installed RedHat Developer Toolset 3 with gcc 
> 4.9. When I call cmake with
>
> sclenable devtoolset-3 "cmake ../src" in my build directory, it 
> generates makefiles which use the new compiler and linker, but still 
> uses the default /usr/bin/ar etc. This is problematic because I enable 
> whole-program-optimization in release mode, and this needs to use the 
> ar provided with gcc 4.9 to handle the link-time optimization object files.
>
> I have tried various things to force cmake to use a specific ar, but 
> none of these worked:
>
> -Manually set CMAKE_AR in the CMakeLists.txt
>
> -Change CMAKE_AR in the cache
>
> -Write my own toolchain file
>
> With the toolchain file, cmake creates Makefiles but puts an empty ar 
> command in the lib "link" command, and building thus fails with an error.
>
> Am I missing something?
>
This is an environment thing.  Make sure the command line you are using is 
setup to find the other tools first in your PATH and it should work. 
  CMake assumes the environment is setup to work with the compiler you want to 
use.

-Bill

-- 

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:
http://public.kitware.com/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:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to