Skip to content
Snippets Groups Projects
Commit 0e8861e0 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

removed usage of lists and replaced it by target specific cmake routines

parent 4c2a5cd9
No related branches found
No related tags found
1 merge request!145M300433/cmake improvements and cleanup 2
...@@ -19,36 +19,34 @@ if(${CDI_PTHREAD}) ...@@ -19,36 +19,34 @@ if(${CDI_PTHREAD})
include(FindThreads) include(FindThreads)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
set_target_properties(Threads::Threads PROPERTIES THREADS_PREFER_PTHREAD_FLAG TRUE) set_target_properties(Threads::Threads PROPERTIES THREADS_PREFER_PTHREAD_FLAG TRUE)
list(APPEND cdi_compile_defs HAVE_PTHREAD=1) target_compile_definitions(cdilib PRIVATE HAVE_PTHREAD=1)
list(APPEND cdi_linked_libs pthread) target_link_libraries(cdilib pthread)
endif() endif()
# enable default internal libs # enable default internal libs
option(CDI_LIBGRIB "GRIB support [default=ON]" ON) option(CDI_LIBGRIB "GRIB support [default=ON]" ON)
if(${CDI_LIBGRIB}) if(${CDI_LIBGRIB})
list(APPEND cdi_compile_defs target_compile_definitions(cdilib PRIVATE HAVE_LIBGRIB=1 HAVE_LIBGRIB_API=1)
HAVE_LIBGRIB=1
HAVE_LIBGRIB_API=1)
endif() endif()
option(CDI_LIBGRIBEX "Use the CGRIBEX library [default=ON]" ON) option(CDI_LIBGRIBEX "Use the CGRIBEX library [default=ON]" ON)
if(${CDI_LIBGRIBEX}) if(${CDI_LIBGRIBEX})
list(APPEND cdi_compile_defs LIBCGRIBEX=1) target_compile_definitions(cdilib PRIVATE LIBCGRIBEX=1)
endif() endif()
option(CDI_EXTRA "Use the extra library [default=ON]" ON) option(CDI_EXTRA "Use the extra library [default=ON]" ON)
if(${CDI_EXTRA}) if(${CDI_EXTRA})
list(APPEND cdi_compile_defs HAVE_LIBEXTRA=1) target_compile_definitions(cdilib PRIVATE HAVE_LIBEXTRA=1)
endif() endif()
option(CDI_IEG "Use the extra library [default=ON]" ON) option(CDI_IEG "Use the extra library [default=ON]" ON)
if(${CDI_IEG}) if(${CDI_IEG})
list(APPEND cdi_compile_defs HAVE_LIBIEG=1) target_compile_definitions(cdilib PRIVATE HAVE_LIBIEG=1)
endif() endif()
option(CDI_SERVICE "Use the extra library [default=ON]" ON) option(CDI_SERVICE "Use the extra library [default=ON]" ON)
if(${CDI_SERVICE}) if(${CDI_SERVICE})
list(APPEND cdi_compile_defs HAVE_LIBSERVICE=1) target_compile_definitions(cdilib PRIVATE HAVE_LIBSERVICE=1)
endif() endif()
# ecCodes # ecCodes
...@@ -56,7 +54,9 @@ option(CDI_ECCODES "Use the eccodes library [default=ON]" ON) ...@@ -56,7 +54,9 @@ option(CDI_ECCODES "Use the eccodes library [default=ON]" ON)
if(${CDI_ECCODES} OR eccodes_ROOT) if(${CDI_ECCODES} OR eccodes_ROOT)
find_package(eccodes REQUIRED) find_package(eccodes REQUIRED)
if (${eccodes_FOUND}) if (${eccodes_FOUND})
list(APPEND cdi_linked_libs eccodes) target_compile_definitions(cdilib PRIVATE HAVE_LIBGRIB_API=${eccodes_FOUND})
message(VERBOSE "added compile definition HAVE_LIBGRIB_API=${eccodes_FOUND}")
target_link_libraries(cdilib eccodes)
endif () endif ()
endif() endif()
...@@ -70,7 +70,7 @@ if(${CDI_NETCDF} OR netCDF_ROOT ) ...@@ -70,7 +70,7 @@ if(${CDI_NETCDF} OR netCDF_ROOT )
HAVE_LIBNC_DAP=${netCDF_FOUND} HAVE_LIBNC_DAP=${netCDF_FOUND}
HAVE_NETCDF4=${netCDF_FOUND} HAVE_NETCDF4=${netCDF_FOUND}
) )
list(APPEND cdi_linked_libs netCDF::netcdf) target_link_libraries(cdilib netCDF::netcdf)
endif () endif ()
endif() endif()
...@@ -78,7 +78,7 @@ message(VERBOSE "looking for config.h in: ${PROJECT_BINARY_DIR}/src") ...@@ -78,7 +78,7 @@ message(VERBOSE "looking for config.h in: ${PROJECT_BINARY_DIR}/src")
#adding subdirectories #adding subdirectories
## lib and general files ## lib and general files
list(APPEND cdi_compile_defs CDI=1 CDI_SIZE_TYPE=size_t PACKAGE_NAME="${PROJECT_NAME}" VERSION="${CMAKE_PROJECT_VERSION}") target_compile_definitions(cdilib PRIVATE CDI=1 CDI_SIZE_TYPE=size_t PACKAGE_NAME="${PROJECT_NAME}" VERSION="${CMAKE_PROJECT_VERSION}")
add_subdirectory(src) add_subdirectory(src)
#app #app
......
list( APPEND cdi_src_files
target_sources(cdilib PRIVATE
async_worker.c async_worker.c
async_worker.h async_worker.h
basetime.c basetime.c
...@@ -139,69 +140,78 @@ list( APPEND cdi_src_files ...@@ -139,69 +140,78 @@ list( APPEND cdi_src_files
zaxis.c zaxis.c
zaxis.h zaxis.h
) )
list( APPEND cdi_pio_files
cdipio.h
pio.c
pio.h
pio_cdf_int.c
pio_cdf_int.h
pio_client.c
pio_client.h
pio_comm.c
pio_comm.h
pio_conf.c
pio_conf.h
pio_dbuffer.c
pio_dbuffer.h
pio_dist_grid.c
pio_dist_grid.h
pio_id_set.h
pio_idxlist_cache.c
pio_idxlist_cache.h
pio_impl.h
pio_interface.c
pio_interface.h
pio_mpi_fw_at_all.c
pio_mpi_fw_at_reblock.c
pio_mpi_fw_ordered.c
pio_mpinonb.c
pio_posixasynch.c
pio_posixfpguardsendrecv.c
pio_posixnonb.c
pio_record_send.c
pio_roles.c
pio_rpc.c
pio_rpc.h
pio_serialize.c
pio_serialize.h
pio_server.c
pio_server.h
pio_util.c
pio_util.h
pio_xmap_cache.c
pio_xmap_cache.h
)
list( APPEND cdi_unknown option(CDI_BUILD_PIO "Build unknown sources in libcdi" OFF)
cfortran.h mark_as_advanced(CDI_BUILD_PIO)
getline.c if (CDI_BUILD_PIO)
make_fint.c target_sources(cdilib PRIVATE
resource_unpack.c cdipio.h
resource_unpack.h pio.c
) pio.h
pio_cdf_int.c
pio_cdf_int.h
pio_client.c
pio_client.h
pio_comm.c
pio_comm.h
pio_conf.c
pio_conf.h
pio_dbuffer.c
pio_dbuffer.h
pio_dist_grid.c
pio_dist_grid.h
pio_id_set.h
pio_idxlist_cache.c
pio_idxlist_cache.h
pio_impl.h
pio_interface.c
pio_interface.h
pio_mpi_fw_at_all.c
pio_mpi_fw_at_reblock.c
pio_mpi_fw_ordered.c
pio_mpinonb.c
pio_posixasynch.c
pio_posixfpguardsendrecv.c
pio_posixnonb.c
pio_record_send.c
pio_roles.c
pio_rpc.c
pio_rpc.h
pio_serialize.c
pio_serialize.h
pio_server.c
pio_server.h
pio_util.c
pio_util.h
pio_xmap_cache.c
pio_xmap_cache.h
)
endif()
option(CDI_BUILD_UNKNOWN "Build unknown sources in libcdi" ON) option(CDI_BUILD_UNKNOWN "Build unknown sources in libcdi" ON)
mark_as_advanced(CDI_BUILD_UNKNOWN) mark_as_advanced(CDI_BUILD_UNKNOWN)
if (CDI_BUILD_UNKNOWN) if (CDI_BUILD_UNKNOWN)
list(APPEND cdi_src_files ${cdi_unknown}) target_sources( cdilib PRIVATE
cfortran.h
getline.c
make_fint.c
resource_unpack.c
resource_unpack.h
)
endif () endif ()
# Support exporting all symbolds on Windows # Support exporting all symbols on Windows
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set_property(TARGET cdilib PROPERTY CDI_INSTALL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/cdi.h
${CMAKE_CURRENT_SOURCE_DIR}/calendar.h
${CMAKE_CURRENT_SOURCE_DIR}/cdi_datetime.h
${CMAKE_CURRENT_SOURCE_DIR}/julian_date.h
) )
target_include_directories(cdilib PRIVATE "${PROJECT_BINARY_DIR}/src/config.h") target_include_directories(cdilib PRIVATE "${PROJECT_BINARY_DIR}/src/config.h")
target_link_libraries(cdilib ${cdi_linked_libs}) target_link_libraries(cdilib ${cdi_linked_libs})
target_compile_definitions(cdilib PRIVATE PACKAGE_NAME="${PROJECT_NAME}" VERSION="${CMAKE_PROJECT_VERSION}" ${cdi_compile_defs}) target_compile_definitions(cdilib PRIVATE PACKAGE_NAME="${PROJECT_NAME}" VERSION="${CMAKE_PROJECT_VERSION}" ${cdi_compile_defs})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment