[CMake] problem in finding netcdf library with cmake

Ufuk Turuncoglu ufuk.turuncoglu at itu.edu.tr
Thu Jul 19 05:03:01 EDT 2018


Hi,

First of all, i am new to cmake and i would like to use it in my current 
project. So, i need to use netcdf library in my project and i am using 
VTK's FindNetCDF.cmake for it. The content of my CMakeLists.txt file as 
follows,

cmake_minimum_required (VERSION 2.6)

# The project name
project (REGESM)

# The version number
set (REGESM_VERSION_MAJOR 2)
set (REGESM_VERSION_MINOR 0)

# Add bld/ directory to cmake module path
set(REGESM_CMAKE_DIR "${REGESM_SOURCE_DIR}/bld")
set(CMAKE_MODULE_PATH ${REGESM_CMAKE_DIR} ${CMAKE_MODULE_PATH})

# Use VTK's NetCDF interface
find_package (NetCDF COMPONENTS F90)
include_directories(${NETCDF_F90_INCLUDE_DIRS})

but when i run the cmake command, i am getting following error,

-- Failed to find NetCDF interface for F90
-- Could NOT find NetCDF (missing: NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS 
NETCDF_HAS_INTERFACES)
CMake Error: The following variables are used in this project, but they 
are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the 
CMake files:
NETCDF_F90_INCLUDE_DIR (ADVANCED)
    used as include directory in directory /RS/users/turuncu/DEV/RegESM2
    used as include directory in directory /RS/users/turuncu/DEV/RegESM2

in my case the netcdf library is installed and i could use it externally 
without any problem. i don't think but to be sure, is it necessary to 
install netcdf with special options to use it under cmake. i also define 
a set of environment variables but it could not help.

NETCDF_LIBRARY=/RS/progs/netcdf/4.4.0/intel/2017u5/lib
NETCDF_HOME=/RS/progs/netcdf/4.4.0/intel/2017u5
NETCDF_ROOT=/RS/progs/netcdf/4.4.0/intel/2017u5
NETCDF_INCLUDE_DIR=/RS/progs/netcdf/4.4.0/intel/2017u5/include
NETCDF4_ROOT=/RS/progs/netcdf/4.4.0/intel/2017u5
NETCDF=/RS/progs/netcdf/4.4.0/intel/2017u5

So, any suggestion will help to me at this point.

Best Regards,

--ufuk



More information about the CMake mailing list