Hi everybody and thanks to your help,
I'm newbie of CMAKE and I try to write a find library for C and Fortran NETCDF library. The problem is the possible different location and version of fortran and C netcdf.
For fortran library I search netcdf.mod(include module) and libnetcdff.so (dynamic library) instead for C library I search netcdf.h and libnetcdf.so.
On the web I find a magic code that find correctly the netcdf C library :
find_path (NETCDF_INCLUDES_C netcdf.h HINTS NETCDF_DIR NETCDF_DIR)
message(" inc = ${NETCDF_INCLUDES_C} ")
find_library (NETCDF_LIBRARIES_C NAMES netcdf)
message(" lib = ${NETCDF_LIBRARIES_C} ")
and the two path is correct. I try to reply the code for fortran:
find_path (NETCDFF_INCLUDES_F90 netcdff.mod HINTS NETCDFF_DIR NETCDFF_DIR)
message(" inc ff = ${NETCDFF_INCLUDES_F90} ")
find_library (NETCDFF_LIBRARIES_F90 NAMES netcdff HINTS NETCDFF_DIR )
message(" lib ff= ${NETCDFF_LIBRARIES_F90} ")
mark_as_advanced(NETCDF_LIBRARIES_F90)
but the both F90 path is empty, probably because I don't understand how cmake find the C library. Through MODULE ENVIRONMENT i load both library and the module load that env var:
$NETCDFF_HOME $NETCDFF_INC $NETCDFF_INCLUDE $NETCDFF_LIB
$NETCDF_HOME $NETCDF_INC $NETCDF_INCLUDE $NETCDF_LIB
I suppose incorrectly that CMAKE search NETCDF_DIR variable and into this search netcdf.h but in my CmakeList and in my ENV that variable is not defined.
How CMake find C var? and how I can reply the find to fortran lib?
Thanks to help me
Best regards
Eric
netcdff.modor did you wantnetcdf.mod? Also I don't really knowcmakebut if looks like you might be trying to store inNETCDFF_INCLUDES_F90but then your message uses${NETCDF_INCLUDES_F90}(i.e. there's an extra F in the first)