[vtkusers] How to specify the path to VTK in CMake?

André Prins a.h.prins at gmail.com
Wed Jul 21 12:13:12 EDT 2010


Dear Michael,

I am sorry, I was not of much help to you. My CMakeLists file does
nothing more than

    # Finding Vtk-5, based on a known VTKDIR environment-variable
    message( STATUS "Find Vtk-5 using $ENV{VTKDIR}" )
    find_package( VTK REQUIRED HINTS $ENV{VTKDIR} )
    include( ${VTK_USE_FILE} )

and then add the correct target_link_libraries to my target, just like
Cyrille demonstrated in an example. Did you put a
target_link_libraries line in you CMakeLists.txt In my case:

    add_executable( test_Visualizations ${TEST_H_HEADERS} ${TEST_CPP_SOURCES} )
    target_link_libraries( test_Visualizations vtkRendering vtkWidgets
vtkHybrid )

Other than that my CMakeLists file does not do anything but collect
source-files... However, I have had issues with Visual Studio with the
link-directories and include-directories not being set by cmake. Did
you try to clear the CMakeCache.txt file? Or tried a clean build?

Regards,
Andre


On Wed, Jul 21, 2010 at 12:03 PM, Cyrille Faucheux
<cyrille.faucheux at etu.univ-tours.fr> wrote:
> Here is the CMakeLists.txt from an example.
>
> -----------------
> PROJECT(Medical4)
>
> cmake_minimum_required(VERSION 2.8)
>
> FIND_PACKAGE(VTK)
> IF(VTK_FOUND)
>     INCLUDE( ${USE_VTK_FILE} )
> ENDIF(VTK_FOUND)
>
> INCLUDE_DIRECTORIES(
>     ${Medical4_SOURCE_DIR}
> )
>
> ADD_EXECUTABLE(Medical4 main.cpp)
> TARGET_LINK_LIBRARIES(Medical4
>     vtkRendering vtkGraphics vtkHybrid
>     vtkImaging vtkIO vtkFiltering vtkCommon
>     vtkVolumeRendering
> )
> -----------------
>
> You may need to rebuild you app from zero if you want to change from win32
> to x64.
>
> Cyrille
>
>
> Le 21/07/2010 16:25, Michael Xanadu a écrit :
>
> Hi Dave,
>
> thank you for your help. I did what you told me without success.
> I replaced
>
>    FIND_PACKAGE(VTK)
>
> with
>
>    FIND_PACKAGE(VTK REQUIRED)
>
> No success. Then I replaced the whole code block. No success. Then I used a
> codeblock found in the internet:
>
>    FIND_PACKAGE(VTK REQUIRED)
>    INCLUDE(${VTK_USE_FILE})
>
> Always the same story. I can't set the path to VTK bin in CMake GUI & CMake
> always links the (wrong) 32lib.
> There are VTKConfig.cmake + useVTK.cmake in the build directory
> "c:\work\libs\vtk_bin_5.6.0_x64" but not in the build directory of my own
> apllication. Do you have any further suggestions for me?
>
> With best regards,
> Michael
>
>
>
> 2010/7/21 Dave Partyka <dave.partyka at kitware.com>
>>
>> You shouldn't need to set a VTK_DIR environment variable. Also you can
>> simplify your logic slightly by using FIND_PACKAGE(VTK REQUIRED) instead.
>>  That said, the only thing you should have to do is set VTK_DIR in the
>> cmake gui to C:\WORK\LIBS\VTK_BIN_5.6.0_x64 and that should be it. Are there
>> definately VTKConfig.cmake and UseVTK.cmake files in the root of your build
>> directory?
>>
>
>
> _______________________________________________
> 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
>
>
> _______________________________________________
> 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