-
Oliver Heidmann authoredOliver Heidmann authored
CMakeLists.txt 2.41 KiB
cmake_minimum_required( VERSION 3.27 FATAL_ERROR )
message(VERBOSE "Entering libcdi")
project(cdilib VERSION 2.5.1 LANGUAGES C )
set(CMAKE_C_STANDARD 11)
include(CTest)
include(CheckIncludeFile)
# Finding libraries
### -------------- Pthread ---------------------------
option(CDI_PTHREAD "Use the pthread library [default=ON]" ON)
if(${CDI_PTHREAD})
include(FindThreads)
find_package(Threads REQUIRED)
set_target_properties(Threads::Threads PROPERTIES THREADS_PREFER_PTHREAD_FLAG TRUE)
list(APPEND cdi_compile_defs HAVE_PTHREAD=1)
endif()
# enable default internal libs
option(CDI_LIBGRIB "GRIB support [default=ON]" ON)
if(${CDI_LIBGRIB})
list(APPEND cdi_compile_defs HAVE_LIBGRIB=1)
endif()
option(CDI_LIBGRIBEX "Use the CGRIBEX library [default=ON]" ON)
if(${CDI_LIBGRIBEX})
list(APPEND cdi_compile_defs LIBCGRIBEX=1)
endif()
option(CDI_EXTRA "Use the extra library [default=ON]" ON)
if(${CDI_EXTRA})
list(APPEND cdi_compile_defs HAVE_LIBEXTRA=1)
endif()
option(CDI_IEG "Use the extra library [default=ON]" ON)
if(${CDI_IEG})
list(APPEND cdi_compile_defs HAVE_LIBIEG=1)
endif()
option(CDI_SERVICE "Use the extra library [default=ON]" ON)
if(${CDI_SERVICE})
list(APPEND cdi_compile_defs HAVE_LIBSERVICE=1)
endif()
# ecCodes
option(CDI_ECCODES "Use the eccodes library [default=ON]" ON)
if(${CDI_ECCODES} OR eccodes_ROOT)
find_package(eccodes)
if (${eccodes_FOUND})
list(APPEND cdi_compile_defs HAVE_LIBGRIB_API=${eccodes_FOUND})
message(VERBOSE "added compile definition HAVE_LIBGRIB_API=${eccodes_FOUND}")
else()
message(WARNING "eccodes not found, compiling without eccodes")
endif ()
endif()
# NetCDF
option(CDI_NETCDF "Use the netcdf library [default=ON]" ON)
if(${CDI_NETCDF} OR netCDF_ROOT )
find_package(netCDF COMPONENTS C REQUIRED)
if (TARGET netCDF::netcdf)
list(APPEND cdi_compile_defs
HAVE_LIBNETCDF=${netCDF_FOUND}
HAVE_LIBNC_DAP=${netCDF_FOUND}
HAVE_NETCDF4=${netCDF_FOUND}
HAVE_LIBGRIB_API=${netCDF_FOUND}
HAVE_LIBGRIB=${netCDF_FOUND}
)
else()
message(WARNING "netcdf target not found, compiling without netcdf")
endif ()
endif()
message(VERBOSE "looking for config.h in: ${PROJECT_BINARY_DIR}/src")
#adding subdirectories
## lib and general files
list(APPEND cdi_compile_defs CDI=1 CDI_SIZE_TYPE=size_t PACKAGE_NAME="${PROJECT_NAME}" VERSION="${CMAKE_PROJECT_VERSION}")
add_subdirectory(src)
#tests
add_subdirectory(app)
add_subdirectory(tests)