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

generate config.h the cmake way #106

Closed
wants to merge 4 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ file(STRINGS "VERSION" pVersion)

# Set up project with version number from VERSION file.
project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C)
message(STATUS "Building wgrib2-${CMAKE_PROJECT_VERSION}")

# Handle user build options.
option(USE_NETCDF3 "Use NetCDF-3?" off)
Expand Down Expand Up @@ -130,6 +131,11 @@ if(USE_PNG)
endif()

# write config.h
configure_file (
"${PROJECT_SOURCE_DIR}/wgrib2/config.h.in"
"${PROJECT_BINARY_DIR}/wgrib2/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")
Expand Down
32 changes: 32 additions & 0 deletions wgrib2/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* config.h generated by cmake */
#ifndef _CONFIG_H
#define _CONFIG_H

#cmakedefine USE_NETCDF3
#cmakedefine USE_NETCDF4
#cmakedefine USE_HDF5
#cmakedefine USE_REGEX
#cmakedefine USE_TIGGE
#cmakedefine USE_MYSQL
#define USE_IPOLATES @USE_IPOLATES@
#cmakedefine USE_UDF
#cmakedefine USE_OPENMP
#cmakedefine USE_PROJ4
#cmakedefine USE_WMO_VALIDATION
#cmakedefine DISABLE_TIMEZONE
#cmakedefine DISABLE_ALARM
#cmakedefine USE_NAMES NCEP
#cmakedefine USE_G2CLIB
#cmakedefine USE_PNG
#cmakedefine USE_JASPER
#cmakedefine USE_OPENJPEG
#cmakedefine MAKE_FTN_API
#cmakedefine USE_AEC

#define BUILD_COMMENTS "@BUILD_COMMENTS@"
#define CC "@CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_ID@"
#define FORTRAN "@CMAKE_Fortran_COMPILER@ @CMAKE_Fortran_COMPILER_ID@"
#define CPPFLAGS "@CMAKE_C_FLAGS@"
#define FFLAGS "@CMAKE_Fortran_FLAGS@"
#define WGRIB2_VERSION "@CMAKE_PROJECT_VERSION@"
#endif
Loading