[CMake] Using QT with ITK

Julien Marchand jmarchand at gmail.com
Tue Apr 18 15:04:08 EDT 2006


Hi!

I have to do a program integrating both Qt and ITK. Therefore, I have
to use Cmake. However, I'm having trouble building my cmakelists. More
precisely, I have trouvle with Qt_WRAP_CPP and QT_WRAP_UI.

I get a "Attempt to add custom rule to output "moc_pline.cxx" which
already has a custom rule" error. In fact, it happens for all my
sources once with the moc_ prefix and once without it (moc_pline.cxx
and pline.h).

I suspect I have a bug with my CMakeList, but I fail to spot it. Here
is my CMakeLists.txt.


Thanks a lot,

Julien Marchand


PROJECT(QtChange)

FIND_PACKAGE (ITK)
	IF (ITK_FOUND)
		INCLUDE( ${USE_ITK_FILE} )
	ENDIF(ITK_FOUND)

FIND_PACKAGE (QT)
	IF (QT_FOUND)
		INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
	ENDIF(QT_FOUND)

LINK_LIBRARIES (${ITKLIBRARIES} ${QT_LIBRARIES} )

SET(QtITK_SRCS
		main.cpp
		roadNetwork.cpp
		road.cpp
		pline.cpp)
		
SET(QtITK_HDRS
		roadNetwork.h
		road.h
		pline.h)
		
SET(QtITK_MOC_SRCS
		window.ui)

	IF(QT_WRAP_CPP )
		QT_WRAP_CPP(QtChange ${QtITK_SRCS} ${QtITK_MOC_HDRS})
	ENDIF(QT_WRAP_CPP )
	
	IF(QT_WRAP_UI)
 		QT_WRAP_UI(QtChange ${QtITK_HDRS} ${QtITK_SRCS} ${QtITK_MOC_SRCS})
 	ENDIF(QT_WRAP_UI)

ADD_EXECUTABLE(QtChange ${QtITK_SRCS} ${QtIRK_HDRS})

TARGET_LINK_LIBRARIES(QtChange
	   ITKAlgorithms
	   ITKBasicFilters
	   ITKCommon
	   ITKIO
	   ITKMetaIO
	   ITKNumerics
	   itkvnl
	   itkvnl_algo
	   itknetlib
		${QT_LIBRARIES})


More information about the CMake mailing list