Slicer build Error

Recently, I used cmake to compile the latest version of 3dSlicer and encountered many problems. I would like to ask you for advice. :rofl:


Build Environment

System: Windows 10 22H2
Cmake: 4.0.0

Build Steps

1. Use Cmake-Gui to configure and generate slicer.sln;
2. Execute the following command
"C:\Program Files\CMake\bin\cmake.exe" --build C:\D\SD --config Debug

Error List:

  1. Build Error One
CMake Error at CMakeLists.txt:555 (install):
    The file

      E:/build/teem-build/TeemLibraryDepends.cmake

    was generated by the export() command.  It may not be installed with the
    install() command.  Use the install(EXPORT) mechanism instead.  See the
    cmake-packages(7) manual for more.


  -- Configuring incomplete, errors occurred!
D:\vs2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: “E:\build\CMakeFiles\d0f89a43b6a
893837f2c66fd8fcc6b20\teem-update.rule;E:\build\CMakeFiles\d0f89a43b6a893837f2c66fd8fcc6b20\teem-patch.rule;E:\build\CM
akeFiles\d0f89a43b6a893837f2c66fd8fcc6b20\teem-configure.rule;E:\build\CMakeFiles\d0f89a43b6a893837f2c66fd8fcc6b20\teem
-build.rule;E:\build\CMakeFiles\d0f89a43b6a893837f2c66fd8fcc6b20\teem-install.rule;E:\build\CMakeFiles\a3ae6876636e24da
322ce04f92645239\teem-complete.rule;E:\build\CMakeFiles\d5760513ab1ffb7a106b6869ee861bc4\teem.rule”的自定义生成已退出,代码为 1。 [E:
\build\teem.vcxproj]
  1. Build Other-Type Info
CMake Deprecation Warning at CMakeLists.txt:21 (cmake_minimum_required):
    Compatibility with CMake < 3.10 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.

It’s possible the build isn’t working due to locale issues (I notice some non-ascii characters in the output).

Thanks for your reply :kissing_face_with_closed_eyes:

It is CMake 4. CMake 4 has been released recently and it is incompatible with most projects, including Slicer. The solution is to use CMake 3.x.

I ran into this problem a week ago, I had to help someone yesterday, and there is report here. Probably dozens of more people encountered this problem and did not report.

As a workaround, I’ve submitted a PR to update the build instructions for latest stable and main branches, but we should make the main branch compatible with CMake 4.

@jcfr what approach do you recommend?

There are many many files concerned in the build tree, see below. I quickly reinstalled cmake 3 for a seamless build. Using -DCMAKE_POLICY_VERSION_MINIMUM=3.5 in the superbuild cmake files did not help.

------------------------------------------------------------------------------
2.x

./RapidJSON/thirdparty/gtest/CMakeLists.txt
./RapidJSON/thirdparty/gtest/googlemock/CMakeLists.txt
./RapidJSON/thirdparty/gtest/googletest/CMakeLists.txt
./RapidJSON/example/CMakeLists.txt
./VTK/ThirdParty/xdmf2/vtkxdmf2/CMakeLists.txt
./VTK/ThirdParty/ogg/vtkogg/CMakeLists.txt
./VTK/ThirdParty/xdmf3/vtkxdmf3/CMakeLists.txt
./VTK/ThirdParty/eigen/vtkeigen/CMakeLists.txt
./VTK/ThirdParty/zlib/vtkzlib/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmjpeg/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/socketxx/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmuuid/CMakeLists.txt
./ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmmd5/CMakeLists.txt
./CTK-build/PythonQt/generator/CMakeLists.txt
./CTK/Libs/Core/CMake/TestBFD/CMakeLists.txt
./zlib/CMakeLists.txt
./teem/CMakeLists.txt
./teem/Examples/sanity/CMakeLists.txt
./teem/UseTeemCMakeDemo/CMakeLists.txt

------------------------------------------------------------------------------
3.0

./VTK/Utilities/KWIML/vtkkwiml/CMakeLists.txt
./curl/CMakeLists.txt
./CTK/CMake/ctkLinkerAsNeededFlagCheck/CMakeLists.txt
./CTKAppLauncherLib/Testing/LauncherLib/AppWithLauncherLib/CMakeLists.txt
./CTKAppLauncherLib/Testing/Launcher/App4ConfigureLauncherTest/CMakeLists.txt
./CTKAppLauncherLib/Testing/Launcher/App4Test/CMakeLists.txt
./CTKAppLauncherLib/CMakeLists.txt

------------------------------------------------------------------------------
3.1

