[CMake] Running executables - local targets vs. system binaries

Clifford Yapp cliffyapp at gmail.com
Tue Mar 6 17:51:51 EST 2012


In a number of places in our build, we use compiled binaries via
add_custom_command and friends to perform work during the compilation.  For
the most part we are able to successfully specify the target name used with
add_executable in place of a full path to successfully tell CMake to run
the locally built binary, but there's a corner case that's causing a bit of
trouble.

We have locally built versions of several tools that might be found on some
systems, but cannot be relied upon to be there in all cases (Windows, in
particular, expands the set of "can't always depend on it being available"
significantly.)  In some build configurations we want to use our local
verisons of these tools even when system versions are present (testing,
making sure the version we use supports what we need, etc.).  This is where
we get into trouble - if the system version of our locally built tool is in
the path, and the executable name matches the CMake target name, it looks
as though the generated build files will use the system version in
preference to the locally built version.

Is this expected behavior, and if so is there a setting that can be set to
make CMake prefer the local target over the system version in cases where
both are present?  It doesn't matter much when using systems like Make
since I can supply the full path to the locally built target, but for
multi-configuration systems like Visual Studio this path changes at build
time, not CMake configure time.

Any insight appreciated!

CY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120306/a61042ea/attachment.htm>


More information about the CMake mailing list