[CMake] Custom directories for QT4

Mike Jackson imikejackson at gmail.com
Mon Oct 29 13:07:24 EDT 2007


No.. and here is why. If you open the FindQt4.cmake file that Cmake  
installs and look for MACRO (QT4_WRAP_UI outfiles ) you can see  
exactly what cmake is going to do.

   MACRO (QT4_WRAP_UI outfiles )
     FOREACH (it ${ARGN})
       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
         COMMAND ${QT_UIC_EXECUTABLE}
         ARGS -o ${outfile} ${infile}
         MAIN_DEPENDENCY ${infile})
       SET(${outfiles} ${${outfiles}} ${outfile})
     ENDFOREACH (it)
   ENDMACRO (QT4_WRAP_UI)

Now what you _might_ want to do is hack this to be something like:

   MACRO (QT4_WRAP_UI outfiles )
     FOREACH (it ${ARGN})
       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
# -- Watch the next line.....
       SET(outfile ${QT4_GENERATED_UI_FILE_HEADERS}/ui_${outfile}.h)
       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
         COMMAND ${QT_UIC_EXECUTABLE}
         ARGS -o ${outfile} ${infile}
         MAIN_DEPENDENCY ${infile})
       SET(${outfiles} ${${outfiles}} ${outfile})
     ENDFOREACH (it)
   ENDMACRO (QT4_WRAP_UI)

And in your own cmake file define the following:
set (QT4_GENERATED_UI_FILE_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/UI_Files)

Be sure to define that BEFORE calling the macro. I _think_ this  
should work but is completely untested. Is that more what you were  
looking for?

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Oct 29, 2007, at 12:47 PM, Andreas Pakulat wrote:

> On Montag, 29. Oktober 2007, Marcin Gil wrote:
>> Hi!
>>
>> Using qmake and it's project files one can define locations eg for
>> moc/ui parsed files.
>> The variables are UI_DIR for UI generated headers location and
>> MOC_DIR for moc generated files.
>>
>> Simply setting set (UI_DIR ui) doesn't work.
>>
>> Is there a way to force generation of those files to directories I
>> want? So that after:
>>
>> set (xx_UIS xx.ui)
>> qt4_wrap_ui(xx_UIS_H ${xx.UIS})
>>
>> those would land in "ui" subdirectory?
>
> I may be overlooking something, but the usual use-case for this with
> QMake is to either not clutter the source tree with buildfiles or to
> have different output directories for different build-configurations.
>
> Neither of the two applies to CMake, it encourages to use out-of- 
> source
> builds which means you don't get crap into your source tree. And also
> with CMake you can't have a builddir containing multiple output files
> frmo different configuration. As soon as you switch from release to
> debug build everything gets rebuild anyway.
>
> So, I think the answer to your question is: no thats not possible with
> CMake, but its also not needed.
>
> Andreas
>
> -- 
> Advancement in position.
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list