[CMake] Generating source file one step before linking

Doug douglas.linder at gmail.com
Fri Jun 15 01:42:56 EDT 2012


Perhaps this is what you're looking for:
http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:add_custom_command

For example, this command copies a set of libraries into a directory:
if(WIN32)
  foreach(ITEM ${DEP_SHARED_LIBRARIES})
    add_custom_command(TARGET mytarget PRE_BUILD COMMAND ${CMAKE_COMMAND}
-E copy ${ITEM} .  WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Copying
${ITEM} to ${PROJECT_BINARY_DIR}")
  endforeach()
endif()

You could use the PRE_LINK key and what ever your custom command is I
expect.

~
Doug.

On Thu, Jun 14, 2012 at 4:59 PM, Johannes Bauer <dfnsonfsduifb at gmx.de>wrote:

> Dear list,
>
> I'd like to know if the following is possible: in my old buildsystem
> (that I'm trying to convert to cmake) there is a script which runs just
> before the linking stage. It examines the created objects and then
> creates a source-file which needs to be linked in. The way this was done
> before is something like this (pseudo-Makefile syntax):
>
> execut: $(OBJS)
>        ./generate_code
>        gcc $(LDFLAGS) $(OBJS) generated.c -o execut
>
> .c.o:
>        gcc -c blah
>
>
> Is it possible to achieve something similar with cmake? I've read the
> FAQ about generating code, but I do not know how to control the
> dependencies (i.e. at which stage it is executed).
>
> Best regards,
> Johannes
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120615/6fc7a293/attachment.htm>


More information about the CMake mailing list