You might be able to configure the file twice - once during configure time (so dependency generation and adding to the build work right), and then again before the build - Take a look at the add_custom_command documentation, especially the PRE_BUILD part.

Ryan

On 01/15/2010 08:44 AM, Marcel Loose wrote:
Hi Jack,

The difference with your and my case is that you have an input file
(the .xsd file) and output files (the .h and .cpp files). In my case I
generate the output file, e.g. myheader.h, from myheader.h.in, using
configure_file(). The problem is that I cannot get this to work during
'make', only during 'cmake'.

Best regards,
Marcel Loose.

On Fri, 2010-01-15 at 15:04 +0100, Smith Jack (Ext. - UGIS - UniCredit
Group) wrote:
I do a similar thing with an XSD file from which I generate c++
wrapper classes for accessing the corresponding XML
Note the DEPENDS line !

MACRO(XSD FILE NAMESPACE)
     ADD_CUSTOM_COMMAND(
         OUTPUT  ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.cpp
         OUTPUT  ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.h
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.xsd
         COMMAND ${XAPI_CODESYNTH}/bin/xsd
         ARGS cxx-tree --generate-serialization --hxx-suffix .h
--cxx-suffix .cpp --fwd-suffix -fwd.hxx --type-naming java
--function-naming java --namespace-map =${NAMESPACE}
--generate-polymorphic --output-dir ${CMAKE_CURRENT_SOURCE_DIR}/xml
${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.xsd
         COMMENT "generating Codesynthesis Wrappers")
ENDMACRO(XSD)



-----Original Message-----
From: cmake-boun...@cmake.org
[mailto:cmake-boun...@cmake.org] On Behalf Of Marcel Loose
Sent: Friday, January 15, 2010 2:55 PM
To: cmake@cmake.org
Subject: [CMake] How to regenerate source file during make?

Hi all,

I've been struggling with this for hours now and I can't seem
to get a grip on it.

I have a header file that must be (re)generated during 'make'
when some external data have changed. I can successfully
generate this file during 'cmake' using configure_file(), but
I haven't been able to figure out how I can trigger the
configure_file() during make.

Should I define a target for this header file? Or can I
specify some kind of file dependency, such that when the
header file is missing our out-of-date, it will be (re)generated?

I guess it must be some clever combination of
add_custom_command() and add_custom_target().

Best regards,
Marcel Loose.


_______________________________________________
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

_______________________________________________
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

_______________________________________________
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

--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpav...@iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik

_______________________________________________
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

Reply via email to