netcdf-c/liblib/CMakeLists.txt
2013-03-15 20:31:07 +00:00

87 lines
1.9 KiB
CMake

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES(".")
SET(liblib_LIBS dispatch netcdf3)
#####
# Add target objects/modules based on options.
#####
IF(USE_HDF5 OR USE_NETCDF4)
SET(liblib_LIBS ${liblib_LIBS} netcdf4)
ENDIF()
IF(USE_PNETCDF)
SET(liblib_LIBS ${liblib_LIBS} netcdf5)
ENDIF()
IF(USE_DAP)
SET(liblib_LIBS ${liblib_LIBS} oc2 dap2)
ENDIF()
IF(BUILD_CDMREMOTE)
SET(liblib_LIBS ${liblib_LIBS} cdmr)
ENDIF()
FOREACH(LIBS ${liblib_LIBS})
SET(LARGS ${LARGS} $<TARGET_OBJECTS:${LIBS}>)
ENDFOREACH()
ADD_LIBRARY(netcdf ${LIB_TYPE} stub.c ${LARGS} )
IF(MOD_NETCDF_NAME)
SET_TARGET_PROPERTIES(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
SET_TARGET_PROPERTIES(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
SET_TARGET_PROPERTIES(netcdf PROPERTIES RUNTIME_OUTPUT_NAME ${NETCDF_LIB_NAME})
ENDIF()
#####
# Add dependencies required for linking.
#####
SET(TLL_LIBS "")
SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
IF(USE_HDF5 OR USE_NETCDF4)
SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
ENDIF()
IF(USE_DAP)
SET(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
ENDIF()
IF(USE_HDF4)
SET(TLL_LIBS ${TLL_LIBS} ${HDF4_LIBRARIES})
ENDIF()
IF(ENABLE_PNETCDF AND PNETCDF)
SET(TLL_LIBS ${TLL_LIBS} ${PNETCDF})
ENDIF()
TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(netcdf PROPERTIES
LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
)
ENDIF()
IF(NOT MSVC)
IF(BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(netcdf PROPERTIES LINK_FLAGS -shared)
ENDIF()
ENDIF()
SET_TARGET_PROPERTIES(netcdf PROPERTIES
VERSION ${netCDF_VERSION}
SOVERSION ${netCDF_VERSION_MAJOR})
INSTALL(TARGETS netcdf EXPORT netcdf-targets RUNTIME DESTINATION bin COMPONENT libraries
LIBRARY DESTINATION lib COMPONENT libraries
ARCHIVE DESTINATION lib COMPONENT libraries
)
SET(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)