Skip to content

CMake failed if I have installed the different version VTK #4926

@Abo-go

Description

@Abo-go

Describe the error

CMake failed if I have installed the different version VTK.

To Reproduce

I have installed VTK-9.0 already, then I installed pcl-1.11.1(VTK-8.2). It was failed in CMake when I want to link pcl into my project. I looked into this and find pcl can't overwrite VTK_DIR which has already set.

Screenshots/Code snippets/Build information

PCLConfig.cmake:

macro(find_VTK)
  message(STATUS ${PCL_ALL_IN_ONE_INSTALLER})
  message(STATUS "Before Set${VTK_DIR}")
  if(PCL_ALL_IN_ONE_INSTALLER AND NOT ANDROID)
    if(EXISTS "${PCL_ROOT}/3rdParty/VTK/lib/cmake")
      set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/cmake/vtk-8.2" CACHE PATH "The directory containing VTKConfig.cmake")
	  message(STATUS "${PCL_ROOT}/3rdParty/VTK/lib/cmake/vtk-8.2")
	  message(STATUS "After Set${VTK_DIR}")
    else()
      set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/vtk-8.2" CACHE PATH "The directory containing VTKConfig.cmake")
    endif()
  elseif(NOT VTK_DIR AND NOT ANDROID)
    set(VTK_DIR "C:/Program Files/VTK/lib/cmake/vtk-8.2" CACHE PATH "The directory containing VTKConfig.cmake")
  endif()

Print by CMake which the path didn't set success

ON
Before SetC:/Program Files/VTK/lib/cmake/vtk-9.0
D:/Program Files/PCL 1.11.1/3rdParty/VTK/lib/cmake/vtk-8.2
After SetC:/Program Files/VTK/lib/cmake/vtk-9.0

If I add FORCE behind

set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/cmake/vtk-8.2" CACHE PATH "The directory containing VTKConfig.cmake" FORCE)

Path set success.

ON
Before SetC:/Program Files/VTK/lib/cmake/vtk-9.0
D:/Program Files/PCL 1.11.1/3rdParty/VTK/lib/cmake/vtk-8.2
After SetD:/Program Files/PCL 1.11.1/3rdParty/VTK/lib/cmake/vtk-8.2

Your Environment (please complete the following information):

  • OS: Win10
  • Compiler: Visual Studio 2019 X64
  • PCL Version 1.11.1
  • PCL Type:Installed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions