Unable to build VTK 9.4 with Qt 6.8

Hi there,

We have built a certified medical device software product, which is mostly based on VTK combined with ITK, GDCM and Qt toolkits/frameworks. It currently uses VTK 8.2.0, combined with Qt 5.15.2
We’ve been using CMake’s ExternalProject functionality to build these dependencies from code and for the last few years everything worked perfectly fine.

However, I am currently attempting to update our dependencies to their latest and greatest versions, using VTK 9.4.0.rc3 Qt 6.8.0. But somehow our CMake pipeline keeps failing when building VTK, telling me that it cannot find Qt6, Qt6QmlTools, Qt6Quick, Qt6QuickTools. These Qt modules exist in the places cmake is looking for them and I can verify that their *Config.cmake files exist. I’ve been struggling for days and already tried adding their paths to the CMAKE_PREFIX_PATH and explicitly setting the *_DIRs, but nothing seems to work. Does anyone else have similar problems or know what I am missing?

cmake_trace.txt (805.3 KB)

This is our CMake for the build:

cmake_minimum_required(VERSION 3.15.0)

include(ExternalProject)

Project(CartBoxSuiteLightDep)

IF (MSVC)   
    IF (NOT MSVC_VERSION LESS 1500)
		message( STATUS "# CARTBox Build # enabling multicore builds on windows")

		string(APPEND CMAKE_C_FLAGS " /MP")
		string(APPEND CMAKE_CXX_FLAGS " /MP")
		string(APPEND QMAKE_CXXFLAGS_EXCEPTIONS_ON " /EHa")
		string(APPEND QMAKE_CXXFLAGS_STL_ON " /EHa")

    ENDIF ()
ENDIF ()

message(STATUS "_____DEBUG_____   CBSL_EXT_BUILD_DIR : 	${CBSL_EXT_BUILD_DIR}")
message(STATUS "_____DEBUG_____   CUR_SRC_DIR : 		${CMAKE_CURRENT_SOURCE_DIR}")

message(STATUS "*** CMAKE_BUILD_TYPE 	: ${CMAKE_BUILD_TYPE} ")
message(STATUS "*** Using EXTERNALS 	: ${EXTERNALS_DIR} ")
message(STATUS "*** Using QT 			: ${QT_EXT_BUILD} ")
message(STATUS "*** Using EXTERNALS 	: ${EXTERNALS_DIR} ")

if( "${EXTERNALS_DIR}" STREQUAL "" )
	message(FATAL "*** Non empty -DEXTERNALS_DIR required ! ")
endif()

message(STATUS "*** Using EXTERNALS : ${EXTERNALS_DIR} ")

cmake_policy(SET CMP0135 OLD)
cmake_policy(SET CMP0077 NEW)

# ================================================= [ VTK ] ================================================= #

set(VTK_EXTERN_DIR VTK-9.4.0.rc3)
set(VTK_PREFIX vtk)
set(VTK_EXTERN_BINARY_DIR "${CBSL_EXT_BUILD_DIR}/${VTK_PREFIX}/src/${VTK_EXTERN_DIR}" )

list(APPEND CMAKE_PREFIX_PATH ${QT_EXT_BUILD})
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6CoreTools")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6Qml")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6QmlTools")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6Quick")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6QuickTools")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6Widgets")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6WidgetsTools")

message(STATUS "*** CMAKE_PREFIX_PATH	: ${CMAKE_PREFIX_PATH} ")

message( STATUS "### CARTBox Build # adding external project VTK-9.4.0")

ExternalProject_Add(
	${VTK_EXTERN_DIR}
	URL "${EXTERNALS_DIR}/${VTK_PREFIX}/${VTK_EXTERN_DIR}.zip"
	URL_MD5 b55788c3e80e4086266d3c988be9e937
	PREFIX ${VTK_PREFIX}
	CMAKE_ARGS
	 -DVTK_QT_VERSION:STRING=6
	 -DQt6_DIR:PATH=${QT_EXT_BUILD}/lib/cmake/Qt6
	 -DVTK_GROUP_ENABLE_QT:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQtQuick:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQtSQL:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_ViewsQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_vtkDICOM:STRING='YES'
	 -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${QT_EXT_BUILD}
	 -DQT_QMAKE_EXECUTABLE:PATH=${QT_EXT_BUILD}/bin/qmake.exe
	 -DVTK_GROUP_ENABLE_Rendering:STRING='YES'
	 -DBUILD_EXAMPLES:BOOL=OFF
	 -DBUILD_TESTING:BOOL=OFF
	 -DVTK_Group_Web:BOOL=OFF
	 -DCMAKE_CXX_MP_FLAG:BOOL=ON
	 -DBUILD_SHARED_LIBS:BOOL=ON
	 -DQT_DEBUG_FIND_PACKAGE=ON
	 INSTALL_COMMAND ""
)

