[CMake] CMake + UIC files -- Is this a bug with CMake or with me?

Michael Wild themiwi at gmail.com
Tue Jul 20 15:52:47 EDT 2010


Hi

I hope the inline comments below solve your problems. And please, don't cross-post...

On 20. Jul, 2010, at 19:06 , kent williams wrote:

> This is with cmake version 2.8.1 on OS X 10.6.
> 
> I had a project using CMake and Qt.  As long as I only used one QT
> Designer-generated .ui file, everything worked perfectly. When I added
> as second UI file, things no longer worked. I was working from the
> CMake + Qt4 examples on the web.
> 
> There are two problems:
> 
> 1. If you give a list of more than one header file as the dependency
> on set_source_files_properties, it throws a configure-time error:
> 
> 
> CMake Error at CMakeLists.txt:33 (set_source_files_properties):
>  set_source_files_properties called with incorrect number of arguments.
> 
> 2. If I work around that error (by setting each header dependency
> individually), then only one of the UI files seems to get processed to
> create the corresponding C++ header file:
> 
> /scratch/kent/qtcmake/src/QTCMake.cxx:4:35: error:
> ui_qvtkpropertydialog.h: No such file or directory
> 
> I've put a succinct example illustrating the problem I'm having here:
> http://www.cornwarning.com/xfer/QTCmakeTest.tar.gz
> 
> The CMakeLists.txt file is as follows:
> 
> project(QTCMake)
> cmake_minimum_required(VERSION 2.8)
> 
> #uses QT4 and associated CMake Macros
> find_package( Qt4 REQUIRED )
> include(${QT_USE_FILE})
> set(QT_USE_QTXML 1)
> 
> 
> #dummy test program
> set(QTCMake_SRC QTCMake.cxx)
> 
> 
> # list of QT Designer-generated XML designs
> set(QTCMake_UIS
> qvtkpropertydialog.ui qimagetransformdialog.ui
> )
> 
> #
> # this is supposed to wrap all the UI files
> QT4_WRAP_UI(UIHeaders ${QTCMake_UIS} )
> 
> include_directories(${CMAKE_CURRENT_BINARY_DIR})
> 
> add_executable(QTCMake ${QTCMake_SRC})
> 
> if(GUMBY)
> #
> # unless I misunderstood, this should make the objects
> # depend on the headers generated by UIC.
> # This doesn't work as it should; I don't know why
> set_source_files_properties(${QTCMake_SRC}
> PROPERTIES OBJECT_DEPENDS ${UIHeaders})

Just wrap ${UIHeaders} in quotes:

set_source_files_properties(${QTCMake_SRC} PROPERTIES
  OBJECT_DEPENDS "${UIHeaders}")

> 
> else()
> #
> # this loops through the list of ui_*.h, and adds the dependency
> # for each.
> foreach(hdr ${UIHeaders})
> set_source_files_properties(${QTCMake_SRC}
> PROPERTIES
> OBJECT_DEPENDS ${hdr})
> endforeach()

This loop isn't going to append to the list of dependencies, it overwrites the previous value instead. If you want appending, you have to use the following instead:

foreach(hdr IN LISTS UIHeaders)
  set_property(SOURCE ${QTCMake_SRC} APPEND PROPERTY
    OBJECT_DEPENDS ${hdr})
endforeach()

> 
> endif()
> 

HTH

Michael



More information about the CMake mailing list