[CMake] add_custom_command with PRE_BUILD and makefiles

Kirill Kranke kranke.kirill at gmail.com
Mon Oct 25 14:29:21 EDT 2010


Hi All,

after moving from Visual Studio to Eclipse I realised that PRE_BUILD command
does not work as expected.

According to documentation:

'Note that the PRE_BUILD option is only supported on Visual Studio 7 or
later. For all other generators PRE_BUILD will be treated as PRE_LINK.'

I was suprised with that, because usually when one use makefile, he can
create additional target to perform files copy operations and etc.

I found old thread in this mail list on same question:
http://www.cmake.org/pipermail/cmake/2007-December/018445.html

I guess no one had time to take a closer look into this problem

There is, actually, wery simple workaround using cmake:

# Add pre_build target
add_custom_target(SOMETARGET_prebuild DEPENDS SOMEDEPENDANCIES)
add_dependencies(SOMETARGET SOMETARGET_prebuild)

add_custom_command(
TARGET SOMETARGET_prebuild
POST_BUILD
COMMAND do some stuff)

I was just wondering if it could be possible to integrate into
add_custom_comman() such sollution for makefiles? It could make cmake code
look nicer and make life much easier.

Here are some arguments for it: In example above things look quite simple,
but if I want to add a few commands to one project from MACRO (what I
actually do)? How should I check wheather SOMETARGET_prebuild (or whatever)
already has been created? Defently there some simple precautions to avoid
doube add, but I guess it should be nicer to automate it.

In any case, thanks for a great tool!

Best regards,

Kirill Kranke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101025/d333ea18/attachment.htm>


More information about the CMake mailing list