[CMake] CMake 3.11: Gives wrong paths to ar/strip/etc. when overridden

Paul Smith paul at mad-scientist.net
Thu Jun 14 08:16:00 EDT 2018


On Thu, 2018-06-14 at 11:41 +0200, Deniz Bahadir wrote:
> > 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
> > 
> 
> This is what I would have expected.
> If you just give the executable's name as value to the variable an 
> implicit "./" is seen by CMake which when translated into an
> absolute path results in "./" being replaced by the current working-
> directory of CMake (which seems to be "/tmp/obj/").

Thanks for the note!

IMO, that's just manifestly wrong behavior.

Either CMake should leave my values alone and use them exactly as I set
them, or if it wants to handle these values specially because it knows
they are binaries and wants to enforce a fully-qualified path (which is
unnecessary IMO but whatever), then at least it should do that
correctly and perform a PATH lookup for them.

Forcing them to be "./binary" when that's not what I said is completely
unexplainable.  In what universe would looking for CMAKE_AR, etc. in
the local directory ever be the right thing to do?

> > 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?
> 
> I recommend to us the fully qualified path to your alternative 
> executables as values for the variables. That should do the trick.

So you're saying that rather than relying on the operating system's
path lookup capabilities, which exist for exactly this reason, I have
to recreate that operation myself by hand (or in some sort of wrapper
script) for all my binaries before I can invoke cmake?

> PS: You are right that the behavior seems to be inconsistent for 
> different variables and should be similar for all variables. So I 
> recommend you file a bug-report in CMake's issue-tracker.

That does seem like the next step.  Filed:

https://gitlab.kitware.com/cmake/cmake/issues/18087

Thanks!


More information about the CMake mailing list