# CMake Compile Issue ...

**URL:** https://discourse.paraview.org/t/cmake-compile-issue/1634
**Category:** Development
**Created:** [April 9, 2019, 1:08pm UTC](https://discourse.paraview.org/t/cmake-compile-issue/1634 "2019-04-09T13:08:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Niklas](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Niklas](https://discourse.paraview.org/u/Niklas)
#### Post date: [April 9, 2019, 1:08pm UTC](https://discourse.paraview.org/t/cmake-compile-issue/1634/1 "2019-04-09T13:08:09Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [April 9, 2019, 3:31pm UTC](https://discourse.paraview.org/t/cmake-compile-issue/1634/2 "2019-04-09T15:31:26Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![Niklas](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@Niklas](https://discourse.paraview.org/u/Niklas)
#### Post date: [April 9, 2019, 4:48pm UTC](https://discourse.paraview.org/t/cmake-compile-issue/1634/3 "2019-04-09T16:48:55Z")

</div>

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