Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gh1739.wif' into gh1740.wif
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Dec 7, 2020
2 parents b292496 + 3171219 commit 6fafa66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
36 changes: 22 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ OPTION(ENABLE_NCZARR_S3_TESTS "Enable NCZarr S3 tests." OFF)

IF(ENABLE_NCZARR_S3_TESTS AND NOT ENABLE_NCZARR_S3)
message(FATAL_ERROR "NCZarr S3 support is disabled; please specify option -DENABLE_NCZARR_S3_TESTS=no")
SET(ENABLE_NCZARR_S3_TESTS OFF CACHE BOOL "NCARR S3 TESTS" FORCE)
SET(ENABLE_NCZARR_S3_TESTS OFF CACHE BOOL "NCARR S3 TESTS" FORCE)
ENDIF()

# See if aws-s3-sdk is available
Expand All @@ -994,7 +994,7 @@ find_package(AWSSDK REQUIRED)
set(SERVICE s3)
AWSSDK_DETERMINE_LIBS_TO_LINK(SERVICE AWSSDK_LINK_LIBRARIES)
IF(AWSSDK_FOUND)
SET(ENABLE_S3_SDK ON CACHE BOOL "S3 SDK" FORCE)
SET(ENABLE_S3_SDK ON CACHE BOOL "S3 SDK" FORCE)
ELSE()
SET(ENABLE_S3_SDK OFF CACHE BOOL "S3 SDK" FORCE)
ENDIF()
Expand Down Expand Up @@ -1580,24 +1580,32 @@ IF(NC_M4)
SET(HAVE_M4 TRUE)
ELSE()
MESSAGE(STATUS "m4 not found.")
SET(HAVE_M4 FALSE)
ENDIF()

MACRO(GEN_m4 filename dest)
set(${dest} "${CMAKE_CURRENT_BINARY_DIR}/${filename}.c")
MACRO(GEN_m4 filename)

# If m4 isn't present, and the generated file doesn't exist,
# it cannot be generated and an error should be thrown.
IF(NOT HAVE_M4)
IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename.c})
MESSAGE(FATAL_ERROR "m4 is required to generate ${filename}.c. Please install m4 so that it is on the PATH and try again.")
ENDIF()
ENDIF(NOT HAVE_M4)

IF(HAVE_M4)
# If m4 is available, remove generated file if it exists.
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c)
FILE(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c)
ENDIF()

ADD_CUSTOM_COMMAND(
OUTPUT ${${dest}}
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${${dest}}
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ELSE(HAVE_M4)
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c)
FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ELSE()
MESSAGE(FATAL_ERROR "File ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c does not exists, and can not be generated")
ENDIF()
)

ENDIF(HAVE_M4)
ENDMACRO(GEN_m4)

Expand Down
6 changes: 4 additions & 2 deletions libsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
# Process these files with m4.
SET(m4_SOURCES attr ncx putget)
foreach (f ${m4_SOURCES})
GEN_m4(${f} dest)
LIST(APPEND libsrc_SOURCES ${dest})
GEN_m4(${f})
IF(NOT EXISTS ${f}.c)
MESSAGE(FATAL_ERROR "m4 is required to generate ${f}.c. Please install m4 on the PATH and try again.")
ENDIF()
endforeach(f)

LIST(APPEND libsrc_SOURCES pstdint.h ncio.h ncx.h)
Expand Down

0 comments on commit 6fafa66

Please sign in to comment.