[CMake] CMake finds wrong ar/ranlib/nm

Bill Hoffman bill.hoffman at kitware.com
Tue Jul 28 11:05:00 EDT 2015


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



More information about the CMake mailing list