### Install Examples Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/CMakeLists.txt Conditionally installs the examples directory to the documentation destination if the Viskores_INSTALL_EXAMPLES option is enabled. It excludes the CMakeLists.txt file from the installation. ```cmake if (Viskores_INSTALL_EXAMPLES) include(GNUInstallDirs) install(DIRECTORY examples DESTINATION ${CMAKE_INSTALL_DOCDIR} REGEX examples/CMakeLists.txt EXCLUDE) endif() ``` -------------------------------- ### Installation Directory Setup Source: https://github.com/kitware/vtk/blob/master/Examples/Build/VTKPythonExtensions/CMakeLists.txt Configures installation directories for libraries, modules, and runtime files, with OS-specific adjustments. ```cmake include(GNUInstallDirs) set(BUILD_SHARED_LIBS ON) set(CMAKE_INSTALL_LIBDIR ".") set(_vtk_module_library_destination "${CMAKE_INSTALL_LIBDIR}/vtk_pyext") set(_vtk_module_module_destination "${CMAKE_INSTALL_LIBDIR}") set(_vtk_module_runtime_destination "${CMAKE_INSTALL_BINDIR}") if (WIN32) # Ensure the dlls end up in lib/vtkmodules as well set(_vtk_module_runtime_destination "${CMAKE_INSTALL_LIBDIR}/vtk_pyext") elseif(APPLE) # These two rpaths are required, always add them list(APPEND CMAKE_INSTALL_RPATH "@loader_path" "@loader_path/../vtkmodules") else() # assumes Linux + GNU-based toolchain # required as the VTK wheels are build with the C++98 ABI list(APPEND CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0") # These two rpaths are required, always add them list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../vtkmodules") endif () ``` -------------------------------- ### CLI11 Callback Execution Order Example Source: https://github.com/kitware/vtk/blob/master/ThirdParty/cli11/vtkcli11/README.md Demonstrates the setup of callbacks for an application and its subcommands, illustrating the order of execution based on a sample command line. ```cpp app.parse_complete_callback(ac1); app.final_callback(ac2); auto sub1=app.add_subcommand("sub1")->parse_complete_callback(c1)->preparse_callback(pc1); auto sub2=app.add_subcommand("sub2")->final_callback(c2)->preparse_callback(pc2); app.preparse_callback( pa); ``` -------------------------------- ### Build and Install Expat Source: https://github.com/kitware/vtk/blob/master/ThirdParty/expat/vtkexpat/README.md After configuring, use 'make' to build the library and 'make install' to install it. Ensure you have write permissions for the installation directories. ```bash make make install ``` -------------------------------- ### Configure Installation Paths Source: https://github.com/kitware/vtk/blob/master/ThirdParty/xdmf2/vtkxdmf2/CMakeLists.txt Sets default installation directories for libraries and includes if they are not already defined. This is typically handled by VTK's CMake setup. ```cmake if(NOT XDMF_INSTALL_LIB_DIR) set(XDMF_INSTALL_LIB_DIR /lib) endif() if(NOT XDMF_INSTALL_INCLUDE_DIR) set(XDMF_INSTALL_INCLUDE_DIR /include/Xdmf) endif() set(XDMF2_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}) configure_file(${xdmf2_SOURCE_DIR}/XDMFConfig.cmake.in ${xdmf2_BINARY_DIR}/XDMFConfig.cmake @ONLY IMMEDIATE) ``` -------------------------------- ### Standard Build with Make Source: https://github.com/kitware/vtk/blob/master/ThirdParty/cgns/vtkcgns/README.md For simpler installations, the standard './configure', 'make', 'make install' commands may suffice. Ensure HDF5 is installed first. ```shell ./configure && make && make install ``` -------------------------------- ### Build Examples Subdirectory Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/CMakeLists.txt Includes the 'examples' subdirectory to build any examples defined within it. This is a standard CMake command for managing subprojects. ```cmake #----------------------------------------------------------------------------- # Build examples add_subdirectory(examples) ``` -------------------------------- ### Install libxml2 Library Targets Source: https://github.com/kitware/vtk/blob/master/ThirdParty/libxml2/vtklibxml2/CMakeLists.txt Installs the libxml2 library, including archive, library, and runtime components. This setup is for the development and runtime components. ```cmake install( TARGETS LibXml2 EXPORT LibXml2 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_COMPONENT development RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime ) ``` -------------------------------- ### Install VTK Build Source: https://github.com/kitware/vtk/blob/master/Wrapping/Java/README.md Install the VTK build to a specified directory. Replace $INSTALLDIR with your desired installation path. ```bash # Substitute $INSTALLDIR cmake --install build --prefix $INSTALLDIR ``` -------------------------------- ### WebGPU Compute API Usage Example Source: https://github.com/kitware/vtk/blob/master/Rendering/WebGPU/doc/webgpu-compute-api-dev.md Illustrates the basic steps for using the WebGPU compute API for standalone compute tasks, including buffer and pipeline setup, and dispatching the compute shader. ```c++ // 1) vtkNew inputBuffer; inputBuffer->SetGroup(0); inputBuffer->SetBinding(0); inputBuffer->SetMode(...); inputBuffer->SetData(...); vtkNew computePipeline; computePipeline->SetShaderSource(...); computePipeline->SetShaderEntryPoint(...); // 2) computePipeline->AddBuffer(inputBuffer); // ... // 3) computePipeline->Dispatch(); ``` -------------------------------- ### Setup Test Infrastructure Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/CMakeLists.txt Includes and calls a module to set up the necessary infrastructure for running tests against a temporary installed version of Viskores. ```cmake # Setup the infrastructure to allow Viskores to run tests against a temporary # installed version of Viskores. include(testing/ViskoresTestInstall) viskores_test_install() ``` -------------------------------- ### Install zlib Manual Page Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Installs the zlib manual page file to the installation man3 directory. ```cmake install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") ``` -------------------------------- ### Install Development Files Source: https://github.com/kitware/vtk/blob/master/ThirdParty/xdmf2/vtkxdmf2/libsrc/CMakeLists.txt Installs development header files and the configuration header to the specified installation directory. ```cmake if(NOT XDMF_INSTALL_NO_DEVELOPMENT) file(GLOB devFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h") install( FILES ${devFiles} DESTINATION ${XDMF_INSTALL_INCLUDE_DIR} COMPONENT Development) install( FILES ${xdmf2_BINARY_DIR}/libsrc/XdmfConfig.h DESTINATION ${XDMF_INSTALL_INCLUDE_DIR} COMPONENT Development) endif() ``` -------------------------------- ### Install Doxygen Documentation Files Source: https://github.com/kitware/vtk/blob/master/Utilities/Doxygen/CMakeLists.txt Installs various documentation-related files and directories to the installation prefix if documentation installation is not disabled. ```cmake if(NOT VTK_INSTALL_NO_DOCUMENTATION) macro(__vtk_install_documentation_files glob) file(GLOB __files "${CMAKE_CURRENT_SOURCE_DIR}/${glob}") install(FILES ${__files} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/vtk${vtk_version_suffix}/doxygen" COMPONENT doxygen) endmacro() __vtk_install_documentation_files("*.css") __vtk_install_documentation_files("*.gif") __vtk_install_documentation_files("*.html") __vtk_install_documentation_files("*.js") __vtk_install_documentation_files("*.pl") __vtk_install_documentation_files("*.stop") install(FILES doc_readme.txt DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/vtk${vtk_version_suffix}/doxygen" COMPONENT doxygen) install(DIRECTORY ${VTK_BINARY_DIR}/Utilities/Doxygen/doc/html DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/vtk${vtk_version_suffix}/doxygen" COMPONENT doxygen) endif() ``` -------------------------------- ### Build and Install TIFF Source: https://github.com/kitware/vtk/blob/master/ThirdParty/tiff/vtktiff/README.md Standard procedure for configuring, building, and installing the TIFF library from source. ```bash % ./configure % make % su # make install ``` -------------------------------- ### Pkg-config File Generation and Installation Source: https://github.com/kitware/vtk/blob/master/ThirdParty/libxml2/vtklibxml2/CMakeLists.txt Generates the libxml-2.0.pc file from a template and installs it to the pkgconfig directory. Handles path calculations for installation. ```cmake if (FALSE) # XXX(kitware): mask installation rules set(XML_INCLUDEDIR "-I\\ ${includedir}/libxml2") set(XML_LIBDIR "-L\\ ${libdir}") set(XML_LIBS "-lxml2") if(BUILD_SHARED_LIBS) set(XML_PC_PRIVATE ".private") set(XML_PC_LIBS_PRIVATE " Libs.private:") else() set(XML_PRIVATE_LIBS_NO_SHARED "${XML_PRIVATE_LIBS}") endif() if(WIN32) set(XML_STATIC_CFLAGS "-DLIBXML_STATIC") if (BUILD_SHARED_LIBS) set(XML_PC_CFLAGS_PRIVATE " Cflags.private:") else() target_compile_definitions(LibXml2 PUBLIC LIBXML_STATIC) set(XML_CFLAGS "${XML_STATIC_CFLAGS}") endif() endif() file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}") string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}") if(WIN32) set(prefix "\\ $pcfiledir/${PACKAGE_RELATIVE_PATH}") else() set(prefix "${CMAKE_INSTALL_PREFIX}") endif() set(exec_prefix "\\ $prefix") set(libdir "\\ $prefix/${CMAKE_INSTALL_LIBDIR}") set(includedir "\\ $prefix/${CMAKE_INSTALL_INCLUDEDIR}") configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development) if(WIN32) set(prefix "$( cd \"\$( dirname \"\$0\")\"; pwd -P)/..") endif() configure_file(xml2-config.in xml2-config @ONLY) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xml2-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development) set(XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2") set(XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}") include(CPack) endif () ``` -------------------------------- ### Install libxml2 with Autotools Source: https://github.com/kitware/vtk/blob/master/ThirdParty/libxml2/vtklibxml2/README.md Install the library after successful configuration and build. ```bash make install ``` -------------------------------- ### Install License File Source: https://github.com/kitware/vtk/blob/master/Utilities/KWSys/vtksys/CMakeLists.txt Installs the Copyright.txt license file to the documentation directory with specified options. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LICENSE_OPTIONS}) ``` -------------------------------- ### Install CGNS Library Source: https://github.com/kitware/vtk/blob/master/ThirdParty/cgns/vtkcgns/README.md Run this command to install the CGNS library. Ensure you have the necessary permissions to write to the installation directory. ```shell user@hostname:build_path$ make install ``` -------------------------------- ### Install zlib Pkgconfig File Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Installs the zlib pkgconfig file to the installation pkgconfig directory. ```cmake install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") ``` -------------------------------- ### Add Examples Subdirectory Source: https://github.com/kitware/vtk/blob/master/CMakeLists.txt Adds the Examples subdirectory to the build if VTK_BUILD_EXAMPLES is enabled. ```cmake add_subdirectory(Examples) ``` -------------------------------- ### Build Expat Example Executables Source: https://github.com/kitware/vtk/blob/master/ThirdParty/expat/vtkexpat/CMakeLists.txt Configures the build for Expat example programs. It iterates through a list of example targets, creates executables for each, sets their output directory, and links them against the Expat library. ```cmake if(EXPAT_BUILD_EXAMPLES) foreach(_target element_declarations elements outline) add_executable(${_target} examples/${_target}.c) set_property(TARGET ${_target} PROPERTY RUNTIME_OUTPUT_DIRECTORY examples) target_link_libraries(${_target} expat) endforeach() endif() ``` -------------------------------- ### Configure Install Options Source: https://github.com/kitware/vtk/blob/master/ThirdParty/ogg/vtkogg/CMakeLists.txt Sets options for installing documentation, pkg-config modules, and CMake package configuration files. These control the contents of the installation. ```cmake if (FALSE) # Install options option(INSTALL_DOCS "Install documentation" ON) option(INSTALL_PKG_CONFIG_MODULE "Install ogg.pc file" ON) option(INSTALL_CMAKE_PACKAGE_MODULE "Install CMake package configuration module" ON) # Extract project version from configure.ac file(READ configure.ac CONFIGURE_AC_CONTENTS) string(REGEX MATCH "AC_INIT\(\[libogg\],\[([0-9]*).([0-9]*).([0-9]*)\]" DUMMY ${CONFIGURE_AC_CONTENTS}) set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3}) else () set(INSTALL_DOCS OFF) set(INSTALL_PKG_CONFIG_MODULE OFF) set(INSTALL_CMAKE_PACKAGE_MODULE OFF) set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MINOR 3) set(PROJECT_VERSION_PATCH 4) endif () set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) ``` -------------------------------- ### Add Subdirectories for Token and Examples Source: https://github.com/kitware/vtk/blob/master/ThirdParty/token/vtktoken/CMakeLists.txt Adds the main token module subdirectory and conditionally adds the examples subdirectory if examples are enabled. ```cmake add_subdirectory(token) if (token_ENABLE_EXAMPLES) add_subdirectory(examples) endif() ``` -------------------------------- ### Install VTK from PyPI Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/advanced/available_python_wheels.md Installs the standard VTK Python wheel from the Python Package Index (PyPI). This is the most common way to install VTK. ```bash pip install vtk ``` -------------------------------- ### Install Copyright File Source: https://github.com/kitware/vtk/blob/master/CMakeLists.txt Installs the Copyright.txt file to the license directory, associated with the 'license' component. ```cmake install( FILES "${CMAKE_CURRENT_LIST_DIR}/Copyright.txt" DESTINATION "${CMAKE_INSTALL_LICENSEDIR}" COMPONENT "license") ``` -------------------------------- ### Compile and Install LZ4 Source: https://github.com/kitware/vtk/blob/master/ThirdParty/lz4/vtklz4/README.md Standard procedure to compile and install the LZ4 library using make. This may require root permissions for the installation step. ```bash make make install # this command may require root permissions ``` -------------------------------- ### Start Cesium web server Source: https://github.com/kitware/vtk/blob/master/IO/Cesium3DTiles/README.md Starts the web server for Cesium 3D Tiles samples. ```bash cd ..;npm start ``` -------------------------------- ### Basic CLI App Setup Source: https://github.com/kitware/vtk/blob/master/ThirdParty/cli11/vtkcli11/README.md Sets up a basic command-line application with a description and a single file option. Ensures UTF-8 compatibility for arguments. ```cpp int main(int argc, char** argv) { CLI::App app{"App description"}; argv = app.ensure_utf8(argv); std::string filename = "default"; app.add_option("-f,--file", filename, "A help string"); CLI11_PARSE(app, argc, argv); return 0; } ``` -------------------------------- ### VTK Folder Structure Example Source: https://github.com/kitware/vtk/blob/master/Documentation/dev/build_windows_vs.md This illustrates the expected folder structure after preparing the VTK source and build directories. ```cmd c:\data\cpp\vtk\build <--empty c:\data\cpp\vtk\src c:\data\cpp\vtk\src\Accelerators c:\data\cpp\vtk\src\Charts c:\data\cpp\vtk\src\.... ``` -------------------------------- ### Add Executable and Link Libraries Source: https://github.com/kitware/vtk/blob/master/Examples/Build/vtkMy/Examples/Cxx/Ex1/CMakeLists.txt Defines the executable for the example and links it against required VTK libraries. This is a standard setup for VTK C++ examples. ```cmake add_executable(vtkmyEx1 vtkmyEx1.cxx) target_link_libraries(vtkmyEx1 VTKMY::Unsorted VTKMY::Common VTKMY::Imaging) ``` -------------------------------- ### Build and Test VTK Token Examples Source: https://github.com/kitware/vtk/blob/master/ThirdParty/token/vtktoken/examples/CMakeLists.txt Configures CMake to build executable examples for VTK token functionalities. It links against the 'token' library and adds tests for each example. ```cmake set(examples basic containers switch-case ) foreach (example ${examples}) add_executable(${example} ${example}.cxx) target_link_libraries(${example} PRIVATE token ) add_test(NAME "example-${example}" COMMAND ${example}) endforeach() ``` -------------------------------- ### WebGPU Compute Pipeline Setup and Execution Source: https://github.com/kitware/vtk/blob/master/Rendering/WebGPU/doc/webgpu-compute-api-user.md This snippet demonstrates the complete process of setting up input and output buffers, creating a compute pipeline, dispatching a compute shader, and reading the results back from the GPU. Ensure the output buffer size is correctly set and the callback function properly handles data transfer. ```c++ std::vector inputValues; // ... // Fill the input vector with data // ... // Creating the input buffer to the compute shader vtkNew inputBuffer; inputBuffer->SetGroup(0); inputBuffer->SetBinding(0); inputBuffer->SetMode(vtkWebGPUComputeBuffer::BufferMode::READ_ONLY_COMPUTE_STORAGE); inputBuffer->SetData(inputValues); inputBuffer->SetDataType(vtkWebGPUComputeBuffer::BufferDataType::STD_VECTOR); // Creating the output buffer of the compute shader vtkNew outputBuffer; outputBuffer->SetGroup(0); outputBuffer->SetBinding(1); outputBuffer->SetMode(vtkWebGPUComputeBuffer::BufferMode::READ_WRITE_MAP_COMPUTE_STORAGE); outputBuffer->SetByteSize(inputValues.size() * sizeof(float)); // Creating the compute pipeline vtkNew computePipeline; vtkSmartPointer computePass = computePipeline->CreateComputePass(); computePass->SetShaderSource(computeShaderSource); computePass->SetShaderEntryPoint("computeMainFunction"); computePass->AddBuffer(inputBuffer); // Getting the index of the output buffer for later mapping with ReadBufferFromGPU() int outputBufferIndex = computePipeline->AddBuffer(outputBuffer); computePass->SetWorkgroups(workgroupsX, workgroupsY, workgroupsZ); // We've set up everything, ready to dispatch computePass->Dispatch(); // Vector that will contain the results of the compute shader std::vector outputData(outputBufferSize); // Function called by ReadBufferFromGPU() whose purpose is to copy // the data into your result buffer (outputData here). auto onBufferMapped = [](const void* mappedData, void* userdata) { std::vector* outputDataVector = reinterpret_cast*>(userdata); // You must know in advance how many elements you're going to read from the mappedData. // We're using the size of outputDataVector here because we resized it to just the right // size so that's just the right number of elements. If you don't want or can't use a // std::vector for that purpose, you can still pass the number of elements as the third // argument of ReadBufferFromGPU(). vtkIdType elementCount = outputDataVector->size(); const float* mappedDataAsF32 = static_cast(mappedData); for (int i = 0; i < elementCount; i++) { (*outputDataVector)[i] = mappedDataAsF32[i]; } }; // Mapping the buffer on the CPU to get the results from the GPU computePass->ReadBufferFromGPU(outputBufferIndex, onBufferMapped, &outputData); // Update() to actually execute WebGPU commands. Without this, the compute shader won't execute. // Update() is called on the compute pipeline and not the compute pass because it is the // compute pipeline that orchestrates the execution of all compute passes computePipeline->Update(); // ... Do something with the output data ``` -------------------------------- ### Install libxml2 with CMake Source: https://github.com/kitware/vtk/blob/master/ThirdParty/libxml2/vtklibxml2/README.md Install the built libxml2 library using CMake. ```bash cmake --install builddir ``` -------------------------------- ### Set KWSYS Installation Binary Directory Source: https://github.com/kitware/vtk/blob/master/Utilities/KWSys/vtksys/CMakeLists.txt Sets the KWSYS_INSTALL_BIN_DIR if it's not already defined, deriving it from KWSYS_LIBRARY_INSTALL_DIR. This ensures consistent binary installation paths, compatible with old library directory setups. ```cmake if(NOT KWSYS_INSTALL_BIN_DIR) string(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR "${KWSYS_LIBRARY_INSTALL_DIR}") endif() ``` -------------------------------- ### Install Latest Release VTK Wheel from GitLab Registry Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/advanced/available_python_wheels.md Installs the latest release VTK Python wheel directly from the GitLab Package Registry. Use this to get the most recent stable version. ```bash pip install --extra-index-url https://wheels.vtk.org vtk ``` -------------------------------- ### Variable/Vector Assignment Examples Source: https://github.com/kitware/vtk/blob/master/ThirdParty/exprtk/vtkexprtk/readme.txt Demonstrates assignment operations between variables and vectors. A variable can be assigned to a vector (all elements get the variable's value), and a vector can be assigned to a variable (variable gets the first element's value). ```ExprTk var x := 3; var y[3] := { 1, 2, 3 }; y := x + 1; ``` ```ExprTk var x := 3; var y[3] := { 1, 2, 3 }; x := y + 1; ``` -------------------------------- ### Build Dawn from Source Source: https://github.com/kitware/vtk/blob/master/Rendering/WebGPU/README.md Steps to clone Dawn, checkout a specific version, build it, and install it to a specified directory. Ensure DAWN_INSTALL_DIR is set correctly. ```sh # Clone the repo and checkout the required version git clone https://github.com/google/dawn dawn && cd dawn git checkout v20260421.125655 cmake -S . -B out/Debug -GNinja -DDAWN_FETCH_DEPENDENCIES=ON -DDAWN_ENABLE_INSTALL=ON cmake --build out/Debug cmake --install out/Debug --prefix ${DAWN_INSTALL_DIR} ``` -------------------------------- ### Class Docstrings Example Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/advanced/PythonWrappers.md Illustrates the structure of class docstrings, starting with a brief description, superclass, and then the full doxygen documentation. ```Python vtkMatrix4x4 - represent and manipulate 4x4 transformation matrices Superclass: vtkObject vtkMatrix4x4 is a class to represent and manipulate 4x4 matrices. Specifically, it is designed to work on 4x4 transformation matrices found in 3D rendering using homogeneous coordinates [x y z w]. Many of the methods take an array of 16 doubles in row-major format. Note that OpenGL stores matrices in column-major format, so the matrix contents must be transposed when they are moved between OpenGL and VTK. @sa vtkTransform ``` -------------------------------- ### Setup Event Listeners and Start Render Window Source: https://github.com/kitware/vtk/blob/master/Examples/JavaScript/cow.html Configures the canvas to receive keyboard input and focus, attaches a click listener to ensure focus, and finally starts the VTK render window's event loop to enable interaction. ```javascript // focus on the canvas to grab keyboard inputs. canvas.setAttribute('tabindex', '0'); // grab focus when the render window region receives mouse clicks. canvas.addEventListener('click', () => canvas.focus()); // start the event loop on browser UI thread. renderWindowInteractor.Start() ``` -------------------------------- ### Basic Loguru Setup and File Logging Source: https://github.com/kitware/vtk/blob/master/ThirdParty/loguru/vtkloguru/README.md Includes Loguru, initializes logging, and sets up files for different verbosity levels. Use this for general application logging. ```C++ #include … // Optional, but useful to time-stamp the start of the log. // Will also detect verbosity level on command line as -v. loguru::init(argc, argv); // Put every log message in "everything.log": loguru::add_file("everything.log", loguru::Append, loguru::Verbosity_MAX); // Only log INFO, WARNING, ERROR and FATAL to "latest_readable.log": loguru::add_file("latest_readable.log", loguru::Truncate, loguru::Verbosity_INFO); // Only show most relevant things on stderr: loguru::g_stderr_verbosity = 1; LOG_SCOPE_F(INFO, "Will indent all log messages within this scope."); LOG_F(INFO, "I'm hungry for some %.3f!", 3.14159); LOG_F(2, "Will only show if verbosity is 2 or higher"); VLOG_F(get_log_level(), "Use vlog for dynamic log level (integer in the range 0-9, inclusive)"); LOG_IF_F(ERROR, badness, "Will only show if badness happens"); auto fp = fopen(filename, "r"); CHECK_F(fp != nullptr, "Failed to open file '%s'", filename); CHECK_GT_F(length, 0); // Will print the value of `length` on failure. CHECK_EQ_F(a, b, "You can also supply a custom message, like to print something: %d", a + b); // Each function also comes with a version prefixed with D for Debug: DCHECK_F(expensive_check(x)); // Only checked #if !NDEBUG DLOG_F(INFO, "Only written in debug-builds"); // Turn off writing to stderr: loguru::g_stderr_verbosity = loguru::Verbosity_OFF; // Turn off writing err/warn in red: loguru::g_colorlogtostderr = false; // Throw exceptions instead of aborting on CHECK fails: loguru::set_fatal_handler([](const loguru::Message& message){ throw std::runtime_error(std::string(message.prefix) + message.message); }); ``` -------------------------------- ### Build and Install with Meson Source: https://github.com/kitware/vtk/blob/master/ThirdParty/libxml2/vtklibxml2/README.md Commands to set up, build, test, and install libxml2 using the Meson build system. ```bash meson setup [options] builddir ninja -C builddir meson test -C builddir ninja -C builddir install ``` -------------------------------- ### Install and Pull Git LFS Datasets Source: https://github.com/kitware/vtk/blob/master/ThirdParty/fides/vtkfides/README.md Initialize and pull datasets managed by Git LFS. This is a required setup step for Fides. ```bash fides$ git lfs install fides$ git lfs pull ``` -------------------------------- ### Setup Development Environment Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/developers_guide/develop_quickstart.md Run the developer setup script to prepare your VTK work tree and configure Git aliases. This script also sets up a data directory and configures a 'gitlab' remote for your fork. ```bash ./Utilities/SetupForDevelopment.sh ``` -------------------------------- ### Install VTK in a Linux virtual environment Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/getting_started/using_python.md Create a virtual environment, activate it, and then install VTK on Linux. ```bash python -m venv ./env source ./env/bin/activate pip install vtk ``` -------------------------------- ### Initialize Points for SMP Operations Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/design_documents/smptools.md Initializes a vtkPoints object with random float coordinates. This is a setup step for parallel processing examples. ```c++ vtkNew pts; pts->SetDataTypeToFloat(); pts->SetNumberOfPoints(numPts); for ( auto i=0; i < numPts; ++i) { pts->SetPoint(i, vtkMath::Random(-1,1), vtkMath::Random(-1,1), vtkMath::Random(-1,1)); } ``` -------------------------------- ### Get include flags with pkg-config Source: https://github.com/kitware/vtk/blob/master/ThirdParty/nlohmannjson/vtknlohmannjson/README.md Use this command in bare Makefiles to obtain the necessary include flags for the installed nlohmann_json library. ```sh pkg-config nlohmann_json --cflags ``` -------------------------------- ### Project and Package Configuration Source: https://github.com/kitware/vtk/blob/master/Examples/Build/VTKPythonExtensions/CMakeLists.txt Sets up the project with version information and finds the necessary VTK components, including Python bindings. ```cmake cmake_minimum_required(VERSION 3.21...4.0) project( vtk-pyext VERSION ${SKBUILD_PROJECT_VERSION} DESCRIPTION "VTK SDK python distributions example" HOMEPAGE_URL "https://gitlab.kitware.com/vtk/vtk" LANGUAGES CXX ) # Find the VTK-SDK provided VTK package # It will be found in a temporary folder generated by scikit-build-core # thanks to the [entry-point mecanism](https://github.com/Kitware/vtk-sdk-python-distributions) find_package(VTK CONFIG REQUIRED COMPONENTS CommonCore Python) ``` -------------------------------- ### VTKData Download Output Example Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/developers_guide/git/test.md Example output when building the VTKData target, showing the download progress and the location of downloaded objects. ```bash -- Fetching ".../ExternalData/SHA512/" -- [download 100% complete] -- Downloaded object: "VTK-build/ExternalData/Objects/SHA512/..." ``` -------------------------------- ### Get Short Commit Hash for Next Update Source: https://github.com/kitware/vtk/blob/master/ThirdParty/xdmf2/vtkxdmf2/README-VTK.txt Retrieve the short commit hash from the xdmf2-upstream branch, which will be used as the starting point for the next update. ```bash git rev-parse --short=8 xdmf2-upstream ``` -------------------------------- ### Get Short Commit Hash for Next Update Source: https://github.com/kitware/vtk/blob/master/IO/Xdmf2/README.md Retrieve the short commit hash from the xdmf2vtk-upstream branch, which will be used as the starting point for the next update. ```bash git rev-parse --short=8 xdmf2vtk-upstream ``` -------------------------------- ### Build Viskores from Source (*nix) Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/README.md Example commands for building Viskores on Unix-like systems. This involves unpacking the source, creating a build directory, running CMake, and then building the project. ```shell $ tar xvzf ~/Downloads/viskores-v2.0.0.tar.gz $ mkdir viskores-build $ cd viskores-build $ cmake-gui ../viskores-v2.0.0 $ cmake --build -j . # Runs make (or other build program) ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://github.com/kitware/vtk/blob/master/Examples/Emscripten/Cxx/ModuleTesting/CMakeLists.txt Sets the minimum required CMake version and defines the project name. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.12...3.21 FATAL_ERROR) project(ExoticShapes) ``` -------------------------------- ### Basic Logging Example Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/viskores/thirdparty/loguru/viskoresloguru/README.md Demonstrates basic logging to stderr and a file with different verbosity levels. Ensure loguru.cpp is built or included. ```C++ #include int main(int argc, char* argv[]) { loguru::init(argc, argv); // Optional: Set a custom thread name loguru::set_thread_name("main_thread"); LOG_INFO("Application started."); LOG_WARNING("This is a warning message."); LOG_ERROR("An error occurred."); // Example with arguments int value = 42; LOG_INFO("The value is: {}", value); // Example with file and line info (automatically included) LOG_DEBUG("This is a debug message from {}:{}", __FILE__, __LINE__); return 0; } ``` -------------------------------- ### Configure Viskores Testing Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/examples/CMakeLists.txt This snippet configures the testing environment for Viskores. It conditionally enables testing if Viskores_ENABLE_TESTING is set. It then uses helper functions to test specific examples against the installed Viskores libraries using both CMake and Make build systems. ```cmake if (Viskores_ENABLE_TESTING) # These need to be fast to build as they will # be built each time we run the test viskores_test_against_install_cmake(demo) viskores_test_against_install_cmake(histogram) viskores_test_against_install_cmake(smoke_test) viskores_test_against_install_make(smoke_test) endif() ``` -------------------------------- ### Build HTML Documentation Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/advanced/build_documentation.md Execute this command to build the HTML version of the documentation after dependencies are installed. ```shell make html ``` -------------------------------- ### Install viskoreslcl Headers Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/viskores/thirdparty/lcl/CMakeLists.txt Installs the 'viskoreslcl' directory containing headers to the installation destination. This is conditional on 'Viskores_INSTALL_ONLY_LIBRARIES' not being set, meaning headers are installed during a full library installation. ```cmake if(NOT Viskores_INSTALL_ONLY_LIBRARIES) install(DIRECTORY viskoreslcl DESTINATION ${Viskores_INSTALL_INCLUDE_DIR}/${kit_dir}/) endif() ``` -------------------------------- ### Configure HDF5 Build Examples Option Source: https://github.com/kitware/vtk/blob/master/ThirdParty/hdf5/vtkhdf5/CMakeLists.txt Sets the HDF5_BUILD_EXAMPLES option based on the existence of the HDF5Examples directory and a hardcoded 'FALSE' check. By default, examples are not built. ```cmake if (EXISTS "${HDF5_SOURCE_DIR}/HDF5Examples" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/HDF5Examples") if (FALSE) # XXX(kitware): Hardcode settings. option (HDF5_BUILD_EXAMPLES "Build HDF5 Library Examples" ON) else () set(HDF5_BUILD_EXAMPLES OFF) endif () if (HDF5_BUILD_EXAMPLES AND NOT USE_SANITIZER) include (${HDF_RESOURCES_DIR}/HDF5ExampleCache.cmake) set (HDF5_VERSION ${HDF5_PACKAGE_VERSION}) add_subdirectory (HDF5Examples) endif () endif () ``` -------------------------------- ### Build Example Executable Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Adds an executable for the zlib example and links it against the zlib library. It also registers it as a test. ```cmake if(ZLIB_BUILD_EXAMPLES) add_executable(example test/example.c) target_link_libraries(example zlib) add_test(example example) add_executable(minigzip test/minigzip.c) target_link_libraries(minigzip zlib) if(HAVE_OFF64_T) add_executable(example64 test/example.c) target_link_libraries(example64 zlib) set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") add_test(example64 example64) add_executable(minigzip64 test/minigzip.c) target_link_libraries(minigzip64 zlib) set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() endif() ``` -------------------------------- ### Install Target Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/viskores/thirdparty/loguru/CMakeLists.txt Installs the viskores_loguru target using the viskores_install_targets macro, making it available for installation. ```cmake viskores_install_targets(TARGETS viskores_loguru) ``` -------------------------------- ### Install VTK in a Windows virtual environment (cmd.exe) Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/getting_started/using_python.md Create a virtual environment, activate it using cmd.exe, and then install VTK on Windows. ```batch python -m venv env .\env\activate.bat pip install vtk ``` -------------------------------- ### Run VTK Java Demonstration Source: https://github.com/kitware/vtk/blob/master/Wrapping/Java/README.md Execute a VTK Java sample using the built VTK JARs and JOGL libraries. Ensure the classpath and library path are correctly set. ```bash java -cp $INSTALLDIR/vtk-XY.jar:/home/kitware/.m2/repository/org/jogamp/gluegen/gluegen-rt/2.6.0/gluegen-rt-2.6.0.jar:/home/kitware/.m2/repository/org/jogamp/jogl/jogl-all/2.6.0/jogl-all-2.6.0.jar -Djava.library.path=$INSTALLDIR/natives-Linux-64bit vtk.sample.Demo ``` -------------------------------- ### Fetch Pre-built Dawn Binaries (Linux) Source: https://github.com/kitware/vtk/blob/master/Rendering/WebGPU/README.md Downloads and installs pre-built Dawn binaries for Linux. Sets the DAWN_INSTALL_DIR environment variable. ```sh cd "${VTK_SOURCE_DIR}" CMAKE_CONFIGURATION="fedora" cmake -P .gitlab/ci/download_dawn.cmake export DAWN_INSTALL_DIR="${VTK_SOURCE_DIR}/.gitlab/dawn" ``` -------------------------------- ### Install zlib Public Headers Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Installs the public header files for the zlib library to the installation include directory. ```cmake install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") ``` -------------------------------- ### Benchmark Utility Command Line Usage Source: https://github.com/kitware/vtk/blob/master/ThirdParty/exprtk/vtkexprtk/readme.txt Example of how to run the benchmark utility with a file of expressions and a specified number of evaluations. ```bash ./exprtk_benchmark my_expressions.txt 1000000 ``` -------------------------------- ### Install SQLite TCL Extension Source: https://github.com/kitware/vtk/blob/master/ThirdParty/sqlite/vtksqlite/README.md Build and install the SQLite TCL extension. This target requires 'tcl-dev' to be installed. ```bash make tclextension-install ;# Build and install the SQLite TCL extension ``` -------------------------------- ### Install KWIML Headers Source: https://github.com/kitware/vtk/blob/master/Utilities/KWIML/vtkkwiml/CMakeLists.txt Installs the necessary KWIML header files to the specified installation directory. This is conditional on KWIML_INSTALL_INCLUDE_DIR being defined. ```cmake if(KWIML_INSTALL_INCLUDE_DIR) install(FILES include/kwiml/abi.h include/kwiml/int.h DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML_INCLUDE_PREFIX} ${KWIML_INSTALL_INCLUDE_OPTIONS} ) endif() ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/kitware/vtk/blob/master/Examples/Modules/Wrapping/CMakeLists.txt Sets up the minimum CMake version, project name, and output directories for runtime, library, and archive files. ```cmake cmake_minimum_required(VERSION 3.8) project(Wrapping) include(GNUInstallDirs) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") ``` -------------------------------- ### Prepare VTK Work Tree Source: https://github.com/kitware/vtk/blob/master/CONTRIBUTING.md Run the developer setup script to prepare your VTK work tree and create necessary Git command aliases. This script also configures a 'gitlab' remote for your fork. ```bash $ ./Utilities/SetupForDevelopment.sh ``` -------------------------------- ### Create Install Target for Library Source: https://github.com/kitware/vtk/blob/master/Utilities/KWSys/vtksys/CMakeLists.txt Defines installation rules for the library targets. This ensures the library and its related components are installed correctly. ```cmake if(KWSYS_INSTALL_LIBRARY_RULE) install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE}) endif() if(KWSYS_INSTALL_NAMELINK_RULE) install(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE}) endif() ``` -------------------------------- ### Fetch Pre-built Dawn Binaries (Windows) Source: https://github.com/kitware/vtk/blob/master/Rendering/WebGPU/README.md Downloads and installs pre-built Dawn binaries for Windows using PowerShell. Sets the DAWN_INSTALL_DIR environment variable. ```pwsh cd "$env:VTK_SOURCE_DIR" $env:CMAKE_CONFIGURATION="windows"; cmake -P .gitlab/ci/download_dawn.cmake $env:DAWN_INSTALL_DIR="$env:VTK_SOURCE_DIR\.gitlab\dawn" ``` -------------------------------- ### Install Target Export Source: https://github.com/kitware/vtk/blob/master/ThirdParty/xdmf2/vtkxdmf2/libsrc/CMakeLists.txt Installs the vtkxdmf2 target for export, specifying runtime, library, and archive destinations based on installation configuration. ```cmake if(XDMF_INSTALL_EXPORT_NAME AND NOT XDMF_INSTALL_NO_LIBRARIES) install(TARGETS vtkxdmf2 EXPORT ${XDMF_INSTALL_EXPORT_NAME} RUNTIME DESTINATION ${XDMF_INSTALL_BIN_DIR} COMPONENT Runtime LIBRARY DESTINATION ${XDMF_INSTALL_LIB_DIR} COMPONENT Runtime ARCHIVE DESTINATION ${XDMF_INSTALL_LIB_DIR} COMPONENT Development) endif() ``` -------------------------------- ### Install VTK in a Windows virtual environment (PowerShell) Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/getting_started/using_python.md Create a virtual environment, activate it using PowerShell, and then install VTK on Windows. ```powershell python -m venv env .\env\Activate.ps1 pip install vtk ``` -------------------------------- ### Select WebGPU Backend at Runtime Source: https://github.com/kitware/vtk/blob/master/Examples/Emscripten/Cxx/ConeMultiBackend/README.md Pass command-line arguments during VTK WASM module initialization to prefer the WebGPU rendering backend. Ensure VTK preferences are initialized from these arguments before creating VTK objects. ```c++ // Initialize VTK WASM module with command line arguments // e.g., "--vtk-factory-prefer RenderingBackend=WebGPU" vtkObjectFactory::InitializePreferencesFromCommandLineArgs(argc, argv); ``` -------------------------------- ### Create and Activate Python Virtual Environment Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/README.md Sets up a Python virtual environment and activates it for installing documentation build dependencies. ```bash python -m venv env source env/bin/activate ``` -------------------------------- ### Install DIY Headers Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/viskores/thirdparty/diy/CMakeLists.txt Installs the necessary DIY header files to the project's include directory. This step is skipped if only libraries are being installed. ```cmake ## Install headers if (NOT Viskores_INSTALL_ONLY_LIBRARIES) install(FILES ${Viskores_BINARY_INCLUDE_DIR}/${kit_dir}/Configure.h ${CMAKE_CURRENT_SOURCE_DIR}/diy.h ${CMAKE_CURRENT_SOURCE_DIR}/environment.h ${CMAKE_CURRENT_SOURCE_DIR}/mpi-cast.h ${CMAKE_CURRENT_SOURCE_DIR}/post-include.h ${CMAKE_CURRENT_SOURCE_DIR}/pre-include.h ${CMAKE_CURRENT_SOURCE_DIR}/serialization.h DESTINATION ${Viskores_INSTALL_INCLUDE_DIR}/${kit_dir}/) ``` -------------------------------- ### Install PugiXML Header Source: https://github.com/kitware/vtk/blob/master/ThirdParty/pugixml/CMakeLists.txt Installs the generated PugiXML header file to the appropriate location within the VTK installation directory using `vtk_module_install_headers`. ```cmake vtk_module_install_headers( FILES "${CMAKE_CURRENT_BINARY_DIR}/vtk_pugixml.h") ``` -------------------------------- ### Configure Zlib Build Examples Option Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Defines whether to build Zlib examples. This option is typically controlled by VTK's build system. ```cmake if (FALSE) # XXX(kitware): hardcode settings option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) else () set(ZLIB_BUILD_EXAMPLES OFF) endif () ``` -------------------------------- ### Install Expat with DESTDIR Source: https://github.com/kitware/vtk/blob/master/ThirdParty/expat/vtkexpat/README.md Use the DESTDIR variable during 'make install' to specify a staging directory for installation, useful for creating package images. ```bash make install DESTDIR=/path/to/image ``` -------------------------------- ### Install Version and CMake Files Source: https://github.com/kitware/vtk/blob/master/CMake/wheel_sdks/CMakeLists.txt Installs the generated _version.py file and the configured CMake configuration files into the vtk_sdk directory structure. ```cmake install( FILES ${CMAKE_CURRENT_BINARY_DIR}/_version.py DESTINATION vtk_sdk ) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vtk_sdk/cmake/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config-version.cmake DESTINATION vtk_sdk/cmake ) ``` -------------------------------- ### Configure Installation Directories Source: https://github.com/kitware/vtk/blob/master/ThirdParty/zlib/vtkzlib/CMakeLists.txt Sets installation directories for executables, libraries, headers, man pages, and pkgconfig files. VTK usually manages these settings. ```cmake if (FALSE) # XXX(kitware): VTK handles installation. set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") endif () ``` -------------------------------- ### Set Viskores Installation Paths Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/CMakeLists.txt Configures the installation directories for Viskores libraries, headers, and CMake modules. This ensures proper integration when Viskores is installed. ```cmake set(Viskores_INSTALL_LIB_DIR "${_vtk_build_LIBRARY_DESTINATION}") set(Viskores_INSTALL_INCLUDE_DIR "${_vtk_build_HEADERS_DESTINATION}/vtkviskores/viskores") if (DEFINED _vtk_build_LIBRARY_NAME_SUFFIX) set(Viskores_CUSTOM_LIBRARY_SUFFIX "-${_vtk_build_LIBRARY_NAME_SUFFIX}") endif () set(Viskores_EXECUTABLE_OUTPUT_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") set(Viskores_LIBRARY_OUTPUT_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") set(Viskores_BUILD_CMAKE_BASE_DIR "${CMAKE_BINARY_DIR}") set(Viskores_INSTALL_CONFIG_DIR "${_vtk_build_CMAKE_DESTINATION}/viskores") set(Viskores_INSTALL_CMAKE_MODULE_DIR "${Viskores_INSTALL_CONFIG_DIR}/cmake") # Currently Viskores only installs its readme and license. set(Viskores_INSTALL_SHARE_DIR "${_vtk_build_LICENSE_DESTINATION}/vtkviskores") ``` -------------------------------- ### Install SDK Binaries Source: https://github.com/kitware/vtk/blob/master/CMake/wheel_sdks/CMakeLists.txt Installs the executable binaries for the VTK SDK. Permissions are set to allow read, write, and execute for the owner, and read and execute for group and world. ```cmake install( DIRECTORY ${VTK_INSTALL_DIR}/bin/ DESTINATION vtk_sdk/${VTK_SDK_INSTALL_DIR}/bin PATTERN "*" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) ``` -------------------------------- ### Add VTK Example Test Source: https://github.com/kitware/vtk/blob/master/Examples/CMakeLists.txt Adds a VTK example as a CTest. This is used when VTK_BINARY_DIR is defined, allowing examples to be run and tested via CTest. ```cmake cmake_minimum_required(VERSION 3.12...3.16 FATAL_ERROR) project(VTKExamples) if (VTK_BINARY_DIR) function (add_example dir) if (vtk_cmake_build_dir) add_test( NAME "VTKExample-${dir}" COMMAND "${CMAKE_COMMAND}" "-Dconfig=$" "-Dgenerator=${CMAKE_GENERATOR}" "-Dsource=${CMAKE_CURRENT_SOURCE_DIR}" "-Dbinary=${CMAKE_CURRENT_BINARY_DIR}" "-Dexample_dir=${dir}" "-Dbuild_type=${CMAKE_BUILD_TYPE}" "-Dshared=${BUILD_SHARED_LIBS}" "-Dvtk_dir=${vtk_cmake_build_dir}" "-Dctest=${CMAKE_CTEST_COMMAND}" "-Dplatform=${CMAKE_GENERATOR_PLATFORM}" "-Dtoolset=${CMAKE_GENERATOR_TOOLSET}" "-Dvtk_binary_dir=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" -P "${CMAKE_CURRENT_LIST_DIR}/RunExample.cmake") set_property(TEST "VTKExample-${dir}" APPEND PROPERTY SKIP_REGULAR_EXPRESSION "Skipping example") endif () endfunction () else () macro (add_example dir) add_subdirectory("${dir}") endmacro () endif () ``` -------------------------------- ### Configure and Build VTK for Wheel Creation Source: https://github.com/kitware/vtk/blob/master/Documentation/docs/advanced/build_python_wheels.md Use these CMake, Ninja, and Python commands to configure VTK for wheel building, build the project, and then create the wheel. ```sh cmake -GNinja -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON path/to/vtk/source ninja python3 setup.py bdist_wheel ``` -------------------------------- ### Install XDMF Headers and Libraries Source: https://github.com/kitware/vtk/blob/master/ThirdParty/xdmf3/vtkxdmf3/CMakeLists.txt Installs XDMF header files and targets. This block is commented out, suggesting that VTK's module system handles installation. ```cmake if (FALSE) # XXX(kitware): VTK's module system handles installation file(GLOB XdmfHeaders "*.hpp" "*.tpp" "*.i" "${CMAKE_CURRENT_BINARY_DIR}/*.hpp" ) install(FILES ${XdmfHeaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(TARGETS ${XDMF_LIBNAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif () ``` -------------------------------- ### Install Viskores CMake Helper Files Source: https://github.com/kitware/vtk/blob/master/ThirdParty/viskores/vtkviskores/viskores/CMakeLists.txt Installs various CMake helper files from the Viskores source directory to the installation's CMake module directory. ```cmake install( FILES ${Viskores_SOURCE_DIR}/CMake/ViskoresCPUVectorization.cmake ${Viskores_SOURCE_DIR}/CMake/ViskoresDetectCUDAVersion.cu ${Viskores_SOURCE_DIR}/CMake/ViskoresDeviceAdapters.cmake ${Viskores_SOURCE_DIR}/CMake/ViskoresDIYUtils.cmake ${Viskores_SOURCE_DIR}/CMake/ViskoresExportHeaderTemplate.h.in ${Viskores_SOURCE_DIR}/CMake/ViskoresRenderingContexts.cmake ${Viskores_SOURCE_DIR}/CMake/ViskoresWrappers.cmake DESTINATION ${Viskores_INSTALL_CMAKE_MODULE_DIR} ) ``` -------------------------------- ### VTK Installation Directories Source: https://github.com/kitware/vtk/blob/master/Documentation/dev/build_windows_vs.md After successful installation, VTK typically creates these directories. The 'bin' folder contains necessary DLL files. ```cmd c:\program file\VTK\bin c:\program file\VTK\include c:\program file\VTK\lib c:\program file\VTK\share ```