[CMake] Cmake 2.2.3 in combination with Qt (4.1.2) and ITK 2.6.0

Huisman, A. A.Huisman-4 at umcutrecht.nl
Tue Apr 4 09:27:35 EDT 2006


Hello,

When upgrading to Microsoft Visual Studio 2005 I upgraded some other tools as well, i.e. Cmake, Qt and ITK. I want to use the Qt userinterface files (.ui). However, my old cmakelists.txt does not work anymore, Cmake gives lots of errors. There appears to be a problem with the naming of my variables they are not in the ${variable} format, that's maybe not correct, but it used to work. 
 I could not find any example online that uses (more strict??)  Cmake 2.2.3 in combination with those Qt ui-files. 
Is there anyone who can provide me with an example of a correct Cmake makefile suitable for usage with Qt and I would be even more happy when ITK and VTK are involved as well... Attached is the old version of the file I was using.

Thanks a lot!!!
André Huisman
-------------- next part --------------
PROJECT(qtMiep)

SET(QT_MAX_VERSION "4.9.9")

FIND_PACKAGE(ITK)
IF(ITK_FOUND)
	INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
	MESSAGE(FATAL_ERROR
        "Cannot build InsightApplications without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
  MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})

SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
FIND_PACKAGE(Qt)

SET(qtMiep_GUI_SRCS 
	TextureFeatCompuCtrl.ui
	PreferencesDialogUi.ui
	DataViewWindowUi.ui
	LogWindowUi.ui
)

SET(QT_WRAP_UI "1")
IF(QT_WRAP_UI)
    QT_WRAP_UI(qtMiep qtMiep_HDRS qtMiep_SRCS qtMiep_GUI_SRCS )
ENDIF(QT_WRAP_UI)

SET(qtMiep_SRCS
  Main.cpp
	MainWindow.cpp
	ImageViewer.cpp
	Settings.cpp
	Settings.h
	MainWindow.h
	ImageViewer.h
	itkImageToVTKImageFilter.txx
	itkVTKImageToImageFilter.txx
	itkImageToVTKImageFilter.h
	itkVTKImageToImageFilter.h
	PipeData.cpp
	PipeData.h
	PipeDatParser.h
	PipeDatParser.cpp
	Pipe3DObj.h
	Pipe3DObj.cpp
	stdwx.h
	ImageModel.h
	ImageModel.txx
	Tools.h
	Tools.cpp
	Tools.txx
	Cell.h
	Cell.txx
	TextureFeatureComputations.txx
	TextureFeatureComputations.h
	TextureFeatureSelectionDialog.cpp
	TextureFeatureSelectionDialog.h
	PreferencesDialog.h
	PreferencesDialog.cpp
	TextureFeatureComputationThreader.h
	TextureFeatureComputationThreader.cpp
	DataViewWindow.cpp
	DataViewWindow.h
	LogWindow.cpp
	LogWindow.h
	qtMiep_HDRS
)

#MOC src are include files containing Q_OBJECT macro
SET(QtITK_MOC_SRCS 
	MainWindow.h
	ImageViewer.h
	TextureFeatureSelectionDialog.h
	PreferencesDialog.h
	LogWindow.h
	TextureFeatureComputationThreader.h
	DataViewWindow.h
)

IF(QT_WRAP_CPP)
  QT_WRAP_CPP(QtITK qtMiep_SRCS QtITK_MOC_SRCS)
ENDIF(QT_WRAP_CPP)


# Use the include path and library for Qt that is used by VTK.
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
                     ${QT_QTCORE_INCLUDE_DIR})

ADD_EXECUTABLE( qtMiep MACOSX_BUNDLE ${qtMiep_SRCS})

# note: if you use Mesa in VTK and get link errors about opengl symbols
#       they are coming from Qt.  Either link OpenGL in, configure Qt to
#       dlopen the GL library, or configure Qt without OpenGL support.

#IF(WIN32)
#	SET_TARGET_PROPERTIES(qtMiep PROPERTIES COMPILE_FLAGS "/Yc\"stdwx.h\"")
#   SET_TARGET_PROPERTIES(qtMiep PROPERTIES LINK_FLAGS "/nodefaultlib:msvcrtd.lib")
#ENDIF(WIN32)

SET(QT_LIBS "${QT_LIBRARIES}")

IF(QT_INST_MAJOR_VERSION GREATER 3)
  IF(CMAKE_BUILD_TYPE)
    SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
                optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
  ELSE(CMAKE_BUILD_TYPE)
    IF(CMAKE_CONFIGURATION_TYPES)
      SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
                  optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
    ELSE(CMAKE_CONFIGURATION_TYPES)
      SET(QT_LIBS ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
    ENDIF(CMAKE_CONFIGURATION_TYPES)
  ENDIF(CMAKE_BUILD_TYPE)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
  SET(QT_LIBS ${QT_QT_LIBRARY})
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)

IF(WIN32)
  ADD_DEFINITIONS(-DQT_DLL) 
ENDIF(WIN32)

#IF(WIN32)
#  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /subsystem:windows") 
#ENDIF(WIN32)


TARGET_LINK_LIBRARIES( qtMiep
  QVTK
  ${QT_LIBS}
  ITKIO
  vtkRendering
  vtkGraphics
  vtkIO
  vtkCommon
  vtkHybrid
  vtkGenericFiltering
  vtkVolumeRendering
  ITKBasicFilters
  itksys
  ITKStatistics
)


More information about the CMake mailing list