Merge pull request #1811 from magnusuMET/bugfix/m4_out_of_tree

Generate configure files out of tree
This commit is contained in:
Ward Fisher 2020-08-13 16:40:46 -06:00 committed by GitHub
commit 665eb151c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 55 deletions

View File

@ -1535,22 +1535,23 @@ ELSE()
MESSAGE(STATUS "m4 not found.")
ENDIF()
MACRO(GEN_m4 filename)
MACRO(GEN_m4 filename dest)
set(${dest} "${CMAKE_CURRENT_BINARY_DIR}/${filename}.c")
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
ADD_CUSTOM_COMMAND(
OUTPUT ${${dest}}
COMMAND ${NC_M4}
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${${dest}}
VERBATIM
)
ENDIF(HAVE_M4)
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)
# Binary tests, but ones which depend on value of 'TEMP_LARGE' being defined.
@ -1596,7 +1597,12 @@ ENDMACRO()
# Build a binary used by a script, but don't make a test out of it.
MACRO(build_bin_test F)
ADD_EXECUTABLE(${F} ${F}.c)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${F}.c")
ADD_EXECUTABLE(${F} "${CMAKE_CURRENT_SOURCE_DIR}/${F}.c")
else()
# File should have been copied to the binary directory
ADD_EXECUTABLE(${F} "${CMAKE_CURRENT_BINARY_DIR}/${F}.c")
endif()
TARGET_LINK_LIBRARIES(${F} netcdf ${ALL_TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(${F}
@ -1852,7 +1858,6 @@ ENDIF()
add_subdirectory(liblib)
IF(ENABLE_FILTER_TESTING)
CONFIGURE_FILE(plugins/H5Znoop.c ${CMAKE_SOURCE_DIR}/plugins/H5Znoop1.c COPYONLY)
add_subdirectory(plugins)
ENDIF()
@ -2099,10 +2104,7 @@ INSTALL(FILES "${netCDF_BINARY_DIR}/libnetcdf.settings"
#####
configure_file(
${netCDF_SOURCE_DIR}/include/netcdf_meta.h.in
${netCDF_SOURCE_DIR}/include/netcdf_meta.h @ONLY)
FILE(COPY ${netCDF_SOURCE_DIR}/include/netcdf_meta.h
DESTINATION ${netCDF_BINARY_DIR}/include/)
${netCDF_BINARY_DIR}/include/netcdf_meta.h @ONLY)
#####
# Build test_common.sh
@ -2123,16 +2125,18 @@ IF(ENABLE_EXAMPLES)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nc_test4/findplugin.in ${CMAKE_CURRENT_BINARY_DIR}/examples/C/findplugin.sh @ONLY NEWLINE_STYLE LF)
ENDIF()
#####
# Build ncdap_test|dap4_test/findtestserver[4].c
#####
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/findtestserver.c.in ${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/findtestserver.c @ONLY NEWLINE_STYLE LF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/findtestserver.c.in ${CMAKE_CURRENT_SOURCE_DIR}/dap4_test/findtestserver4.c @ONLY NEWLINE_STYLE LF)
IF(ENABLE_TESTS)
#####
# Build ncdap_test|dap4_test/findtestserver[4].c
#####
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/findtestserver.c.in ${CMAKE_CURRENT_BINARY_DIR}/ncdap_test/findtestserver.c @ONLY NEWLINE_STYLE LF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/findtestserver.c.in ${CMAKE_CURRENT_BINARY_DIR}/dap4_test/findtestserver4.c @ONLY NEWLINE_STYLE LF)
#####
# Build dap4_test/pingurl4.c
#####
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/pingurl.c ${CMAKE_CURRENT_SOURCE_DIR}/dap4_test/pingurl4.c @ONLY NEWLINE_STYLE LF)
#####
# Build dap4_test/pingurl4.c
#####
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/pingurl.c ${CMAKE_CURRENT_BINARY_DIR}/dap4_test/pingurl4.c @ONLY NEWLINE_STYLE LF)
ENDIF()
####
# Export files

View File

