[CMake] change the moc_file directory

Brad King brad.king at kitware.com
Tue Aug 23 13:32:05 EDT 2005


Sören Freudiger wrote:
> Is it possible to change the directory the moc files will be generated in?
> 
> Right now I have following structure (just an example):
> 
> D:/test/source/function/presentation/QTHeader.h
> D:/test/source/function/presentation/CMakeLists.txt
> D:/test/bin/CMakeLists.txt
[snip]
> Questions:
> 1. How can I set the correct path in the rules 
> (moc:
> D:/test/source/source/basics/utilities/presentation/QFunction2DWidget.h:?

The CMakeLists.txt files can just be in the source directory and then 
you won't need ../-style paths.  If you really want to keep CMake code 
outside the tree you can do

GET_FILENAME_COMPONENT(MY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
SET(MY_SRC ${MY_ROOT}/source)

in the bin/CMakeLists.txt file.

> 2. In general, can I define the moc_file output directory?

You'll have to look in the FindQt* modules to see if it is possible 
without editing them.  If not please submit a feature request here:

http://www.cmake.org/Bug

-Brad


More information about the CMake mailing list