I am trying to change my build system to use CMake’s FetchContent(...) method. I specify the git repository and a git tag.
When I start compiling I get the following:
D:\temp\buildme2\vtk-fss_deps\vtkrepo-src\Common\Core../DataModel/vtkDataObject.h(37): fatal error C1083: Cannot open include file: ‘vtkCommonDataModelModule.h’: No such file or directory
The build works fine when I use git submodule with the same git tag.
I assume I am missing a CMake variable which will generate vtkCommonDataModelModule.h during the configuration process. Any ideas which variable that could be?
Good spotting on the missing /. However this may be a separate issue; I get the same error under linux and there it is not missing any forward slashes:
In file included from /home/peter/source/build-volsung-dependencies-Qt_5_15_2_GCC_64bit-Debug/vtk-fss/_deps/vtkrepo-src/Common/Core/vtkInformationDataObjectKey.cxx:18:
/home/peter/source/build-volsung-dependencies-Qt_5_15_2_GCC_64bit-Debug/vtk-fss/_deps/vtkrepo-src/Common/Core/…/DataModel/vtkDataObject.h:37:10: fatal error: vtkCommonDataModelModule.h: No such file or directory
Also after getting this error I explicitly set the CMake variable to force building of vtkCommonDataModule but it made no difference:
Further checks: The file vtkCommonDataModelModule.h exists, but it can’t be found when building vtkInformationDataObjectKey.cxx. It is referenced via an include:
#include “vtkCommonDataModelModule.h” // For export macro
So it looks like the file is generated correctly, but the Common/Core module has not set the list of include directories for its dependencies correctly?
This is controlled by the CMakeLists.txt file for Common/Core:
# We can't check for the target since we're before VTK::CommonDataModel in the
# dependency graph.
if (VTK_MODULE_ENABLE_VTK_CommonDataModel)
list(APPEND vtk_include_dirs
"${CMAKE_CURRENT_BINARY_DIR}/../DataModel")
set_property(SOURCE vtkInformationDataObjectKey.cxx
PROPERTY
COMPILE_DEFINITIONS vtkCommonDataModel_ENABLED)
endif ()
The filename is defined in <vtk-source>/CMake/vtkModule.cmake:
set(_vtk_add_module_module_header_name
"${_vtk_add_module_library_name}Module.h")
if (NOT _vtk_add_module_HEADER_ONLY AND NOT _vtk_add_module_third_party)
set(_vtk_add_module_generated_header
"${CMAKE_CURRENT_BINARY_DIR}/${_vtk_add_module_module_header_name}")
list(APPEND _vtk_add_module_HEADERS
"${_vtk_add_module_generated_header}")
endif ()
The header name is correct, and ${CMAKE_CURRENT_BINARY_DIR} points to vtkCommonDataModel at this point (tested via printing it out).
Why? How are you building VTK that this gets messed up? I’ll note that VTK is not meant to be built by add_subdirectory. If you want to vendor it, vendor it like ParaView does (see its CMakeLists.txt for the nitty-gritty details).
I have a complicated chain of dependencies for my project, and I want to be able to build them automatically all in one go, one after the other. Therefore I am setting them all up as independent CMakeProjects, where each project contains a CMakeLists.txt which defines how the project will be built.
If you have a better idea on how to automate this step, i.e. building it from scratch from a particular git tag and being able to modify CMake variables please let me know.
It wiki needs a deep clean of old crufy information. The build docs now live in the repo. Vendoring is not something that is 100% supported explicitly or in any stable way (global variables expected to exist or files to include change without much notification). ParaView does it because when we bump VTK we keep it in sync. Note that VTK also does not care about the binary directory you give it; it uses ${CMAKE_BINARY_DIR} for artifacts without a way to override it.
The only road to the supported way is vtk_module_scan and vtk_module_build VTK’s modules yourself.