And this is the build output:

New-Item : An item with the specified name E:\ct\bld\cbsl_ext\Dbg already exists.
At E:\ct\src_git\cartbox-suite-light\build\externals\config_build-externals.ps1:34 char:1
+ New-Item -ItemType "directory" -Path "$CBSL_EXT_BUILD_DIR"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceExists: (E:\ct\bld\cbsl_ext\Dbg:String) [New-Item], IOException
    + FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
 
Put cmake in trace mode, but with variables expanded.
Put cmake in trace mode and redirect trace output to a file instead of stderr.
Trace will be written to cmake_trace.txt
-- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.19045.
-- # CARTBox Build # enabling multicore builds on windows
-- _____DEBUG_____   CBSL_EXT_BUILD_DIR : 	E:/ct/bld/cbsl_ext/Dbg
-- _____DEBUG_____   CUR_SRC_DIR : 		E:/ct/src_git/cartbox-suite-light/build/externals
-- *** CMAKE_BUILD_TYPE 	: Debug 
-- *** Using EXTERNALS 	: E:/ct/fake_ftp_cbsl/cbsl 
-- *** Using QT 			: E:/Qt/6.8.0/msvc2022_64 
-- *** Using EXTERNALS 	: E:/ct/fake_ftp_cbsl/cbsl 
-- *** Using EXTERNALS : E:/ct/fake_ftp_cbsl/cbsl 
-- *** CMAKE_PREFIX_PATH	: E:/Qt/6.8.0/msvc2022_64;E:/Qt/6.8.0/msvc2022_64/lib/cmake;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6CoreTools;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Qml;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QmlTools;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QuickTools;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Widgets;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6WidgetsTools 
-- ### CARTBox Build # adding external project VTK-9.4.0
-- Configuring done (0.1s)
-- Generating done (0.2s)
-- Build files have been written to: E:/ct/bld/cbsl_ext/Dbg
MSBuild version 17.11.9+a69bbaaf5 for .NET Framework

  Performing configure step for 'VTK-9.4.0.rc3'
  -- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.19045.
  -- Could not use git to determine source version, using version 
  -- vtkDICOM: Building vtkDICOM as a Remote VTK Module
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  -- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR) 
  CMake Warning at C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeFindDependencyMacro.cmake:76 (find_package):
    By not providing "FindQt6QmlTools.cmake" in CMAKE_MODULE_PATH this project
    has asked CMake to find a package configuration file provided by
    "Qt6QmlTools", but CMake did not find one.
  
    Could not find a package configuration file provided by "Qt6QmlTools"
    (requested version 6.8.0) with any of the following names:
  
      Qt6QmlToolsConfig.cmake
      qt6qmltools-config.cmake
  
    Add the installation prefix of "Qt6QmlTools" to CMAKE_PREFIX_PATH or set
    "Qt6QmlTools_DIR" to a directory containing one of the above files.  If
    "Qt6QmlTools" provides a separate development package or SDK, be sure it
    has been installed.
  Call Stack (most recent call first):
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QuickTools/Qt6QuickToolsDependencies.cmake:12 (find_dependency)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QuickTools/Qt6QuickToolsConfig.cmake:36 (include)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:97 (find_package)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickDependencies.cmake:38 (_qt_internal_find_tool_dependencies)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake:43 (include)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/Qt6Config.cmake:181 (find_package)
    CMake/vtkModule.cmake:5351 (find_package)
    GUISupport/QtQuick/CMakeLists.txt:17 (vtk_module_find_package)
  
  
  CMake Warning at E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:97 (find_package):
    Found package configuration file:
  
      E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QuickTools/Qt6QuickToolsConfig.cmake
  
    but it set Qt6QuickTools_FOUND to FALSE so package "Qt6QuickTools" is
    considered to be NOT FOUND.  Reason given by package:
  
    Qt6QuickTools could not be found because dependency Qt6QmlTools could not
    be found.
  
  Call Stack (most recent call first):
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickDependencies.cmake:38 (_qt_internal_find_tool_dependencies)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake:43 (include)
    E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/Qt6Config.cmake:181 (find_package)
    CMake/vtkModule.cmake:5351 (find_package)
    GUISupport/QtQuick/CMakeLists.txt:17 (vtk_module_find_package)
  
  
  CMake Warning at E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/Qt6Config.cmake:181 (find_package):
    Found package configuration file:
  
      E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake
  
    but it set Qt6Quick_FOUND to FALSE so package "Qt6Quick" is considered to
    be NOT FOUND.  Reason given by package:
  
    Qt6Quick could not be found because dependency Qt6QuickTools could not be
    found.
  
    Configuring with --debug-find-pkg=Qt6QuickTools might reveal details why
    the package was not found.
  
     find_package search path values and other context for the last package that was not found:
      CMAKE_MODULE_PATH: E:/ct/bld/cbsl_ext/Dbg/vtk/src/VTK-9.4.0.rc3/CMake/patches/99;E:/ct/bld/cbsl_ext/Dbg/vtk/src/VTK-9.4.0.rc3/CMake;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/3rdparty/kwin
      CMAKE_PREFIX_PATH: 
      $ENV{CMAKE_PREFIX_PATH}: 
      CMAKE_FIND_ROOT_PATH: 
      _qt_additional_packages_prefix_paths: E:/Qt/6.8.0/msvc2022_64/lib/cmake
      _qt_additional_host_packages_prefix_paths: 
      _qt_cmake_dir: E:/Qt/6.8.0/msvc2022_64/lib/cmake
      QT_HOST_PATH: 
      Qt6HostInfo_DIR: 
      Qt6_DIR: E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6
      CMAKE_TOOLCHAIN_FILE: 
      CMAKE_FIND_ROOT_PATH_MODE_PACKAGE: 
      CMAKE_SYSROOT: 
      $ENV{PATH}: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64;;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86;;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\tools;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\ide;C:\Program Files (x86)\HTML Help Workshop;;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\;;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files\Microsoft Visual Studio\2022\Community\Team Tools\DiagnosticsHub\Collector;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\\x64;C:\Program Files (x86)\Windows Kits\10\bin\\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\ImageMagick-7.1.0-Q16-HDRI;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Qt\Qt5.15.2\5.15.2\msvc2019_64\bin;C:\Program Files (x86)\Microsoft SDKs\MPI;C:\Program Files (x86)\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\NASM\nasm.exe;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\TortoiseHg\;C:\Program Files\Docker\Docker\resources;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\CMake\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\ninja;C:\Program Files\PowerShell\7\;C:\Users\DaanBaas\AppData\Local\activestate\cache\bin;C:\Users\DaanBaas\AppData\Local\ActiveState\StateTool\release\bin;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python311\;C:\Users\DaanBaas\AppData\Local\Microsoft\WindowsApps;C:\Qt\Qt5.15.2\5.15.2\msvc2019_64\bin;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python39\libs;C:\Program Files\Orthanc Server;C:\Users\DaanBaas\.dotnet\tools;C:\Program Files\Docker\Docker;C:\Program Files\Git\cmd;C:\Users\DaanBaas\AppData\Local\Programs\Microsoft VS Code\bin;;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;
  
  Call Stack (most recent call first):
    CMake/vtkModule.cmake:5351 (find_package)
    GUISupport/QtQuick/CMakeLists.txt:17 (vtk_module_find_package)
  
  
  CMake Warning at CMake/vtkModule.cmake:5351 (find_package):
    Found package configuration file:
  
      E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/Qt6Config.cmake
  
    but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
    FOUND.  Reason given by package:
  
    Failed to find required Qt component "Quick".
  
    Expected Config file at
    "E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake" exists
  
  
  
    Configuring with --debug-find-pkg=Qt6Quick might reveal details why the
    package was not found.
  
     find_package search path values and other context for the last package that was not found:
      CMAKE_MODULE_PATH: E:/ct/bld/cbsl_ext/Dbg/vtk/src/VTK-9.4.0.rc3/CMake/patches/99;E:/ct/bld/cbsl_ext/Dbg/vtk/src/VTK-9.4.0.rc3/CMake;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules;E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6/3rdparty/kwin
      CMAKE_PREFIX_PATH: 
      $ENV{CMAKE_PREFIX_PATH}: 
      CMAKE_FIND_ROOT_PATH: 
      _qt_additional_packages_prefix_paths: E:/Qt/6.8.0/msvc2022_64/lib/cmake
      _qt_additional_host_packages_prefix_paths: 
      _qt_cmake_dir: E:/Qt/6.8.0/msvc2022_64/lib/cmake
      QT_HOST_PATH: 
      Qt6HostInfo_DIR: 
      Qt6_DIR: E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6
      CMAKE_TOOLCHAIN_FILE: 
      CMAKE_FIND_ROOT_PATH_MODE_PACKAGE: 
      CMAKE_SYSROOT: 
      $ENV{PATH}: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64;;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86;;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\tools;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\ide;C:\Program Files (x86)\HTML Help Workshop;;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\;;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files\Microsoft Visual Studio\2022\Community\Team Tools\DiagnosticsHub\Collector;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\\x64;C:\Program Files (x86)\Windows Kits\10\bin\\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\ImageMagick-7.1.0-Q16-HDRI;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Qt\Qt5.15.2\5.15.2\msvc2019_64\bin;C:\Program Files (x86)\Microsoft SDKs\MPI;C:\Program Files (x86)\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\NASM\nasm.exe;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\TortoiseHg\;C:\Program Files\Docker\Docker\resources;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\CMake\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\ninja;C:\Program Files\PowerShell\7\;C:\Users\DaanBaas\AppData\Local\activestate\cache\bin;C:\Users\DaanBaas\AppData\Local\ActiveState\StateTool\release\bin;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python311\;C:\Users\DaanBaas\AppData\Local\Microsoft\WindowsApps;C:\Qt\Qt5.15.2\5.15.2\msvc2019_64\bin;C:\Users\DaanBaas\AppData\Local\Programs\Python\Python39\libs;C:\Program Files\Orthanc Server;C:\Users\DaanBaas\.dotnet\tools;C:\Program Files\Docker\Docker;C:\Program Files\Git\cmd;C:\Users\DaanBaas\AppData\Local\Programs\Microsoft VS Code\bin;;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;
  
  Call Stack (most recent call first):
    GUISupport/QtQuick/CMakeLists.txt:17 (vtk_module_find_package)
  
  
  CMake Error at CMake/vtkModule.cmake:5357 (message):
    Could not find the Qt6 external dependency.
  Call Stack (most recent call first):
    GUISupport/QtQuick/CMakeLists.txt:17 (vtk_module_find_package)
  
  
  -- Configuring incomplete, errors occurred!
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'E:\ct\bld\cbsl_ext\Dbg\CMakeFiles\bee896126a8445c0d844c5780156f01e\VTK-9.4.0.rc3-configure.rule;E:\ct\bld\cbsl_ext\Dbg\CMakeFiles\bee896126a8445c0d844c5780156f01e\VTK-9.4.0.rc3-build.rule;E:\ct\bld\cbsl_ext\Dbg\CMakeFiles\bee896126a8445c0d844c5780156f01e\VTK-9.4.0.rc3-install.rule;E:\ct\bld\cbsl_ext\Dbg\CMakeFiles\3e6145eb22da66cab3d55e4e08211278\VTK-9.4.0.rc3-complete.rule;E:\ct\bld\cbsl_ext\Dbg\CMakeFiles\f4226eca7df04a84030caf5143f1dc97\VTK-9.4.0.rc3.rule' exited with code 1. [E:\ct\bld\cbsl_ext\Dbg\VTK-9.4.0.rc3.vcxproj]

