Modified how m4 is detected/handled, made it less a straight platform check.

This commit is contained in:
Ward Fisher 2015-06-11 14:28:39 -06:00
parent 03fad43a19
commit 952b73e51e
2 changed files with 15 additions and 9 deletions

View File

@ -1055,22 +1055,26 @@ ENDMACRO()
# A basic script used to convert m4 files
FIND_PROGRAM(NC_M4 NAMES m4)
IF(NOT MSVC)
IF(NOT NC_M4)
MESSAGE(FATAL "Cannot find 'm4' utility. Install m4 and try again.")
ENDIF(NOT NC_M4)
ENDIF(NOT MSVC)
IF(NC_M4)
SET(HAVE_M4 TRUE)
ENDIF()
#IF(NOT MSVC)
#IF(NOT NC_M4)
# MESSAGE(FATAL "Cannot find 'm4' utility. Install m4 and try again.")
# ENDIF(NOT NC_M4)
#ENDIF(NOT MSVC)
MACRO(GEN_m4 filename)
# IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c)
IF(NC_M4)
IF(HAVE_M4)
MESSAGE(STATUS "Test: NC_M4: ${NC_M4}")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ENDIF(NC_M4)
ENDIF(HAVE_M4)
ENDMACRO(GEN_m4)
# Binary tests, but ones which depend on value of 'TEMP_LARGE' being defined.

View File

@ -4,7 +4,9 @@
# Process these files with m4.
SET(m4_SOURCES attr ncx putget t_ncxx)
foreach (f ${m4_SOURCES})
IF(HAVE_M4)
GEN_m4(${f})
ENDIF()
endforeach(f)
SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c)
@ -45,13 +47,13 @@ IF (BUILD_PARALLEL)
ENDIF(BUILD_PARALLEL)
# Generate the man page.
IF(NOT MSVC)
IF(HAVE_M4)
FILE(GLOB libsrc_MANPAGE ${CMAKE_SOURCE_DIR}/docs/netcdf.m4)
FILE(COPY ${libsrc_MANPAGE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_TARGET(manpage ALL
COMMAND m4 ${ARGS_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4 > ${CMAKE_CURRENT_BINARY_DIR}/netcdf.3
COMMAND ${NC_M4} ${ARGS_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4 > ${CMAKE_CURRENT_BINARY_DIR}/netcdf.3
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)