Skip to content

Commit b57b512

Browse files
committed
findNetCDF: don't fail if only netcdf-c available, just don't find
1 parent b9948da commit b57b512

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

cmake/Modules/FindNetCDF.cmake

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,6 @@ if(netCDF_FOUND)
141141
set(NetCDF_C_INCLUDE_DIR "${netCDF_INCLUDE_DIR}")
142142
set(NetCDF_C_LIBRARY "${netCDF_LIBRARIES}")
143143
set(NetCDF_VERSION "${NetCDFVersion}")
144-
145-
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED)
146-
if (TARGET "netCDF::netcdf")
147-
# 4.7.3
148-
set_target_properties(NetCDF::NetCDF_C PROPERTIES
149-
INTERFACE_LINK_LIBRARIES "netCDF::netcdf")
150-
elseif (TARGET "netcdf")
151-
set_target_properties(NetCDF::NetCDF_C PROPERTIES
152-
INTERFACE_LINK_LIBRARIES "netcdf")
153-
else()
154-
set_target_properties(NetCDF::NetCDF_C PROPERTIES
155-
INTERFACE_LINK_LIBRARIES "${netCDF_LIBRARIES}")
156-
endif()
157-
set_target_properties(NetCDF::NetCDF_C PROPERTIES
158-
INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_C_INCLUDE_DIR}")
159144
endif(netCDF_FOUND)
160145

161146
# 2. manual search for Fortran (and C if needed) using optional pkg-config
@@ -199,7 +184,17 @@ if(NetCDF_FOUND)
199184
if(NOT TARGET NetCDF::NetCDF_C)
200185
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED)
201186
set_target_properties(NetCDF::NetCDF_C PROPERTIES
202-
INTERFACE_LINK_LIBRARIES "${NetCDF_C_LIBRARY}"
203187
INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_C_INCLUDE_DIR}")
188+
if (TARGET "netCDF::netcdf")
189+
# 4.7.3
190+
set_target_properties(NetCDF::NetCDF_C PROPERTIES
191+
INTERFACE_LINK_LIBRARIES "netCDF::netcdf")
192+
elseif (TARGET "netcdf")
193+
set_target_properties(NetCDF::NetCDF_C PROPERTIES
194+
INTERFACE_LINK_LIBRARIES "netcdf")
195+
else()
196+
set_target_properties(NetCDF::NetCDF_C PROPERTIES
197+
INTERFACE_LINK_LIBRARIES "${NetCDF_C_LIBRARY}")
198+
endif()
204199
endif()
205200
endif()

0 commit comments

Comments
 (0)