1 Like

The error indicates that CMake couldn’t find Qt6QmlTools. Please check to make sure that the CMAKE_PREFIX_PATH points to a directory containing Qt5QmlToolsConfig.cmake file.

An alternative approach would be to disable the vtkGUISupportQtQuick module altogether if you don’t use vtk’s qml integration. You can do that via the cmake flag - VTK_MODULE_ENABLE_VTK_GUISupportQtQuick:STRING=NO.

Hi Sankesh,

Thanks a lot for your reply. The solution you describe does exactly what I already tried (as I wrote in my question). My CMAKE_PREFIX_PATH is printed in the cmake output I added to the post and clearly shows that the path ‘E:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6QmlTools’ has been successfully added. As I described, I also verified that the module paths contains the expected *Config.cmake files. Strangely, it only fails with Qt6QmlTools, the rest of the module paths are correctly found.

For now, I have been able to configure and compile VTK by adding ‘-DQt6QmlTools_DIR:PATH=${QT_EXT_BUILD}/lib/cmake/Qt6QmlTools’ to VTK’s ExternalProject_Add CMAKE_ARGS. But to me this still feels a bit like an ugly hack.

I also changed '-DVTK_GROUP_ENABLE_Qt:STRING=‘YES’ from ‘-DVTK_GROUP_ENABLE_QT:STRING=‘YES’’ (note the _Qt instead of _QT)

