CMake Compile Issue ...

Dear All, @ben.boeckel
I have a little CMake problem that I could not solve so far. I have C Code in my plugin, and need to pass the location of two external header files to it. They are both located in the same directory. The path ${ECCODES_INCLUDE_DIRS} is correct, but passing this to the C code (cdilib.c) does not work. An object file for the C++ code is created however. I tried several variations and googled a bit, but I haven’t solved it yet. Below is the CMakeLists.txt, any help is appreciated:

Thanks and Cheers, Niklas

set(classes
vtkCDIReader)

set(sources
cdilib.c
HEADERS ${ECCODES_INCLUDE_DIRS})

set(private_headers
cdi.h)

set(CMAKE_C_STANDARD 99)
vtk_module_add_module(CDIReader::vtkCDIReader
CLASSES ${classes}
SOURCES ${sources}
PRIVATE_HEADERS ${private_headers} ${ECCODES_INCLUDE_DIRS})

if (PARAVIEW_PLUGIN_BUILD_CDIReader_WITH_GRIB)
vtk_module_link(CDIReader::vtkCDIReader
PRIVATE
${ECCODES_LIBRARIES})
endif ()

vtk_module_definitions(CDIReader::vtkCDIReader
PRIVATE
# Please leave these definitions in here and do not change them.
# We use the cdi library to read both, netCDF2 and netCDF4 data,
# and if configured and available, also grib data (see below).
HAVE_LIBNETCDF
HAVE_NETCDF2
HAVE_NETCDF4)

if (PARAVIEW_PLUGIN_BUILD_CDIReader_WITH_GRIB)
vtk_module_definitions(CDIReader::vtkCDIReader
PRIVATE
HAVE_LIBGRIB_API)
endif ()

paraview_add_server_manager_xmls(
XMLS CDIReader.xml)

The HEADERS ${ECCODES_INCLUDE_DIRS} should be passed to a vtk_module_include command, not as an argument to vtk_module_add_module. It also shouldn’t be passed to PRIVATE_HEADERS.

Perfect. Thank you, that was it!
Cheers, Niklas