diff --git a/CMakeLists.txt b/CMakeLists.txt index 40e915f655e..4b1e3589e4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,17 @@ if (PIO_ENABLE_COVERAGE) endif () endif () +# Include this so we can check values in netcdf_meta.h. +INCLUDE(CheckCSourceCompiles) +INCLUDE(FindNetCDF) +if (PIO_ENABLE_FORTRAN) + find_package (NetCDF REQUIRED COMPONENTS C Fortran) + find_package (PnetCDF COMPONENTS C Fortran) +else() + find_package (NetCDF REQUIRED COMPONENTS C) + find_package (PnetCDF COMPONENTS C) +endif() + #============================================================================== # INCLUDE SOURCE DIRECTORIES #============================================================================== @@ -265,11 +276,6 @@ if (PIO_ENABLE_DOC) add_subdirectory (doc) endif () -# Include this so we can check values in netcdf_meta.h. -INCLUDE(CheckCSourceCompiles) -INCLUDE(FindNetCDF) -find_package (NetCDF REQUIRED) -find_package (PnetCDF) SET(STATUS_PNETCDF PnetCDF_C_FOUND) @@ -425,6 +431,3 @@ configure_file ( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/config.h" ) - - - diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 49f772ba371..fb9bde74e8e 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -92,7 +92,8 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-C ===== -find_package (NetCDF "4.3.3" COMPONENTS C) + +message("NetCDF_C_FOUND has value ${NetCDF_C_FOUND}") if (NetCDF_C_FOUND) target_include_directories (pioc PUBLIC ${NetCDF_C_INCLUDE_DIRS}) diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 2f4f54feacc..2e1493375aa 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -219,7 +219,7 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-Fortran ===== -find_package (NetCDF "4.3.3" COMPONENTS Fortran) +message("NetCDF_Fortran_FOUND is ${NetCDF_Fortran_FOUND}") if (NetCDF_Fortran_FOUND) target_include_directories (piof PUBLIC ${NetCDF_Fortran_INCLUDE_DIRS})