Build VTK 9.0.1 on Windows MSVS2019 v16 with Qt5 - DmitrySemikin/dsemikin_notes GitHub Wiki

Build VTK 9.0.1 on Windows MSVS2019 v16 with Qt5

Prerequisites:

  • MSVS2019 (v16)
  • CMake (I used latest at the moment 3.19)

Download VTK sources. Unzip.

Next to it create directory for build and target directory for installation (I prefer not to use "C:\Program Files", which is the default valud). Note, that with MSVS build toolchain one can build both: Debug and Release configurations in the same build directory (unline make or jinja, which require separate buld directories for each configuration).

Start CMake-Gui.

Spcify source directory and build directory.

Press "Configure". Select MSVS-2019, x64. Wait until finished. Bunch of variables will be shown.

Change "CMAKE_INSTALL_PREFIX" to whatever target installation directory you like.

"VTK_GROUP_ENABLE_Qt" => Yes (don't miss, that 't' at the end of 'Qt' is small, if providing it by hand as -D option).

"CMAKE_PREFIX_PATH" => Installation dir of Qt5 (In my case it was default: "C:/Qt/5.15.2/msvc2019_64"). It is to enable cmake to find Qt (see e.g. https://doc.qt.io/qt-5.12/cmake-manual.html).

Press "Configure" again. It should complete without errors.

Then press "Generate".

Then open MSVS Command Line for Native x64 Development.

CD to build directory (one created earlier and then used in cmake-gui).

Note, that with MSVS build toolchain one can build both: Debug and Release configurations in the same build directory (unline make or jinja, which require separate buld directories for each configuration).

Execute to build debug and release configurations:

msbuild ALL_BUILD.vcxproj /p:Configuration="Debug" /m
msbuild ALL_BUILD.vcxproj /p:Configuration="Release" /m

To install debug and release configurations:

msbuild INSTALL.vcxproj /p:Configuration=Debug
msbuild INSTALL.vcxproj /p:Configuration=Release

Here /p:Configuration="" - configuration to build and "/m" - multiprocessor build (one can also specify number of processors explicitly; by default all processors are used).

For some reason I did not succeed to run msbuild on VTK.sln specifying INSTALL as project to build... But running msbuild directly on INSTALL projectfile does, what is needed.

⚠️ **GitHub.com Fallback** ⚠️