Maik Keller <> wrote:

> Hi Alex,
> 
> I prefer to use the class, which is contained in the automatically
> generated ui-header file, as a base class for an extended
> implementation of the widget. Therefore I have to include the header
> of that class. So it would be nice to locate the base class in the
> same directory like the derived class (somewhere in my sources - and
> not in the build-directory).     
> 
> In case of the moc-file it is not that important. But it would be
> also nice to have the location under the control of the user. 
> 
> Would there be a possibility to use cmake's "ADD_CUSTOM_COMMAND"? I
> appreciate any help of defining such custom commands for ui and moc
> files. I tried it on my own, but I failed...  

As a reference point, here is the macro I use:

# Run Qt UIC on a UI file.
# Arguments:
#    1-N   Names of .ui files
MACRO(AIS_UI)
   FOREACH (it ${ARGN})
      GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
      SET(outhfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.h)
      SET(outcppfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_uic.cpp)
      ADD_CUSTOM_COMMAND(OUTPUT ${outhfile}
         COMMAND ${QT_UIC_EXECUTABLE} ARGS -o ${outhfile}
${CMAKE_CURRENT_SOURCE_DIR}/${it}
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
         MAIN_DEPENDENCY ${it}
         DEPENDS ${it}
      )
      ADD_CUSTOM_COMMAND(OUTPUT ${outcppfile}
         COMMAND ${QT_UIC_EXECUTABLE} ARGS
${CMAKE_CURRENT_SOURCE_DIR}/${it} -impl ${outhfile} -o ${outcppfile}
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
         MAIN_DEPENDENCY ${it}
         DEPENDS ${it} ${outhfile})
        SET(CPP_SOURCE ${CPP_SOURCE} ${outcppfile})
      AIS_MOC(${outhfile})

      SET(AIS_UIC_SOURCES ${AIS_UIC_SOURCES} ${outcppfile})
      LIST(APPEND AIS_UIC_HEADERS ${outhfile})
   ENDFOREACH (it)
ENDMACRO(AIS_UI)

Note that this also generates the header file out-of-source - therefore
I have this line in another macro:

   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

(This macro is used in all my projects).

-Torsten

This e-mail and any files sent with it contain information that may be 
privileged or confidential and is the property of the GateHouse Group. This 
information is intended solely for the person to whom it is addressed. If you 
are not the intended recipient, you are not authorized to read, print, retain, 
copy, disseminate, distribute, or use the message or any part thereof. If you 
have received this e-mail in error, please notify the sender immediately, and 
delete all copies of this message. In accordance with GateHouse Security 
Policy, e-mails sent or received may be monitored. 
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to