./Slicer-build/_CPack_Packages/linux-amd64/TGZ/Slicer-5.9.0-2025-04-13-linux-amd64/share/Slicer-5.9/Wizard/Templates/Extensions/SuperBuild/CMakeLists.txt
./Slicer-build/_CPack_Packages/linux-amd64/TGZ/Slicer-5.9.0-2025-04-13-linux-amd64/share/Slicer-5.9/Wizard/Templates/Extensions/Default/CMakeLists.txt
./VTK/CMakeLists.txt
./VTK/Examples/Emscripten/Cxx/MultiCone/CMakeLists.txt
./VTK/Examples/Emscripten/Cxx/ConeMultiBackend/CMakeLists.txt
./VTK/Examples/Emscripten/Cxx/WrappedMace/CMakeLists.txt
./VTK/Examples/Emscripten/Cxx/Cone/CMakeLists.txt
./VTK/Examples/CMakeLists.txt
./VTK/Examples/GUI/QML/QtQuickChartsOn3DScene/CMakeLists.txt
./VTK/Examples/GUI/QML/QtQuickBoxWidget/CMakeLists.txt
./VTK/Examples/GUI/QML/QtQuickCone/CMakeLists.txt
./VTK/Examples/GUI/QML/QtQuickProperty/CMakeLists.txt
./VTK/ThirdParty/libxml2/vtklibxml2/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/ising/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/hello_worklet/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/multi_backend/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/logistic_map/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/cosmotools/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/contour_tree/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/contour_tree_distributed/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/mesh_quality/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/demo/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/temporal_advection/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/histogram/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/polyline_archimedean_helix/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/redistribute_points/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/clipping/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/streamline_mpi/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/lagrangian_structures/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/particle_advection/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/oscillator/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/contour_tree_augmented/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/game_of_life/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/lagrangian/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/smoke_test/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/examples/tetrahedra/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/CMakeLists.txt
./VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/tutorial/CMakeLists.txt
./VTK/ThirdParty/expat/vtkexpat/CMakeLists.txt
./VTK/ThirdParty/libharu/vtklibharu/CMakeLists.txt
./vtkAddon/CMakeLists.txt
./BRAINSTools/CMakeLists.txt
./MultiVolumeExplorer/CMakeLists.txt
./SimpleFilters/CMakeLists.txt
./ITK/Testing/TestExternal/CMakeLists.txt
./ITK/Examples/Installation/CMakeLists.txt
./ITK/Modules/Bridge/NumPy/CMakeLists.txt
./ITK/Modules/Video/BridgeOpenCV/CMakeLists.txt
./ITK/Modules/Numerics/FEM/CMakeLists.txt
./ITK/Modules/ThirdParty/NIFTI/src/nifti/CMakeLists.txt
./ITK/Modules/ThirdParty/VNL/src/vxl/config/cmake/config/vxl_shared_link_test/CMakeLists.txt
./ITK/Modules/ThirdParty/VNL/src/vxl/CMakeLists.txt
./ITK/Modules/ThirdParty/Eigen3/src/itkeigen/CMakeLists.txt
./ITK/Modules/Core/GPUCommon/CMakeLists.txt
./ITK/Modules/Core/GPUFiniteDifference/CMakeLists.txt
./ITK/Modules/Remote/MGHIO/CMakeLists.txt
./ITK/Modules/Remote/AdaptiveDenoising/CMakeLists.txt
./ITK/Modules/Remote/MorphologicalContourInterpolation/examples/CMakeLists.txt
./ITK/Modules/Remote/MorphologicalContourInterpolation/wasm/CMakeLists.txt
./ITK/Modules/Remote/MorphologicalContourInterpolation/CMakeLists.txt
./ITK/Modules/Remote/GrowCut/CMakeLists.txt
./ITK/Modules/Remote/SimpleITKFilters/CMakeLists.txt
./ITK/Modules/Remote/GenericLabelInterpolator/CMakeLists.txt
./ITK/Modules/Remote/IOScanco/CMakeLists.txt
./ITK/Modules/Filtering/GPUAnisotropicSmoothing/CMakeLists.txt
./ITK/Modules/Filtering/GPUImageFilterBase/CMakeLists.txt
./ITK/Modules/Filtering/GPUSmoothing/CMakeLists.txt
./ITK/Wrapping/CMakeLists.txt
./DCMTK/CMakeLists.txt
./LZMA/CMakeLists.txt
./LandmarkRegistration/CMakeLists.txt
./MultiVolumeImporter/CMakeLists.txt
./CTK/CMakeLists.txt
./CTK/Utilities/DGraph/CMakeLists.txt
./LibFFI/CMakeLists.txt
./ITK-build/Modules/Core/Common/CMakeTmp/ITK_PRIVATE_DYNAMIC_CAST/CMakeLists.txt
./CompareVolumes/CMakeLists.txt
./python/CMakeLists.txt
./SimpleITK/Examples/CppCMake/Source/CMakeLists.txt
./SimpleITK/Examples/CMakeLists.txt
./SlicerExecutionModel/CMakeLists.txt
./SlicerExecutionModel/GenerateCLP/Testing/Slicer3Example/CMakeLists.txt
./SlicerExecutionModel/GenerateCLP/Testing/PointExample1/CMakeLists.txt
./SlicerExecutionModel/GenerateCLP/Testing/CLPExample1/CMakeLists.txt
./SlicerExecutionModel/GenerateCLP/Testing/Utf8Example/CMakeLists.txt
./SlicerExecutionModel/GenerateCLP/Testing/CLPTestMultiple/CMakeLists.txt
./SurfaceToolbox/CMakeLists.txt

------------------------------------------------------------------------------
3.2

./BRAINSTools/ARCHIVE/BRAINSTexture/CMakeLists.txt

------------------------------------------------------------------------------
3.3

./SimpleITK-build/SimpleITK-build/CMakeTmp/link_flags/gnu_ld_ignore/MODULE/SHARED/src/CMakeLists.txt
./SimpleITK-build/SimpleITK-build/Wrapping/Python/CMakeTmp/link_flags/gnu_ld_ignore/MODULE/STATIC/src/CMakeLists.txt
./SimpleITK-build/CMakeTmp/link_flags/gnu_ld_ignore/MODULE/SHARED/src/CMakeLists.txt

------------------------------------------------------------------------------
3.4

./VTK/ThirdParty/pugixml/vtkpugixml/CMakeLists.txt
./bzip2/CMakeLists.txt

------------------------------------------------------------------------------
3.5

./ITK/Modules/ThirdParty/ZLIB/src/itkzlib-ng/CMakeLists.txt
./ITK/Modules/ThirdParty/GoogleTest/src/itkgoogletest/CMakeLists.txt
./ITK/Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt
./CTK-build/PythonQt/CMakeLists.txt
./qRestAPI/CMakeLists.txt