[vtkusers] Wrong CMake configuration for VTK+Qt-Projects in Visual Studio

Rocco Gasteiger post at rocco-gasteiger.de
Fri May 21 05:27:08 EDT 2010


Hi Zein and John,

Thanks for your answers! I build VTK as static and now it works without an
additionally entry in visual studio:-).

Greetings, Rocco



-----Ursprüngliche Nachricht-----
Von: Zein Salah [mailto:zeinsalah at gmail.com] 
Gesendet: Sonntag, 16. Mai 2010 21:04
An: Rocco Gasteiger
Betreff: Re: [vtkusers] Wrong CMake configuration for VTK+Qt-Projects in
Visual Studio

Hallo Rocco,

I had configured VTK+Qt with Cmake for Visual studio and everything worked
smoothly.

Hier is my cmakelist file. Perhapse it helps you adapt your file. I

cheers,
Zein

On Sun, May 16, 2010 at 7:03 PM, Rocco Gasteiger <post at rocco-gasteiger.de>
wrote:
> 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()
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>




More information about the vtkusers mailing list