[CMake] Custom Command Execution

Jeroen Dierckx jeroen.dierckx at gmail.com
Mon Sep 21 11:40:51 EDT 2009


On Mon, Sep 21, 2009 at 4:15 PM, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2009/9/21  <th.tom at gmx.de>:
>> Hi,
>>
>> I have the following CMakeLists.txt:
>>
>> ---------
>> cmake_minimum_required(VERSION 2.6)
>> MESSAGE (" CMAKE TEST ")
>>
>> ADD_CUSTOM_COMMAND (TARGET Hello PRE_BUILD
>>                    COMMAND ${CMAKE_COMMAND} -E echo "Prebuild execution"
>>                    COMMENT "Information string for prebuild execution"
>> )
>>
>> ADD_EXECUTABLE ( Hello abc.cpp )
>> ---------
>>
>> Why is the custom command not executed? Is it meat different?
>
> From my testing side (CMake 2.6.4 / Unix Makefile / Linux )
> it looks like you need to put your ADD_CUSTOM_COMMAND definition
> AFTER the ADD_EXECUTABLE statement.

This is normal, because you specify a target (that has to exist) to
add the custom command to. IIRC, this is the case for all
target-specific commands and variables.


> May be this deserves a bug report since when you write it before it
> behaves as silently ignored.

I agree, a warning or error should be raised if the specified target
doesn't exist.


>
> Note that on Linux the doc is right:
>
> "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."
>
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> _______________________________________________
> 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