How can I get the location of the target being built? Granted, this file
name changes depending on the configuration that you're building.
I'm trying to add a post build event using add_custom_command that will
copy the target executable to a different directory, but I can't get the
correct location of the executable created at build time, because it
changes depending on the configuration being built.
add_custom_command will replace the executable target (created by
ADD_EXECUTABLE) with the location of the executable created at build
time, but only if the target is the one being executed by the command.
>From the docs:
"If COMMAND specifies an executable target (created by ADD_EXECUTABLE)
it will automatically be replaced by the location of the executable
created at build time"
Would it be a bad idea to have add_custom_command replace the executable
target by its location, when this is passed as an argument?
Ideally the following code:
add_executable(foo ${HEADERS} ${SOURCES})
set_target_properties(
foo
PROPERTIES
OUTPUT_NAME bar
DEBUG_POSTFIX _d
)
add_custom_command(
TARGET foo
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy foo C:/put/it/here/bin
)
Would create a post build event that looks like this in Visual Studio:
Debug Configuration:
"C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy Debug/bar_d.exe
C:/put/it/here/bin
Release Configuration:
"C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy Release/bar.exe
C:/put/it/here/bin
As far as I can tell, add_custom_command, only expands the target name
into the executable location, if this is the command being executed.
This thread <http://www.mail-archive.com/[email protected]/msg18026.html>
discussed a similar, if not identical issue. But didn't seem to have an
elegant solution.
Thanks,
Daniel Tavares
Programmer | Slipgate Ironworks
http://www.slipg8.com
_______________________________________________
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