I've discovered that CMake is not correctly locating ar/strip/etc. if I
override the names of these tools on the command line.  I've tried this
with 3.5.2 as well and I get the same incorrect behavior.

Here's an example (this is on a GNU/Linux system):

$ type -a my-ar
/work/bin/my-ar

$ my-ar --version | head -n1
GNU ar (GNU Binutils) 2.30

$ pwd
/tmp/obj

$ cat ../CMakeLists.txt
PROJECT(foobar)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)

$ cmake --version | head -n1
cmake version 3.11.3

$ cmake -DCMAKE_AR=my-ar ..
  ...

$ grep CMAKE_AR CMakeCache.txt
CMAKE_AR:FILEPATH=/tmp/obj/my-ar
//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1


Note how, instead of either using just "my-ar" or else the fully-
qualified path "/work/bin/my-ar", CMake uses the bogus and completely
non-existent path "/tmp/obj/my-ar".  This causes my builds to fail,
obviously.

I tried enabling debug-output, trace, and trace-expand but there are no
clues there as to why CMake prefixes these paths with the local object
directory.

I should note that resetting the C and C++ compilers works:

 * -DCMAKE_C_COMPILER=my-gcc   --> CMAKE_C_COMPILER=/work/bin/my-gcc
 * -DCMAKE_CXX_COMPILER=my-g++ --> CMAKE_CXX_COMPILER=/work/bin/my-g++

But all the other bintools variable overrides do the wrong thing:

 * -DCMAKE_AR=my-ar           --> CMAKE_AR=/tmp/obj/my-ar
 * -DCMAKE_LINKER=my-ld       --> CMAKE_LINKER=/tmp/obj/my-ld
 * -DCMAKE_RANLIB=my-ranlib   --> CMAKE_RANLIB=/tmp/obj/my-ranlib
 * -DCMAKE_STRIP=my-strip     --> CMAKE_STRIP=/tmp/obj/my-strip
 * -DCMAKE_OBJCOPY=my-objcopy --> CMAKE_OBJCOPY=/tmp/obj/objcopy

Can anyone explain this, and hopefully help me find a way to fix it? 
Am I just doing variables wrong here?  How should I do it?

Thanks!
-- 

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 via email to