diff --git a/.github/workflows/Linux_options.yml b/.github/workflows/Linux_options.yml index 9611cc2f..7a80c83b 100644 --- a/.github/workflows/Linux_options.yml +++ b/.github/workflows/Linux_options.yml @@ -30,6 +30,9 @@ jobs: - { options: "-DUSE_IPOLATES=1" } + - { + options: "-DUSE_NETCDF4=ON" + } steps: @@ -40,7 +43,7 @@ jobs: sudo apt-get install libpng-dev autotools-dev autoconf - name: checkout-jasper - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: jasper-software/jasper path: jasper @@ -55,7 +58,7 @@ jobs: make install - name: checkout-sp - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: NOAA-EMC/NCEPLIBS-sp path: sp @@ -96,7 +99,7 @@ jobs: make install - name: checkout-ip2 - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: NOAA-EMC/NCEPLIBS-ip2 path: ip2 @@ -112,7 +115,7 @@ jobs: make install - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: wgrib2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8417db41..b3f74c11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,12 @@ option(USE_AEC "Use AEC?" off) option(MAKE_FTN_API "add ftn api?" off) option(DISABLE_STAT "disable posix feature" off) set(BUILD_COMMENTS "stock build") - option(BUILD_LIB "Build wgrib2 library?" on) option(BUILD_SHARED_LIB "Build shared library?" off) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -#set default install path if not provided +# Set default install path if not provided. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" @@ -50,6 +48,7 @@ endif() include(GNUInstallDirs) +# Set compiler flags. message(STATUS "Setting compiler flags...") if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_C_FLAGS "-g -traceback ${CMAKE_C_FLAGS} -DIFORT") @@ -67,7 +66,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -O0") endif() - message(STATUS "Checking if user wants to use NCEPLIBS-g2c...") if(USE_G2CLIB) if(USE_PNG) @@ -129,12 +127,13 @@ if(USE_PNG) find_package(PNG REQUIRED) endif() -# write config.h +# Start to write config.h. message(STATUS "Writing config.h...") FILE(WRITE "wgrib2/config.h" "/* config.h generated by cmake */\n") FILE(APPEND "wgrib2/config.h" "#ifndef _CONFIG_H\n") FILE(APPEND "wgrib2/config.h" "#define _CONFIG_H\n") +# Add lines to config.h for each of the user options. FOREACH(var IN ITEMS USE_NETCDF3 USE_NETCDF4 USE_HDF5 USE_REGEX USE_TIGGE USE_MYSQL USE_IPOLATES USE_UDF USE_OPENMP USE_PROJ4 USE_WMO_VALIDATION DISABLE_TIMEZONE DISABLE_ALARM USE_NAMES USE_G2CLIB USE_PNG USE_JASPER USE_OPENJPEG MAKE_FTN_API USE_AEC BUILD_COMMENTS) @@ -151,16 +150,19 @@ FOREACH(var IN ITEMS USE_NETCDF3 USE_NETCDF4 USE_HDF5 USE_REGEX USE_TIGGE USE_MY endif() ENDFOREACH() +# Add some compiler information to config.h. FILE(APPEND "wgrib2/config.h" "#define CC \"${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ID}\"\n") FILE(APPEND "wgrib2/config.h" "#define FORTRAN \"${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID}\"\n") FILE(APPEND "wgrib2/config.h" "#define CPPFLAGS \"${CMAKE_C_FLAGS}\"\n") FILE(APPEND "wgrib2/config.h" "#define FFLAGS \"${CMAKE_Fortran_FLAGS}\"\n") FILE(APPEND "wgrib2/config.h" "#endif\n") +# Compile the wgrib2 code. message(STATUS "Adding wgrib2, aux_probs subdirectories...") add_subdirectory(wgrib2) add_subdirectory(aux_progs) +# Build wgrib2 library if desired. if(BUILD_LIB) message(STATUS "Adding wgrib2 library build...") ### Package config