[CMake] Portable way to locate built executables.

Rick McGuire object.rexx at gmail.com
Sun May 18 13:24:11 EDT 2014


We have a project that builds some executables, then uses those executables
to build some additional build artifacts.  We have this working well using
makefiles on Windows and various unix variants.  I decided it would be nice
to try doing a build using a Visual Studio project.  The various
compile/link steps worked great, but any step that needed to use one of the
built executables was failing to find the executables.  An examination of
the build tree revealed that Visual Studio was placing the executables in
bin\Debug rather than the expected bin directory.

The command we're using is specified as:

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rexx.img
           COMMAND ./rexximage
           DEPENDS rexximage rxapi rexxutil ${image_class_files}
${platform_rexx_img_depends}
           WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})


where we're assuming the rexximage.exe file will be in the
CMAKE_RUNTIME_OUTPUT_DIRECTORY, which is specified as
${CMAKE_CURRENT_BINARY_DIR}/bin.  Is there a more appropriate method
we should be doing to locate this executable that will work using both
the NMake build process and a Visual Studio project?


Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140518/ac7b6a4e/attachment.html>


More information about the CMake mailing list