Problem building VTK

I’ve been happily developing large projects for VTK and ITK for years, but I am not a CMake expert.

I just switched to a new Mac Powerbook with the M1 chip, and I’m getting errors running CMake on VTK

I’ve updated to the latest
Cmake-3.21.0
VTK 9.0.3
Xcode 12.5 (with the Command Line Tools for Xcode 12.5 installed)

CMake configures successfully, but the Generate yields the error statement below. Any help would be appreciated.


CMake Error in ThirdParty/zlib/vtkzlib/CMakeLists.txt:
The custom command generating
/Users/Stetten/ITK_VTK_FLTK/VTK-9.0.0_build/ThirdParty/hdf5/vtkhdf5/H5Tinit.c
is attached to multiple targets:
vtkhdf5_src
gen_hdf5
but none of these is a common dependency of the other(s). This is not
allowed by the Xcode “new build system”.

The Xcode generator is not well-tested by VTK. I would recommend using the Ninja generator instead for now.

Thanks for the tip. I have been using Xcode successfully with CMake/ITK/VTK for years, and would hate to have to switch to a whole new IDE. It seems strange that CMake would not support Xcode, which seems like one of the major environments out there. Perhaps I’m not understanding what exactly an IDE is vs. the actual compiler inside? I have read that Xcode uses Clang internally. Is there some way i can still use Xcode as the IDE by switching which compiler is used?

We test with the Xcode compilers all the time. What is not well-tested is the Xcode generator. CMake supports both just fine, but Xcode is a “multi-config generator” and it’s just not something that I’ve put a lot of time into making sure works as well as it can when building VTK due to a lack of time and it being a lower priority thing (AFAIK, very few VTK developers use these generators). I think most of the VTK module system should be OK with multi-config generators, but there are always corner cases (probably in the wrapping support logic). So it’s not so much out of interest, just a lack of resources to make it work well.

Thanks so much for your comments. They helped… I used the “Unix Makefile” option in CMake and successfully compiled VTK and ITK (with the “Module_ITKVtkGlue” option, to tie the two libraries together) using good old fashioned “make -f Makefile”. Then I tried using the “Xcode” option in CMake to generate a project for my own code (which uses the ITK an VTK libraries and worked in the past) but it returns the error below.

The C compiler identification is AppleClang 12.0.5.12050022
The CXX compiler identification is AppleClang 12.0.5.12050022
CMake Error at CMakeLists.txt:22 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:22 (project):
No CMAKE_CXX_COMPILER could be found.

I seem to have found the problem.
After installing “Command Line Tools for Xcode 12.5” I needed to remove and reinstall CMake. CMake can now find the C and C++ compilers.

Thanks again for your help.

One more discovery… I did finally get VTK-9.0.3 to configure and generate with Xcode (and then compile) by putting “buildsystem=1” into the -T window in CMake, see
[When trying to generate an Xcode project from a cmake folder, I get an error related to Xcode new build system. Any possible solution? - Stack Overflow]