CMakelists.txt file question

Hi all.

I am a casual user of ITK, and haven’t used it in a few years. When I recently set it up again, I found that the original CMakelists.txt file I had previously used didn’t work any more in CMake. This is a small example program and only had 1 CMakelists file. I did get an error relating to the version requirement and fixed that. The file contents are here:

cmake_minimum_required(VERSION 3.1)

project(BinaryThresholdImageFilter)

find_package(ITK REQUIRED)
include({ITK_USE_FILE}) if (ITKVtkGlue_LOADED) find_package(VTK REQUIRED) else() find_package(ItkVtkGlue REQUIRED) include({ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()

add_executable(BinaryThresholdImageFilter MACOSX_BUNDLE BinaryThresholdImageFilter.cxx)
target_link_libraries(BinaryThresholdImageFilter {Glue} {VTK_LIBRARIES} ${ITK_LIBRARIES})

vtk_module_autoinit(
TARGETS BinaryThresholdImageFilter
MODULES
VTK::RenderingOpenGL2
)

Can anyone suggest changes/additions that would let this work? Is there some help somewhere that will help with this? I have been looking but haven’t been able to find anything.

Thanks!

Kent Ogden

I see that the code got reformatted, here is another try:

 
project(BinaryThresholdImageFilter)
 
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
if (ITKVtkGlue_LOADED)
  find_package(VTK REQUIRED)
else()
  find_package(ItkVtkGlue REQUIRED)
  include(${ItkVtkGlue_USE_FILE})
  set(Glue ItkVtkGlue)
endif()
 
add_executable(BinaryThresholdImageFilter MACOSX_BUNDLE BinaryThresholdImageFilter.cxx)
target_link_libraries(BinaryThresholdImageFilter  ${Glue}  ${VTK_LIBRARIES} ${ITK_LIBRARIES})

vtk_module_autoinit(
    TARGETS BinaryThresholdImageFilter
    MODULES 
    VTK::RenderingOpenGL2
    )