[vtkusers] Wrong CMake configuration for VTK+Qt-Projects in Visual Studio
Rocco Gasteiger
post at rocco-gasteiger.de
Sun May 16 13:03:18 EDT 2010
Hello everybody,
I use CMake to configure a VTK+Qt project in Visual Studio 9 on a Windows 7
machine. According to information in this mailing list and other examples I
create my own CMakeLists.txt file and it works.almost! I can build and link
my project correctly against VTK but if I start my program within (or
outside of) Visual Studio I get a error that some (I think all) VTK dlls are
missing e.g. vtkCommon.dll. In my environment variables I already set a
path (in the Path-variable or VTK_DIR) to the binary folder of the compiled
VTK sources. Within this folder I have a debug and release folder.
Currently, I can only resolve this behavior in one of two ways.
1. I set the path in my environment variables to the debug or release
folder and can run the program in debug or release mode.
2. I set PATH=$(QTDIR)\bin;$(VTK_DIR)\$(OutDir) as entry in the
debugging environment in the project properties (QTDIR was set in the
environment variables too)
But I think this manual effort is not necessary if I configure my
CMakeLists.txt correctly. So I do something wrong and maybe somebody can
help me.
At the end of this mail you find the (shortened) content of my
CMakeLists.txt file.
Many thanks in advance for any help or hint
Rocco Gasteiger
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(VTKQtProject)
# find and setup Qt4 for this project
FIND_PACKAGE(QT4 REQUIRED)
# find and setup VTK
FIND_PACKAGE(VTK REQUIRED)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
# Set source, header, and Qt files
SET(SRCS_CPP .)
SET(SRCS_H .)
SET(CLIENT_UI .)
SET(CLIENT_MOC_SRCS .)
QT4_WRAP_UI(SRCS_CPP ${CLIENT_UI})
QT4_WRAP_CPP(SRCS_CPP ${CLIENT_MOC_SRCS})
IF(UNIX)
ADD_EXECUTABLE(MyVTKQtProject ${SRCS_CPP} ${SRCS_H} ${CLIENT_UI} )
ELSEIF(APPLE)
ADD_EXECUTABLE(MyVTKQtProject MACOSX_BUNDLE ${SRCS_CPP} ${SRCS_H}
${CLIENT_UI} )
ELSEIF(WIN32)
ADD_EXECUTABLE(MyVTKQtProject ${SRCS_CPP} ${SRCS_H} ${CLIENT_UI} )
ENDIF()
IF(WIN32)
TARGET_LINK_LIBRARIES(MyVTKQtProject ${QT_LIBRARIES} ${QT_GIF_PLUGIN}
${QT_JPEG_PLUGIN} vtkCommon vtkexpat vtkFiltering vtkfreetype vtkftgl
vtkGraphics vtkHybrid vtkImaging vtkIO vtkjpeg vtkpng vtkRendering vtktiff
vtkzlib vtkVolumeRendering QVTK)
ELSE()
TARGET_LINK_LIBRARIES(MyVTKQtProject ${QT_LIBRARIES} vtkCommon vtkexpat
vtkFiltering vtkfreetype vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO
vtkjpeg vtkpng vtkRendering vtktiff vtkzlib vtkVolumeRendering QVTK)
ENDIF()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100516/129a76e2/attachment.htm>
More information about the vtkusers
mailing list