Hi, I am trying to cmake’s FetchContent to build VTK with my project. Cmake failed to configure the project. I tried to set the VTK_DIR to the VTK source dir and it did work either. Here is my CMakeLists.txt file. Could anybody tell me what I am doing wrong here? You help would be greatly appreciated.
project(CylinderExample)
include(FetchContent)
message(STATUS "Fetching VTK...")
set(VTK_BUILD_TESTING OFF)
set(VTK_BUILD_EXAMPLES OFF)
set(VTK_USE_CUDA ON)
set(VTK_REQUESTED_VERSION "v9.2.6" CACHE STRING "The requested VTK version")
FetchContent_Declare(
VTK
URL https://github.com/Kitware/VTK/archive/refs/tags/${VTK_REQUESTED_VERSION}.zip
)
FetchContent_MakeAvailable(VTK)
find_package(VTK COMPONENTS
CommonColor
CommonCore
FiltersSources
InteractionStyle
RenderingContextOpenGL2
RenderingCore
RenderingFreeType
RenderingGL2PSOpenGL2
RenderingOpenGL2
)
if (NOT VTK_FOUND)
message(FATAL_ERROR "CylinderExample: Unable to find the VTK build folder.")
endif()
# Prevent a "command line is too long" failure in Windows.
set(CMAKE_NINJA_FORCE_RESPONSE_FILE "ON" CACHE BOOL "Force Ninja to use response files.")
add_executable(CylinderExample CylinderExample.cpp)
target_link_libraries(CylinderExample PRIVATE ${VTK_LIBRARIES})
# vtk_module_autoinit is needed
vtk_module_autoinit(
TARGETS CylinderExample
MODULES ${VTK_LIBRARIES}
)