From eaa06560776d4bee2e687411e2274e6c025d8a65 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Wed, 19 Aug 2020 04:48:48 -0600 Subject: [PATCH] now building ncint directory with cmake --- src/clib/CMakeLists.txt | 4 ++++ src/ncint/CMakeLists.txt | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index d81ec2edbc4..948a7a0f8dd 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -21,6 +21,10 @@ include_directories( target_include_directories (pioc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +# Include the ncint source directory +target_include_directories (pioc + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ncint) + # System and compiler CPP directives target_compile_definitions (pioc PUBLIC ${CMAKE_SYSTEM_DIRECTIVE}) diff --git a/src/ncint/CMakeLists.txt b/src/ncint/CMakeLists.txt index 4a0b4d57faf..8d5776d46c8 100644 --- a/src/ncint/CMakeLists.txt +++ b/src/ncint/CMakeLists.txt @@ -1 +1,45 @@ cmake_minimum_required (VERSION 2.8.12) + +add_library(ncint nc_get_vard.c ncintdispatch.c ncint_pio.c nc_put_vard.c) + +# set up include-directories +include_directories( + "${CMAKE_BINARY_DIR}" + "${PROJECT_SOURCE_DIR}" # to find foo/foo.h + "${PROJECT_BINARY_DIR}") # to find foo/config.h + +# Include the clib source directory +target_include_directories (ncint + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +# Include the ncint source directory +target_include_directories (ncint + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../clib) + +#===== NetCDF-C ===== +find_package (NetCDF "4.3.3" COMPONENTS C) +if (NetCDF_C_FOUND) + target_include_directories (ncint + PUBLIC ${NetCDF_C_INCLUDE_DIRS}) + target_compile_definitions (ncint + PUBLIC _NETCDF) + target_link_libraries (ncint + PUBLIC ${NetCDF_C_LIBRARIES}) + if (${NetCDF_C_HAS_PARALLEL}) + target_compile_definitions (ncint + PUBLIC _NETCDF4) + endif () + if (${NetCDF_C_LOGGING_ENABLED}) + target_compile_definitions (ncint + PUBLIC NETCDF_C_LOGGING_ENABLED) + # netcdf.h needs this to be defined to use netCDF logging. + target_compile_definitions (ncint + PUBLIC LOGGING) + endif() +else () + target_compile_definitions (ncint + PUBLIC _NONETCDF) +endif () + + +