FindNetCDF.cmake: fix target

This commit is contained in:
Christoph Junghans
2020-03-24 14:29:14 -06:00
parent 99d4a226b5
commit 5eb77f2e9a

View File

@ -112,6 +112,8 @@ NetCDF_check_interface (F90 netcdf.mod netcdff)
#export accumulated results to internal varS that rest of project can depend on #export accumulated results to internal varS that rest of project can depend on
list (APPEND NetCDF_libs "${NETCDF_C_LIBRARIES}") list (APPEND NetCDF_libs "${NETCDF_C_LIBRARIES}")
set (NETCDF_LIBRARIES ${NetCDF_libs})
set (NETCDF_INCLUDE_DIRS ${NetCDF_includes})
# handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
@ -121,14 +123,11 @@ find_package_handle_standard_args (NetCDF
# Copy the results to the output variables and target. # Copy the results to the output variables and target.
if(NetCDF_FOUND) if(NetCDF_FOUND)
set (NETCDF_LIBRARIES ${NetCDF_libs})
set (NETCDF_INCLUDE_DIRS ${NetCDF_includes})
if(NOT TARGET NetCDF::NetCDF) if(NOT TARGET NetCDF::NetCDF)
add_library(NetCDF::NetCDF UNKNOWN IMPORTED) add_library(NetCDF::NetCDF UNKNOWN IMPORTED)
set_target_properties(NetCDF::NetCDF PROPERTIES set_target_properties(NetCDF::NetCDF PROPERTIES
IMPORTED_LOCATION "${NETCDF_LIBRARY}" IMPORTED_LOCATION "${NETCDF_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_includes}" INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${NETCDF_LIBRARIES}") INTERFACE_LINK_LIBRARIES "${NETCDF_LIBRARIES}")
endif() endif()
endif() endif()