[CMake] generating source files with ADD_CUSTOM_COMMAND

David Cole david.cole at kitware.com
Thu Jul 1 14:58:22 EDT 2010


I think you mean:
${CMAKE_COMMAND} -E copy src dst

You forgot the -E.


On Thu, Jul 1, 2010 at 2:38 PM, Hicham Mouline <hicham at mouline.org> wrote:

> Hello
>
> I'm trying to generate source files .cxx and include them in ADD_LIBRARY to
> build a static library, according to
>
> http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_
> the_build.3F
>
> #
> # Copy template source files to *.cxx and place them in the build dir
> #
> ADD_CUSTOM_COMMAND(
>  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/name.cxx
> ${CMAKE_CURRENT_BINARY_DIR}/widget.cxx
>  COMMAND ${CMAKE_COMMAND} copy
> ${CMAKE_SOURCE_DIR}/systems/template_name.cpp
> ${CMAKE_CURRENT_BINARY_DIR}/name.cxx
>  COMMAND ${CMAKE_COMMAND} copy
> ${CMAKE_SOURCE_DIR}/systems/template_widget.cpp
> ${CMAKE_CURRENT_BINARY_DIR}/widget.cxx
>  DEPENDS ${CMAKE_SOURCE_DIR}/template_name.cpp
> ${CMAKE_SOURCE_DIR}/systems/template_widget.cpp
> )
>
> ADD_LIBRARY(mylib STATIC
>  main.cpp parameters.hpp
>  ${CMAKE_CURRENT_BINARY_DIR}/name.cxx
>  ${CMAKE_CURRENT_BINARY_DIR}/widget.cxx
> )
>
>
> The vs2008 solution is generated with the Solution explorer showing the
> .cxx
> files, but they are actually nowhere to be found.
>
> Regards,
>
> _______________________________________________
> 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/20100701/c06f4996/attachment.htm>


More information about the CMake mailing list