Skip to content

Commit

Permalink
Added a check for m4 and throw an error if m4 isn't on the path and t…
Browse files Browse the repository at this point in the history
…he generated file isn't present (as it would be in a point release). In support of #1739
  • Loading branch information
WardF committed May 26, 2020
1 parent c2ea69d commit 5961d6d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1492,20 +1492,27 @@ ENDIF()

MACRO(GEN_m4 filename)

IF(HAVE_M4)
# 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 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()
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 ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ENDIF(HAVE_M4)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ENDIF(HAVE_M4)
ENDMACRO(GEN_m4)

# Binary tests, but ones which depend on value of 'TEMP_LARGE' being defined.
Expand Down

0 comments on commit 5961d6d

Please sign in to comment.