[cmake-developers] [CMake] Windows rpath emulation

Brad King brad.king at kitware.com
Thu Sep 25 09:17:24 EDT 2014


On 09/25/2014 08:45 AM, Nils Gladitz wrote:
> @Brad: Before I rush into implementing anything and given that David 
> already raised concerns ... would anything like this be considered for 
> merge into CMake?

I'm not convinced it should be a builtin CMake feature.  KWSys provides
the "SharedForward" component specifically to help projects create
launcher executables like this.  It even helps create relocatable
binaries on *NIX without $ORIGIN, and works for redistributable
packages on both Windows and *NIX.  All of this works without any
special CMake features.

While it would be nice to provide a helper for applications to do this,
the only reason to include it in CMake would be to avoid an additional
external dependency for the application.  The same dependency management
argument could be made for any library, and we can't include the world
in CMake.

> $<TARGET_FILE> should continue to point at the real binary.
> A new $<TARGET_WRAPPER> could point at the wrapper binary.

The original purpose of $<TARGET_FILE> was for add_custom_command and
add_test to be able to refer to executables to run on command lines.
That would have to be the wrapper for this use case.  However, other
use cases may want to pass the real binary with $<TARGET_FILE>.
This makes the behavior of a magic wrapper hard to define in general,
so it would be better to have application code manage the separate
targets explicitly.

Note that CMake now has a "cmake -E env" feature that could be
used in custom commands and tests to set PATH before launching
an executable.

-Brad




More information about the cmake-developers mailing list