diff --git a/CMakeLists.txt b/CMakeLists.txt index 59cdfbcd6..ebb69287b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.8) #Project Name -project(NetCDF C) +project(NetCDF C CXX) SET(NetCDF_VERSION 4.2.1) ENABLE_TESTING() INCLUDE(CTest) @@ -18,6 +18,13 @@ SET (CTEST_DROP_LOCATION "/submit.php?project=WinNETCDF" CACHE STRING "") SET (CTEST_DROP_SITE_CDASH TRUE CACHE BOOL "") SET (CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "") +# Set variable to define the build type. +INCLUDE(GenerateExportHeader) +SET (LIB_TYPE STATIC) +IF (BUILD_SHARED_LIBS) + SET(LIB_TYPE SHARED) +ENDIF() + ADD_DEFINITIONS() ### Verbose make, for debugging. @@ -490,6 +497,14 @@ IF(ENABLE_TESTS) ENDIF() +# Code to generate an export header +GENERATE_EXPORT_HEADER(netcdf + BASE_NAME netcdf + EXPORT_MACRO_NAME netcdf_EXPORT + EXPORT_FILE_NAME netcdf_Export.h + STATIC_DEFINE netcdf_BUILT_AS_STATIC +) + ##### # Build doxygen documentation, if need be. ##### diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt index 3a6da330e..5f2da5759 100644 --- a/liblib/CMakeLists.txt +++ b/liblib/CMakeLists.txt @@ -25,19 +25,16 @@ FOREACH(LIBS ${liblib_LIBS}) SET(LARGS ${LARGS} $) ENDFOREACH() -ADD_LIBRARY(netcdf stub.c ${LARGS} ) +ADD_LIBRARY(netcdf ${LIB_TYPE} stub.c ${LARGS} ) + ##### # Add dependencies required for linking. ##### SET(TLL_LIBS ${HAVE_LIBM} ${ZLIB_LIBRARY}) -#TARGET_LINK_LIBRARIES(netcdf ${HAVE_LIBM}) - -#TARGET_LINK_LIBRARIES(netcdf ${MMATH}) IF(USE_DAP) SET(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES}) -# TARGET_LINK_LIBRARIES(netcdf ${CURL_LIBRARIES}) ENDIF() IF(USE_HDF5 OR USE_NETCDF4) @@ -46,7 +43,6 @@ ENDIF() IF(ENABLE_PNETCDF AND PNETCDF) SET(TLL_LIBS ${TLL_LIBS} ${PNETCDF}) - #TARGET_LINK_LIBRARIES(netcdf ${PNETCDF}) ENDIF() TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})