[CMake] ADD_CUSTOM_COMMAND, PRE_BUILD

Pau Garcia i Quiles pgquiles at elpauer.org
Tue Dec 23 15:53:31 EST 2008


On Tue, Dec 23, 2008 at 9:38 PM, Andrey Sploshnov
<ice.nightcrawler at gmail.com> wrote:
> From documentation to CMake 2.6.x:
>
> "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'm using Visual Studio 9, which is newer than VS7, so PRE_BUILD
should be supported

> What are you actually trying to do?

I'm generating .cpp and .h filesfrom .ice files (something like
CORBA's IDL), which I later compile into the 'thetarget' library.

> If you want to perform some actions before actually build the target, use of
> add_custom_target() may be better idea. Something like this:

No, I don't want to use add_custom_target() because it is considered
always out-of-date:

"The target has no output file and is ALWAYS CONSIDERED OUT OF DATE
       even if the commands try to create a file with the name of the target."

If I used add_custom_target(), .h/.cpp files would always be
generated, compiled and linked and I don't want that to happen because
several executables depend on that library.

> add_custom_target (thetarget
>
>                                  COMMAND touch
> ${CMAKE_CURRENT_BINARY_DIR}/helloworld
>                                  WORKING_DIRECTORY
> ${CMAKE_CURRENT_SOURCE_DIR}
>
>                                  COMMENT "Prebuild action before build
> MainTarget"
> )
>
> add_executable (MainTarget
>
>                             ${SOURCES}
>
> )
>
> add_dependecies (MainTarget thetarget)
>
> On Tue, Dec 23, 2008 at 10:41 PM, Pau Garcia i Quiles <pgquiles at elpauer.org>
> wrote:
>>
>> Hello,
>>
>> I'm trying ADD_CUSTOM_COMMAND(TARGET ... PRE_BUILD) but it does not
>> work here. This is how I'm using it:
>>
>> ADD_CUSTOM_COMMAND(TARGET thetarget
>>                                        PRE_BUILD
>>                                        COMMAND touch
>> ${CMAKE_CURRENT_BINARY_DIR}/helloworld
>>                                        WORKING_DIRECTORY
>> ${CMAKE_CURRENT_SOURCE_DIR}
>>                                        COMMENT "Blah"
>>                                        )
>>
>> I've tried with the "NMake Makefiles" and "Visual Studio 9 2008"
>> generators, with CMake 2.6.2 and CVS 2.7-20081222 but it does not work
>> ('touch' is installed and in the PATH, that's not the problem).
>>
>> Am I doing anything wrong? :-?
>>
>> Thank you.
>>
>> --
>> Pau Garcia i Quiles
>> http://www.elpauer.org
>> (Due to my workload, I may need 10 days to answer)
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
> No fate, but what we make!
>



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the CMake mailing list