Skip to content
Snippets Groups Projects

M300433/cmake improvements and define cleanups

Merged Oliver Heidmann requested to merge m300433/cmake_improvements_and_define_cleanups into develop
4 unresolved threads
+ 61
28
cmake_minimum_required( VERSION 3.30 FATAL_ERROR )
cmake_minimum_required( VERSION 3.27 FATAL_ERROR )
message(VERBOSE "Entering libcdi")
project(cdilib VERSION 2.5.1 LANGUAGES C )
@@ -8,39 +8,72 @@ include(CTest)
include(CheckIncludeFile)
# Finding libraries
### -------------- Pthread ---------------------------
option(enable_pthread "Use the pthread library [default=ON]" ON)
if(${enable_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
list(APPEND cdi_compile_defs
HAVE_LIBGRIB=1
HAVE_LIBCGRIBEX=1
HAVE_LIBEXTRA=1
HAVE_LIBSERVICE=1
HAVE_LIBIEG=1
)
option(enable_libgrib "GRIB support [default=ON]" ON)
if(${enable_libgrib})
list(APPEND cdi_compile_defs HAVE_LIBGRIB=1)
endif()
option(enable_cgribex "Use the CGRIBEX library [default=ON]" ON)
if(${enable_cgribex})
list(APPEND cdi_compile_defs LIBCGRIBEX=1)
endif()
option(enable_extra "Use the extra library [default=ON]" ON)
if(${enable_extra})
list(APPEND cdi_compile_defs HAVE_LIBEXTRA=1)
endif()
option(enable_ieg "Use the extra library [default=ON]" ON)
if(${enable_ieg})
list(APPEND cdi_compile_defs HAVE_LIBIEG=1)
endif()
option(enable_service "Use the extra library [default=ON]" ON)
if(${enable_service})
list(APPEND cdi_compile_defs HAVE_LIBSERVICE=1)
endif()
# ecCodes
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 ()
option(enable_eccodes "Use the eccodes library [default=ON]" ON)
if(${enable_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
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}
)
message(VERBOSE "added to list of definitions: ${cdi_compile_defs} ")
else()
message(WARNING "netcdf not found, compiling without netcdf")
endif ()
option(enable_netcdf "Use the netcdf library [default=ON]" ON)
if(${enable_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")
Loading