Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake check test 1_30 #89

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ jobs:
- name: build
run: |
cd wgrib2
mkdir b
cd b
cmake ..
make VERBOSE=1
140 changes: 75 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
cmake_minimum_required(VERSION 3.12)
project(wgrib2 VERSION 2.0.8 LANGUAGES Fortran C)
project(wgrib2 VERSION 3.1.4 LANGUAGES Fortran C)


option(USE_NETCDF3 "Use NetCDF-3?" off)
option(USE_NETCDF4 "Use NetCDF-4?" off)
option(USE_HDF5 "Use HDF5?" off)
option(USE_REGEX "Use Regex?" on)
option(USE_TIGGE "Use tigge?" on)
option(USE_MYSQL "Use MySQL?" off)
# option(USE_IPOLATES "iplib=0,1,3?" 3)
set(USE_IPOLATES 0)
option(USE_UDF "Use UDF?" off)
option(USE_OPENMP "Use OpenMP?" on)
option(USE_PROJ4 "Use Proj4?" off)
option(USE_WMO_VALIDATION "Use WMO Validation?" off)
option(DISABLE_TIMEZONE "Disable posix Timezone?" off)
option(DISABLE_ALARM "Disable Alarm?" off)
option(DISABLE_STAT "disable posix feature" off)
set(USE_NAMES "NCEP")
option(USE_G2CLIB "Use g2c lib?" off)
option(USE_PNG "Use PNG?" off)
option(USE_JASPER "Use Jasper?" off)
option(USE_OPENJPEG "Use OpenJPEG?" off)
option(USE_AEC "Use AEC?" off)
# MAKE_FTN_API should only be on when building library
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")

Expand All @@ -16,7 +47,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-g -traceback ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-O0")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_C_FLAGS "-g -fbacktrace ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-O0")
endif()

Expand All @@ -28,28 +59,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -O0")
endif()

option(USE_NETCDF3 "Use NetCDF-3?" off)
option(USE_NETCDF4 "Use NetCDF-4?" off)
option(USE_REGEX "Use Regex?" on)
option(USE_TIGGE "Use tigge?" on)
option(USE_MYSQL "Use MySQL?" off)
set(USE_IPOLATES "0" CACHE STRING "")
option(USE_SPECTRAL "Use SP lib?" off)
option(USE_UDF "Use UDF?" off)
option(OPENMP "Use OpenMP?" off)
option(USE_PROJ4 "Use Proj4?" off)
option(USE_WMO_VALIDATION "Use WMO Validation?" off)
option(DISABLE_TIMEZONE "Disable Timezone?" off)
option(DISABLE_ALARM "Disable Alarm?" off)

option(USE_G2CLIB "Use g2c lib?" off)
option(USE_PNG "Use PNG?" on)
option(USE_JASPER "Use Jasper?" on)
option(USE_AEC "Use AEC?" off)

option(BUILD_LIB "Build wgrib2 library?" on)
option(BUILD_SHARED_LIB "Build shared library?" off)


if(USE_G2CLIB)
if(USE_PNG)
Expand All @@ -65,40 +74,14 @@ if(USE_NETCDF3 AND USE_NETCDF4)
message(FATAL_ERROR "USE_NETCDF3 OR USE_NetCDF4, not both")
endif()

if(USE_REGEX)
list(APPEND definitions_list -DUSE_REGEX)
endif()

if(USE_TIGGE)
list(APPEND -DUSE_TIGGE)
endif()

if(DISABLE_ALARM)
list(APPEND definitions_list -DDISABLE_ALARM)
endif()

if(DISABLE_TIMEZONE)
list(APPEND definitions_list -DDISABLE_TIMEZONE)
endif()

if(USE_UDF)
list(APPEND definitions_list -DUSE_UDF)
endif()

if(USE_IPOLATES EQUAL 1)
find_package(ip CONFIG REQUIRED)
find_package(sp CONFIG REQUIRED)
elseif(USE_IPOLATES EQUAL 3)
find_package(ip2 CONFIG REQUIRED)
list(APPEND definitions_list -DUSE_SPECTRAL=1)
endif()

if(NOT USE_IPOLATES EQUAL 0)
list(APPEND definitions_list -DIPOLATES_LIB="ipolates_lib")
endif()

list(APPEND definitions_list -DUSE_IPOLATES=${USE_IPOLATES})

if(USE_NETCDF4)
find_package(NetCDF MODULE REQUIRED COMPONENTS C)
list(APPEND definitions_list -DUSE_NETCDF4 -DUSE_HDF5 -DHDF5="hdf5")
Expand All @@ -112,34 +95,61 @@ if(USE_JASPER)
endif()
endif()

if(OPENMP)
list(APPEND definitions_list -DUSE_OPENMP)
if(USE_OPENMP)
find_package(OpenMP)
endif()

if(USE_G2CLIB)
list(APPEND definitions_list -DUSE_G2CLIB)
endif()

if(USE_PROJ4)
list(APPEND definitions_list -DUSE_PROJ4)
if(OpenMP_CXX_FOUND)
target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_CXX)
endif()
# if(OpenMP_Fortran_FOUND)
# target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_Fortran)
# endif()
endif()

if(USE_PNG)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
list(APPEND definitions_list -DUSE_PNG)
endif()

if(USE_WMO_VALIDATION)
list(APPEND definitions_list -DUSE_WMO_VALIDATION)
endif()

# write 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")

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)

# FILE(APPEND "wgrib2/config.h" "#test ${var} ${${var}}\n")
if(${var} STREQUAL ON)
FILE(APPEND "wgrib2/config.h" "#define ${var}\n")
elseif(${var} STREQUAL OFF)
FILE(APPEND "wgrib2/config.h" "// #define ${var}\n")
elseif(${${var}} MATCHES " ")
FILE(APPEND "wgrib2/config.h" "#define ${var} \"${${var}}\"\n")
else()
FILE(APPEND "wgrib2/config.h" "#define ${var} ${${var}}\n")
endif()
ENDFOREACH()

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")





add_subdirectory(wgrib2)
add_subdirectory(aux_progs)


if(BUILD_LIB)
add_subdirectory(ftn_api)

### Package config
include(CMakePackageConfigHelpers)
Expand Down
6 changes: 6 additions & 0 deletions aux_progs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

add_executable(gmerge gmerge.c uint8.c)

add_executable(smallest_grib2 smallest_grib2.c uint8.c)

add_executable(smallest_4 smallest_4.c uint8.c)
34 changes: 34 additions & 0 deletions ftn_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


set(fortran_src
wgrib2api.f90
wgrib2lowapi.f90
)

set(c_src
fort_wgrib2.c
)


add_library(wgrib2_api ${fortran_src} ${c_src})

set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}")
set_target_properties(wgrib2_api PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir})



target_include_directories(wgrib2_api
PUBLIC $<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}>)

target_link_libraries(wgrib2_api PUBLIC wgrib2_lib)

install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})

install(
TARGETS wgrib2_api
EXPORT wgrib2_exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Loading
Loading