Maybe this helps fellow VTK fans struggling with their builds.

That seems fine for now. I looked into it a little and it seems like a Qt6 cmake config issue.

Hello,

My answer is not an immediate solution to your issue, but you may be interested in building your project and all its dependencies from the ground up with Conan 2. The advantage of this dependency management system is that it can build dependencies using different build systems (CMake, Autotools, JOM, etc.). In Conan, the dependencies are built via Python scripts called recipes. If you want, you can take a look at the recipes tailored for my project here ( gammaray/conan2_recipes at build_with_conan · PauloCarvalhoRJ/gammaray · GitHub) or the generic ones (includes Qt 6.x.y versions) in Conan Center ( Search Result - Conan 2.0: C and C++ Open Source Package Manager).

all the best,

PC

Hello,

Thanks for the Conan suggestion, it seems promising.

Today, I also noticed that in the CMAKE script I posted in my original post, we did not pass the CMAKE_PREFIX_PATH as a CMAKE_ARG (via -D) to ExternalProject_Add.

We now do, as shown below and stuff works.

# ================================================= [ VTK ] ================================================= #

set(VTK_EXTERN_DIR VTK-9.4.0.rc3)
set(VTK_PREFIX vtk)
set(VTK_EXTERN_BINARY_DIR "${CBSL_EXT_BUILD_DIR}/${VTK_PREFIX}/src/${VTK_EXTERN_DIR}" )

