[CMake] Problem copying generated files in an out-of-source build

Eric Tellefsen eric.tellefsen at db.com
Thu Sep 24 14:18:15 EDT 2009


I am having some trouble with the following.

I have a static library project which has a tree structure of the main 
directory and a group of sub directories.  The main project has a 
CMakeLists.txt file as well as the sub directories.  Each of the sub 
directories CMakeLists.txt file generates .cpp & .h files from a .wsdl 
file via calls to gSoap executables.  When make is run, all the sub 
directory files are generated into the respective CMAKE_CURRENT_BINARY_DIR 
locations, and then compiled by the project level generated Makefile.  All 
of this works fine.

My seemingly simple problem is as follows.  This library and all of the 
others being used by my group, I have just converted to CMake and am using 
out-of-source builds.  Another library depends on the WSDL (mentioned 
above) sub directories for header files which are generated into 
CMAKE_CURRENT_BINARY_DIR.  Unfortunately this inter-library dependency is 
looking to the CMAKE_CURRENT_SOURCE_DIR.  When this library builds 
out-of-source, it cannot find  these headers and the compile fails.

My short-term solution was to copy these files from the respective BINARY 
to SOURCE directories using a custom command.  This does not seem to work 
and I cannot understand why.  I've put this code into both the master 
CMakeLists.txt  as well as the specific subdirectory CMakeLists.txt file.

Am I taking the wrong approach?  Is my syntax for the custom command 
incorrect?  I'm stumped and could use some suggestions from the group.

Thanks

Eric

Custom command is below

macro( GenericFileCopy Filename FromDir ToDir )

ADD_CUSTOM_COMMAND(
        OUTPUT  ${ToDir}/${Filename}
        COMMAND ${CMAKE_COMMAND} -E chdir ${FromDir} cp ${Filename} 
${ToDir}
        DEPENDS ${FromDir}/${Filename}
        COMMENT "Copying ${FromDir}/${Filename} to ${ToDir}"
        )
endmacro( GenericFileCopy )


---
This communication may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this communication
in error) please notify the sender immediately and destroy this
communication. Any unauthorized copying, disclosure or distribution of the
material in this communication is strictly forbidden.

Deutsche Bank does not render legal or tax advice, and the information
contained in this communication should not be regarded as such.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090924/3a0cdeba/attachment.htm>


More information about the CMake mailing list