cmake issue: generated files in subdirs
Alexander Neundorf
neundorf at kde.org
Thu Mar 23 22:49:03 GMT 2006
On Thursday 23 March 2006 23:21, Aaron J. Seigo wrote:
> On Thursday 23 March 2006 14:42, Alexander Neundorf wrote:
> > On Thursday 23 March 2006 22:06, you wrote:
> > > On Thursday 23 March 2006 12:01, Alexander Neundorf wrote:
> > > #include <dir/generatedfile.h>
> >
> > Ok, this is indeed a problem.
>
> =/
>
> > > but generatedfile.h is in the top level dir. it just means more porting
> > > work and was a bit surprising to see generated files not ending up in
> > > the buildtree where they were in the sourcetree.
> >
> > Well, it would be possible to generate the file in
> > ${CMAKE_CURRENT_SOURCE_DIR}/subdir/generatedfile.h . Something like
> >
> > get_filename_component(absPathToFile file.ui ABSOLUTE)
> > get_filename_component(absPath ${absPathToFile} PATH)
> > file(RELATIVE_PATH relPath ${CMAKE_CURRENT_SOURCE_DIR} ${absPath} )
> > set(outputFile ${CMAKE_CURRENT_BINARY_DIR}/${relPath}/file.h )
>
> hmm... where would this go? in the projects CMakeLists.txt file or .. ?
Something like
macro(make_build_tree_location result infile outfileName)
get_filename_component(absPathToFile ${infile} ABSOLUTE)
get_filename_component(absPath ${absPathToFile} PATH)
file(RELATIVE_PATH relPath ${CMAKE_CURRENT_SOURCE_DIR} ${absPath} )
set(${result} ${CMAKE_CURRENT_BINARY_DIR}/${relPath}/${outfileName} )
endmacro(make_build_tree_location result file )
in an own file kdelibs/cmake/modules/MakeBuildTreeLocation.cmake I'd say,
so that it can then be used:
make_build_tree_location(outFile file.ui file.h)
...
> > At least the example you give above cannot work for KDE, independently
> > from the buildsystem (see explanation above).
> >
> > If we reintroduce convenience libs it will work, otherwise it can't.
>
> even with -I. and requiring that files outside of '.' must refer to paths
> properly in #includes (e.g. #include "modules/mod1/module.h")? that at
> least is a more common requirement IME. or is this because cmake doesn't
> actually run gcc from the directory the file is in, but from the base
> directory handing gcc a relative path to the file to be compiled?
cmake runs gcc from the builddir, so with out-of-source builds, the includes
are only found via the include path.
Bye
Alex
--
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org - http://www.kde.org
alex AT neundorf.net - http://www.neundorf.net
More information about the kde-core-devel
mailing list