list(APPEND CMAKE_PREFIX_PATH ${QT_EXT_BUILD})
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake")
list(APPEND CMAKE_PREFIX_PATH "${QT_EXT_BUILD}/lib/cmake/Qt6")

message( STATUS "### Build System is adding external project VTK-9.4.0")

ExternalProject_Add(
	${VTK_EXTERN_DIR}
	URL "${EXTERNALS_DIR}/${VTK_PREFIX}/${VTK_EXTERN_DIR}.zip"
	URL_MD5 b55788c3e80e4086266d3c988be9e937
	PREFIX ${VTK_PREFIX}
	CMAKE_ARGS
	 -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
	 -DVTK_QT_VERSION:STRING=6
	 -DVTK_GROUP_ENABLE_Qt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQtQuick:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_GUISupportQtSQL:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_ViewsQt:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_vtkDICOM:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_ImagingOpenGL2:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingGL2PSOpenGL2:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingOpenGL2:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2:STRING='YES'
	 -DVTK_MODULE_ENABLE_VTK_:STRING='YES'
	 -DQt6_DIR:PATH=${QT_EXT_BUILD}/lib/cmake/Qt6
	 -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${QT_EXT_BUILD}
	 -DQT_QMAKE_EXECUTABLE:PATH=${QT_EXT_BUILD}/bin/qmake.exe
	 -DVTK_GROUP_ENABLE_Rendering:STRING='YES'
	 -DBUILD_EXAMPLES:BOOL=OFF
	 -DBUILD_TESTING:BOOL=OFF
	 -DVTK_Group_Web:BOOL=OFF
	 -DCMAKE_CXX_MP_FLAG:BOOL=ON
	 -DBUILD_SHARED_LIBS:BOOL=ON
	 INSTALL_COMMAND ""
)
1 Like