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

Eric Tellefsen eric.tellefsen at db.com
Mon Sep 28 14:42:30 EDT 2009


Anatoly,

Thanks for the advice - I included the binary dir and all is well

Eric

Anatoly Shirokov <shirokov_a at mail.ru> wrote on 09/25/2009 12:25:16 AM:

> May be it helps:
> 
> generated/CMakeLists.txt:
> 
> project (generated)
> 
> add_custom_command(...)
> ...
> depends_on_generated/CMakeLists.txt:
> 
> project(depends_on_generated)
> ...
> # add the generated binary dir to the search paths
> include_directories(${generated_BINARY_DIR})
> ...
> 
> BR, Anatoly
> 
> Eric Tellefsen:
> >
> > 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.
> > 
------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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


---
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/20090928/9e2c2e08/attachment-0001.htm>


More information about the CMake mailing list