[CMake] generating source files with ADD_CUSTOM_COMMAND

Hicham Mouline hicham at mouline.org
Thu Jul 1 14:38:30 EDT 2010


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,



More information about the CMake mailing list