How to use the 'install' folder after a VTK build

Hello,
We are trying to setup our applications, that uses VTK (9.1), to be automatically built by our build system, Gitlab. Before that, however, we are trying to build manually.

When building the ‘install’ target of VTK, all binaries and headers, etc, are copied to our Build folder.

Applications that are to use VTK, subsequently, are using CMake. However, when only the the ‘install’ folder of VTK is present, we have problems with apps finding VTK headers and libraries properly.

We basically want a binary VTK build package that we can just copy into our build folder, and from there build our ‘on top of VTK’ apps. If that is possible?

The CMake file for one of our apps (actually a library), that are using VTK, looks (snippet) like this:

...
...
 #===== Shared library
add_library(${target} SHARED
        ${src}
        ${HDRS}
)

#Find boost
find_package(Boost ${BOOST_VERSION} EXACT COMPONENTS system filesystem REQUIRED)

find_package(VTK 9.1)
message("VTK_FOUND: ${VTK_FOUND}")
message("VTK_INCLUDE_DIRS: ${VTK_INCLUDE_DIRS}")
message("VTK_LIBRARIES: ${VTK_LIBRARIES}")

#
#vtk_module_autoinit(
#   TARGETS arbFoundation
#  MODULES ${VTK_LIBRARIES}
#)

find_package(Poco REQUIRED COMPONENTS Foundation Data JSON DataSQLite)

target_include_directories (${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS})
    
target_compile_definitions(${target} PRIVATE 
    EXPORT_ARBORETA_FOUNDATION
    EXPORT_ARBORETA_COMMON
    EXPORT_ARBORETA_MATH 
    EXPORT_ARBORETA_GRAPHICS
    EXPORT_ARBORETA_VOLUMEMANAGER
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    message(STATUS "Setting up BOOST")
    message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
    message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
endif()  


target_link_libraries(
    ${target} 
    ${VTK_LIBRARIES}
    Poco::Foundation debug
    Poco::Data
    Poco::DataSQLite
    Poco::JSON
    ${boost_FILESYSTEM_LIBRARY}
    ${boost_SYSTEM_LIBRARY}
 )

When setting VTK_DIR to /our_build_folder/lib/cmake/vtk-9.1 , then when configuring the above CMake file, we get errors:

CMake Error at X:/arboreta_auto_build/lib/cmake/vtk-9.1/vtk-config.cmake:138 (include):
  include could not find requested file:

    X:/arboreta_auto_build/lib/cmake/vtk-9.1/VTK-targets.cmake
Call Stack (most recent call first):
  foundation/CMakeLists.txt:163 (find_package)


CMake Error at X:/arboreta_auto_build/lib/cmake/vtk-9.1/vtk-config.cmake:139 (include):
  include could not find requested file:

    X:/arboreta_auto_build/lib/cmake/vtk-9.1/VTK-vtk-module-properties.cmake
Call Stack (most recent call first):
  foundation/CMakeLists.txt:163 (find_package)

...

And they message statements above gives:

VTK_FOUND: 1
VTK_INCLUDE_DIRS: 
VTK_LIBRARIES:

Any hints on what we might be missing?

I’m doing exactly that for my app and it is working flawlessly.

Perhaps not exactly, because if so, you would see the same errors that I see :slight_smile:

The errors seem to come from the find_package(VTK 9.1), and it seem to be looking for

X:/arboreta_auto_build/lib/cmake/vtk-9.1/VTK-targets.cmake

and

X:/arboreta_auto_build/lib/cmake/vtk-9.1/VTK-vtk-module-properties.cmake

and neither are found in the install folder.

They are present, however, in the cmake folder where we create the solution file:

Just seems it is not being “installed”. I guess something is not proper with the VTK build in the first place.

Hello,

Here’s some sanity checks:

  1. Build and Install folders must be different, otherwise a great confusion may ensue.
  2. You install VTK’s SDK (headers, link time libraries, runtime libraries, CMake find scripts, etc.) by running, for example, make install (for gcc toolchain) in the build directory.
  3. If your client software is also configured with CMake, configure it to find VTK’s CMake files that resides in the <VTK install folder>\lib\cmake\vtk-9.1 path.

Here’s how my source, build (debug and release) and install (debug and release) folders are organized:
image

So, when I configure software that uses VTK, I set, for example, VTK_DIR (actual CMake variable may change) in my program’s CMake configuration to the D:\vtk-9.1.0-install_release\lib\cmake\vtk-9.1 path.

take care,

Paulo

2 Likes

Thanks Paulo,
I believe I had a bad VTK build in the first place. After making a new build, everything worked fine.

Your answer helped me configure my client CMake, however, so that finding vtk now happens automatically for client software.

Cheers!

1 Like