tFindPNetCDF.cmake - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tFindPNetCDF.cmake (1667B)
       ---
            1 # - Find PNetCDF
            2 # Find the native PNetCDF includes and library
            3 #
            4 #  PNETCDF_INCLUDES    - where to find netcdf.h, etc
            5 #  PNETCDF_LIBRARIES   - Link these libraries when using NetCDF
            6 #  PNETCDF_FOUND       - True if PNetCDF was found
            7 #
            8 # Normal usage would be:
            9 #  find_package (PNetCDF REQUIRED)
           10 #  target_link_libraries (uses_pnetcdf ${PNETCDF_LIBRARIES})
           11 
           12 if (PNETCDF_INCLUDES AND PNETCDF_LIBRARIES)
           13   # Already in cache, be silent
           14   set (PNETCDF_FIND_QUIETLY TRUE)
           15 endif (PNETCDF_INCLUDES AND PNETCDF_LIBRARIES)
           16 
           17 find_path (PNETCDF_INCLUDES pnetcdf.h
           18   HINTS "${PNETCDF_ROOT}/include" "$ENV{PNETCDF_ROOT}/include")
           19 
           20 string(REGEX REPLACE "/include/?$" "/lib"
           21   PNETCDF_LIB_HINT ${PNETCDF_INCLUDES})
           22 
           23 find_library (PNETCDF_LIBRARIES
           24   NAMES pnetcdf
           25   HINTS ${PNETCDF_LIB_HINT})
           26 
           27 if ((NOT PNETCDF_LIBRARIES) OR (NOT PNETCDF_INCLUDES))
           28   message(STATUS "Trying to find PNetCDF using LD_LIBRARY_PATH (we're desperate)...")
           29 
           30   file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" LD_LIBRARY_PATH)
           31 
           32   find_library(PNETCDF_LIBRARIES
           33     NAMES pnetcdf
           34     HINTS ${LD_LIBRARY_PATH})
           35 
           36   if (PNETCDF_LIBRARIES)
           37     get_filename_component(PNETCDF_LIB_DIR ${PNETCDF_LIBRARIES} PATH)
           38     string(REGEX REPLACE "/lib/?$" "/include"
           39       PNETCDF_H_HINT ${PNETCDF_LIB_DIR})
           40 
           41     find_path (PNETCDF_INCLUDES pnetcdf.h
           42       HINTS ${PNETCDF_H_HINT}
           43       DOC "Path to pnetcdf.h")
           44   endif()
           45 endif()
           46 
           47 # handle the QUIETLY and REQUIRED arguments and set PNETCDF_FOUND to TRUE if
           48 # all listed variables are TRUE
           49 include (FindPackageHandleStandardArgs)
           50 find_package_handle_standard_args (PNetCDF DEFAULT_MSG PNETCDF_LIBRARIES PNETCDF_INCLUDES)
           51 
           52 mark_as_advanced (PNETCDF_LIBRARIES PNETCDF_INCLUDES)