@ -1,35 +1,34 @@
## This is a CMake file, part of Unidata's netCDF package.
# Copyright 2012-2018, see the COPYRIGHT file for more information.
# 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)
SET(libsrc_SOURCES ${libsrc_SOURCES} pstdint.h ncio.h ncx.h)
# Process these files with m4.
SET(m4_SOURCES attr ncx putget)
foreach (f ${m4_SOURCES})
GEN_m4(${f} dest)
LIST(APPEND libsrc_SOURCES ${dest})
endforeach(f)
SET(libsrc_SOURCES ${libsrc_SOURCES} memio.c)
LIST(APPEND libsrc_SOURCES pstdint.h ncio.h ncx.h)
LIST(APPEND libsrc_SOURCES memio.c)
IF (BUILD_MMAP)
SET(libsrc_SOURCES ${libsrc_SOURCES} mmapio.c)
LIST(APPEND libsrc_SOURCES mmapio.c)
ENDIF( BUILD_MMAP)
IF (USE_FFIO)
SET(libsrc_SOURCES ${libsrc_SOURCES} ffio.c)
LIST(APPEND libsrc_SOURCES ffio.c)
ELSEIF (USE_STDIO)
SET(libsrc_SORUCES ${libsrc_SOURCES} ncstdio.c)
IST(APPEND libsrc_SOURCES ncstdio.c)
ELSE (USE_FFIO)
SET(libsrc_SOURCES ${libsrc_SOURCES} posixio.c)
LIST(APPEND libsrc_SOURCES posixio.c)
ENDIF (USE_FFIO)
IF (ENABLE_BYTERANGE)
SET(libsrc_SOURCES ${libsrc_SOURCES} httpio.c)
LIST(APPEND libsrc_SOURCES httpio.c)
ENDIF(ENABLE_BYTERANGE)
add_library(netcdf3 OBJECT ${libsrc_SOURCES})

View File

@ -15,22 +15,21 @@ add_definitions(-D"TOPBINDIR=${CMAKE_BINARY_DIR}")
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
SET (nc_test_m4_SOURCES test_get test_put test_read test_write)
FOREACH (F ${nc_test_m4_SOURCES})
GEN_m4(${F})
ENDFOREACH()
SET (nc_test_SRC
nc_test.c
error.c
test_get.c
test_put.c
test_read.c
test_write.c
util.c
)
SET (nc_test_m4_SOURCES test_get test_put test_read test_write)
FOREACH (F ${nc_test_m4_SOURCES})
GEN_m4(${F} dest)
LIST(APPEND nc_test_SRC ${dest})
ENDFOREACH()
ADD_EXECUTABLE(nc_test ${nc_test_SRC})
TARGET_INCLUDE_DIRECTORIES(nc_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
TARGET_LINK_LIBRARIES(nc_test
netcdf
${HAVE_LIBM}

View File

@ -6,12 +6,14 @@
# See netcdf-c/COPYRIGHT file for more info.
SET(CMAKE_BUILD_TYPE "")
CONFIGURE_FILE(H5Znoop.c ${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c COPYONLY)
SET(libh5bzip2_SOURCES blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c H5Zbzip2.c)
SET(libmisc_SOURCES H5Zmisc.c H5Zutil.c h5misc.h)
SET(libnoop_SOURCES H5Znoop.c H5Zutil.c h5noop.h)
SET(libnoop1_SOURCES H5Znoop1.c H5Zutil.c h5noop.h)
SET(libnoop1_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c H5Zutil.c h5noop.h)
IF(ENABLE_FILTER_TESTING)
IF(BUILD_UTILITIES)
@ -46,7 +48,7 @@ SET_TARGET_PROPERTIES(noop PROPERTIES ARCHIVE_OUTPUT_NAME "noop")
SET_TARGET_PROPERTIES(noop PROPERTIES RUNTIME_OUTPUT_NAME "noop")
TARGET_LINK_LIBRARIES(noop ${ALL_TLL_LIBS})
SET_SOURCE_FILES_PROPERTIES(H5Znoop1.c PROPERTIES COMPILE_OPTIONS -DNOOP_INSTANCE=1)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c PROPERTIES COMPILE_OPTIONS -DNOOP_INSTANCE=1)
ADD_LIBRARY(noop1 MODULE ${libnoop1_SOURCES})
SET_TARGET_PROPERTIES(noop1 PROPERTIES LIBRARY_OUTPUT_NAME "noop1")
SET_TARGET_PROPERTIES(noop1 PROPERTIES ARCHIVE_OUTPUT_NAME "noop1")