[Cmake] ADD_CUSTOM_COMMAND and PRE_BUILD
Ken Martin
ken.martin at kitware.com
Mon, 19 Apr 2004 10:19:25 -0400
PRE_BUILD and PRE_LINK are the same for Visual Studio 6 and all makefiles.
They both act like PRE_LINK. (Brad said they were POST_BUILD which if so we
need to change to PRE_LINK) Thanks for the reminder. We intended to modify
the rules for the Makefile to support PRE_BUILD but looking into it quickly
I'm not sure makefiles can handle PRE_BUILD. PRE_BUILD can be pretty useful
but if only Visual Studio 7 can handle it then we may have to remove it.
Thanks
Ken
> PRE_BUILD - run before all other dependencies
> PRE_LINK - run after other dependencies
> POST_BUILD - run after the target has been built
>
> So I'd like to use the PRE_BUILD to get my custom command to run
> before any of the dependencies for the named target are built.
> Here's my sample project:
>
> ::::::::::::::
> CMakeLists.txt
> ::::::::::::::
> PROJECT(dummyproj)
>
> ADD_LIBRARY(dummylib SHARED foo.cpp)
>
> ADD_CUSTOM_COMMAND(
> TARGET dummylib
> PRE_BUILD
> COMMAND cp
> ARGS -v /etc/hosts ${dummyproj_BINARY_DIR})
>
> ::::::::::::::
> foo.cpp
> ::::::::::::::
> class Foo
> {
> int a;
> int b;
> };
>
> So I'd like the 'cp' command to execute before any dependencies of
> dummylib are built. Yet the output shows that the 'cp' command is
> happening after foo.o and libdummylib.so are built. I'd like the 'cp'
> command to happen before both of them are built. What am I doing
> wrong?
>
> $ cmake ../dummyproj
> -- Check for working C compiler: gcc
> -- Check for working C compiler: gcc -- works
> -- Check for working CXX compiler: g++
> -- Check for working CXX compiler: g++ -- works
> -- Configuring done
> -- Generating done
> $ make
> Building dependencies. cmake.depends...
> cmake.depends is up-to-date
> Building object file foo.o...
> Building shared library libdummylib.so...
> `/etc/hosts' -> `/home/rutt/dev/dummyproj/build/hosts'