[CMake] Out-of-source build with QT_WRAP_UI

Roy van Pelt r.f.p.v.pelt at tue.nl
Wed Jun 25 04:28:17 EDT 2008


Dear all, 

I'm trying to create the following situation, but so far I did not
manage to do so with the examples I found on the Internet.

I have:

build_linux\
  CMakeLists.txt
src
  ui
    mainWindow.ui
  main.cxx
  main.h
CMakeLists.cxx

The root CMakeLists uses SUBDIR to run the CMakeLists for my Linux
build. Now I want QT_WRAP_UI to generate the necessary header and source
files. By default however it places them in the build directory?!

How can I get the generated files to be generated in the ui directory?

I include the current CMakeLists.txt for the linux build below.

Thanks in advance.

#============================================================================
SET(EXECUTABLE_NAME bmrvis)

SET(SRC_DIR ../src)
SET(GUI_DIR ../src/ui)

#-------------------------------------------------------------------------------
# Find Qt package library and include files.
#-------------------------------------------------------------------------------
SET(DESIRED_QT_VERSION  ${VTK_DESIRED_QT_VERSION}  CACHE FILEPATH "")

FIND_PACKAGE(Qt4 REQUIRED)
IF(QT_USE_FILE)
        INCLUDE(${QT_USE_FILE})
ELSE(QT_USE_FILE)
        SET(QT_LIBRARIES ${QT_QT_LIBRARY})
ENDIF(QT_USE_FILE)

#-------------------------------------------------------------------------------
# Build list of class files.
#-------------------------------------------------------------------------------
SET(CLASSES  
  main
)

FOREACH(class ${CLASSES})
  SET(SOURCES ${SRC_DIR}/${class}.cxx ${SRC_DIR}/${class}.h)
ENDFOREACH(class)

#-------------------------------------------------------------------------------
# Build list of ui files.
#-------------------------------------------------------------------------------
SET(GUI_FILES
  QMainWindow
)

FOREACH(guifile ${GUI_FILES})
  SET(GUI ${GUI_DIR}/${guifile}.ui)
ENDFOREACH(guifile)

IF (QT_WRAP_UI)
  QT_WRAP_UI(bmrvis_gui_lib GUI_HEADERS GUI_SOURCES ${GUI} )
ENDIF (QT_WRAP_UI)

#-------------------------------------------------------------------------------
# Specify that given list of source files is part of final library. 
#-------------------------------------------------------------------------------
ADD_EXECUTABLE(${EXECUTABLE_NAME} ${SOURCES} ${GUI_SOURCES} )

#-------------------------------------------------------------------------------
# Specify what other library files need to be linked with this one.
#-------------------------------------------------------------------------------
TARGET_LINK_LIBRARIES(
  ${EXECUTABLE_NAME} 	
  vtkCommon
  vtkRendering
  ${QT_LIBRARIES}
)


More information about the CMake mailing list