-
Notifications
You must be signed in to change notification settings - Fork 1
/
FindNETCDF.cmake
27 lines (22 loc) · 1.08 KB
/
FindNETCDF.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if(NETCDF_INCLUDE_DIR AND NETCDF_LIBRARY)
set(NETCDF_FIND_QUIETLY TRUE)
endif()
find_path(NETCDF_INCLUDE_DIR NAMES netcdf.h)
find_library(NETCDF_LIBRARY NAMES netcdf)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NETCDF DEFAULT_MSG NETCDF_INCLUDE_DIR NETCDF_LIBRARY)
mark_as_advanced(NETCDF_INCLUDE_DIR NETCDF_LIBRARY)
set(NETCDF_LIBRARIES ${NETCDF_LIBRARY})
set(NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR})
if(NETCDF_FOUND AND NOT TARGET netcdf)
add_library(netcdf UNKNOWN IMPORTED)
set_target_properties(netcdf PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_INCLUDE_DIRS}")
set_target_properties(netcdf PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C")
set_target_properties(netcdf PROPERTIES IMPORTED_LOCATION "${NETCDF_LIBRARIES}")
get_filename_component(NETCDF_LIBRARIES_EXT "${NETCDF_LIBRARIES}" EXT)
if("${NETCDF_LIBRARIES_EXT}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(HDF5_USE_STATIC_LIBRARIES ON)
endif()
find_package(HDF5 REQUIRED)
set_target_properties(netcdf PROPERTIES INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}")
endif()