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

David Cole david.cole at kitware.com
Tue Mar 6 17:56:41 EST 2012


If you want add_custom_command to run a certain executable, simply
give it the full path to that executable: use "/full/path/to/tool"
instead of "tool"

If tool is a built thing, you can use
"${XYZ_BINARY_DIR}/${CMAKE_CFG_INTDIR}/tool" which will properly
expand out to the correct "Release" or "Debug" subdirectory when run
with Visual Studio or Xcode.


HTH,
David


On Tue, Mar 6, 2012 at 5:51 PM, Clifford Yapp <cliffyapp at gmail.com> wrote:
> 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
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list