netcdf-c/liblib/CMakeLists.txt
Ward Fisher b4e198d163 Added '--enable-dynamic-loading' to autotools-based builds, and
-DENABLE_DYNAMIC_LOADING to cmake-based builds.

This will allow for compatibility with hdf5 1.8.11 builds that
have enabled dynamic building (depends on libdl).

See Jira ticket NCF-258
2013-06-10 21:48:11 +00:00

94 lines
2.1 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(HAVE_LIBDL)
SET(TLL_LIBS ${LIBDL} ${TLL_LIBS})
ENDIF()
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_SO_VERSION})
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)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")