Merging CMake branch into trunk. Changes include:

CMake related changes in CMakeLists.txt files,
cmake_config.h.in. Other changes relate to 
Windows-specific issues, and changes made
when regenerating generated source files.
This commit is contained in:
Ward Fisher 2013-01-15 22:43:09 +00:00
parent 4a6b93f3ab
commit 91188cea7a
13 changed files with 287 additions and 267 deletions

View File

@ -196,17 +196,33 @@ IF(ENABLE_LOGGING)
SET(LOGGING ON)
ENDIF()
# Option to use HDF4
OPTION (USE_HDF4 "Build NetCDF-4 with HDF5 read capability (HDF4, HDF5 and Zlib required." OFF)
IF (USE_HDF4)
FIND_PACKAGE(HDF4)
IF(NOT HDF4_FOUND)
MESSAGE(FATAL_ERROR "HDF4 Support specified, but HDF4 libraries were not found.")
ENDIF(NOT HDF4_FOUND)
OPTION (ENABLE_HDF4 "Build NetCDF-4 with HDF5 read capability (HDF4, HDF5 and Zlib required)." OFF)
IF (ENABLE_HDF4)
SET(USE_HDF4 ON)
# Check for include files, libraries.
CHECK_INCLUDE_FILE("mfhdf.h" HAVE_MFHDF_H)
IF(NOT HAVE_MFHDF_H)
MESSAGE(FATAL_ERROR "HDF4 Support specified, cannot find file mfhdf.h")
ENDIF(NOT HAVE_MFHDF_H)
ENDIF (USE_HDF4)
FIND_LIBRARY(HDF4_DF_LIB NAMES df libdf)
IF(NOT HDF4_DF_LIB)
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find df lib.")
ENDIF()
FIND_LIBRARY(HDF4_MFHDF_LIB NAMES mfhdf libmfhdf)
IF(NOT HDF4_MFHDF_LIB)
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find mfhdf lib.")
ENDIF()
SET(HDF4_LIBRARIES ${HDF4_DF_LIB} ${HDF4_MFHDF_LIB})
# End include files, libraries.
MESSAGE(STATUS "HDF4 Libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}")
OPTION(ENABLE_HDF4_FILE_TESTS "Run HDF4 File Tests.",OFF)
IF(ENABLE_HDF4_FILE_TESTS)
SET(USE_HDF4_FILE_TESTS ON)
ENDIF()
ENDIF ()
# Option to Build DLL
IF(WIN32)
@ -306,6 +322,13 @@ ELSE()
SET(ENABLE_DAP_GROUPS OFF CACHE BOOL "Whether netcdf4 group names should be enabled.")
ENDIF()
# Enable some developer-only tests
OPTION(ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." OFF)
IF(ENABLE_EXTRA_TESTS)
SET(EXTRA_TESTS ON)
ENDIF()
# Option to use bundled XGetopt in place of getopt(). This is mostly useful
# for MSVC builds. If not building utilities, getopt() isn't required at all.
IF(MSVC)
@ -421,6 +444,12 @@ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/libsrc)
# Library include checks
CHECK_INCLUDE_FILE("math.h" HAVE_MATH_H)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
# Solve a compatibility issue in ncgen/, which checks
# for NO_UNISTD_H
IF(NOT HAVE_UNISTD_H)
SET(YY_NO_UNISTD_H TRUE)
ENDIF()
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H)
CHECK_INCLUDE_FILE("dirent.h" HAVE_DIRENT_H)

View File

@ -104,6 +104,7 @@
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
#cmakedefine YY_NO_UNISTD_H @YY_NO_UNISTD_H@
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@

View File

@ -723,6 +723,8 @@ dnl fi
fi
AC_CHECK_LIB([df], [Hclose], [], [])
AC_CHECK_LIB([mfhdf], [SDcreate], [], [])
#AC_SEARCH_LIBS([Hclose],[df], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])])
#AC_SEARCH_LIBS([SDcreate],[mfhdf], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])])
AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too])
fi
fi

View File

@ -412,8 +412,7 @@ by the desired type. */
/* Define for 64 bit windows. */
#if defined (_WIN64)
#define off_t __int64
#define size_t __int64
//#define lseek _lseeki64
#define size_t unsigned __int64
#define _OFF_T_DEFINED
#endif

View File

@ -56,26 +56,32 @@ nvdims(int ncid, int varid)
return ndims;
}
static void* nvmalloc(int ct, int size) {
int mct = ct;
if(ct < 0) mct = 1;
/* Used to avoid errors on 64-bit windows related to
c89 macros and flow control/conditionals. */
static void* nvmalloc(off_t size) {
if(size < 0)
return NULL;
return malloc(mct * size);
return malloc(size);
}
#define NDIMS_DECL const int ndims = nvdims(ncid, varid);
#define NDIMS_DECL const int ndims = nvdims(ncid, varid); \
# define A_DECL(name, type, ndims, rhs) \
ALLOC_ONSTACK(name, type, ndims)
type *const name = (type*) nvmalloc((ndims) * sizeof(type))
// ALLOC_ONSTACK(name, type, ndims)
# define A_FREE(name) \
FREE_ONSTACK(name)
# define A_INIT(lhs, type, ndims, rhs) \
{ \
if(ndims >= 0) { \
if((off_t)ndims >= 0) { \
const long *lp = rhs; \
type *tp = lhs; \
type *const end = lhs + ndims; \
@ -86,7 +92,7 @@ static void* nvmalloc(int ct, int size) {
} \
} \
\
if (ndims < 0) {nc_advise("nvdims",NC_EMAXDIMS,"ndims %d",ndims); return -1;}
if ((off_t)ndims < 0) {nc_advise("nvdims",NC_EMAXDIMS,"ndims %d",ndims); return -1;}
#endif
@ -788,7 +794,6 @@ ncvarputs(
{
NDIMS_DECL
A_DECL(stp, size_t, ndims, start);
A_DECL(cntp, size_t, ndims, count);
A_DECL(strdp, ptrdiff_t, ndims, stride);

View File

@ -41,6 +41,10 @@ IF(USE_DAP)
SET(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
ENDIF()
IF(USE_HDF4)
SET(TLL_LIBS ${TLL_LIBS} ${HDF4_LIBRARIES})
ENDIF()
IF(USE_HDF5 OR USE_NETCDF4)
SET(TLL_LIBS ${TLL_LIBS} ${SZIP_LIBRARY} ${HDF5_LIBRARIES})
ENDIF()

View File

@ -1245,7 +1245,8 @@ read_type(NC_GRP_INFO_T *grp, char *type_name)
if ((retval = nc4_enum_member_add(&type->enum_member, type->size,
member_name, value)))
return retval;
free(member_name); /* Where is this defined? */
free(member_name);
}
/* Free the tempory memory for one value, and the member name

View File

@ -12,38 +12,34 @@ ADD_EXECUTABLE(nc_test ${nc_test_SRC})
TARGET_LINK_LIBRARIES(nc_test netcdf)
# Some extra tests
SET(EXTRA_TSTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3)
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3)
IF(NOT MSVC)
SET(EXTRA_TSTS ${EXTRA_TSTS} tst_atts3)
SET(TESTS ${TESTS} tst_atts3)
ENDIF()
IF(USE_NETCDF4)
SET(EXTRA_TSTS ${EXTRA_TSTS} tst_atts)
SET(TESTS ${TESTS} tst_atts)
ENDIF()
IF(LARGE_FILE_TESTS)
SET(EXTRA_TSTS ${EXTRA_TSTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large large_files)
SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large large_files)
ENDIF()
IF(BUILD_DISKLESS)
SET(EXTRA_TSTS ${EXTRA_TSTS} tst_diskless tst_diskless3 tst_diskless4)
SET(TESTS ${TESTS} tst_diskless tst_diskless3 tst_diskless4)
IF(USE_NETCDF4)
SET(EXTRA_TSTS ${EXTRA_TSTS} tst_diskless2)
SET(TESTS ${TESTS} tst_diskless2)
ENDIF()
ENDIF()
FOREACH(CTEST ${EXTRA_TSTS})
FOREACH(CTEST ${TESTS})
add_bin_test(nc_test ${CTEST})
#ADD_EXECUTABLE(${CTEST} ${CTEST}.c)
#TARGET_LINK_LIBRARIES(${CTEST} netcdf)
ENDFOREACH()
## Tests
ADD_TEST(nc_test ${EXECUTABLE_OUTPUT_PATH}/nc_test)

View File

@ -2,7 +2,7 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES(".")
# Some extra tests
SET(EXTRA_TSTS4 tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2
tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings
tst_strings2 tst_interops tst_interops4 tst_interops6
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4
@ -12,23 +12,27 @@ t_type cdm_sea_soundings tst_vl
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug)
IF(NOT MSVC)
SET(EXTRA_TSTS4 ${EXTRA_TSTS4} tst_interops5 tst_camrun)
SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun)
ENDIF()
IF(USE_HDF4)
SET(NC4_TESTS ${NC4_TESTS} tst_interops2)
ENDIF()
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc)
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
FOREACH(CTEST ${EXTRA_TSTS4})
FOREACH(CTEST ${NC4_TESTS})
add_bin_test(nc_test4 ${CTEST})
#ADD_EXECUTABLE(${CTEST} ${CTEST}.c)
#TARGET_LINK_LIBRARIES(${CTEST} netcdf)
#ADD_TEST(${CTEST} ${EXECUTABLE_OUTPUT_PATH}/${CTEST})
ENDFOREACH()
IF(USE_HDF4_FILE_TESTS)
add_sh_test(nc_test4 run_get_hdf4_files)
add_bin_test(nc_test4 tst_interops3)
ENDIF()

View File

@ -13,6 +13,10 @@ TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS})
INSTALL(TARGETS ncgen DESTINATION bin COMPONENT utilities)
# Copy the input for the flex file (ncgen.l)
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.l ${CMAKE_CURRENT_SOURCE_DIR}/*.y)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
# Stuff to build if tests are enabled.
IF(ENABLE_TESTS)
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
@ -33,3 +37,16 @@ ENDIF()
SET(CLEANFILES c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
ADD_CUSTOM_COMMAND(
OUTPUT ncgentab.h
COMMAND flex -Pncg -B ncgen.l
COMMAND rm -f ncgenyy.c
COMMAND mv lex.ncg.c ncgenyy.c
COMMAND bison -pncg -t -d ncgen.y
COMMAND rm -f ncgentab.c ncgentab.h
COMMAND mv ncgen.tab.c ncgentab.c
COMMAND mv ncgen.tab.h ncgentab.h
)
ADD_CUSTOM_TARGET(makeparser DEPENDS ncgentab.h)

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.4. */
/* A Bison parser, made by GNU Bison 2.7. */
/* Bison interface for Yacc-like parsers in C
@ -100,7 +100,7 @@ extern int ncgdebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2077 of yacc.c */
/* Line 2058 of yacc.c */
#line 131 "ncgen.y"
Symbol* sym;
@ -111,7 +111,7 @@ Datalist* datalist;
Constant constant;
/* Line 2077 of yacc.c */
/* Line 2058 of yacc.c */
#line 116 "ncgen.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1

View File

@ -27,7 +27,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#define YY_FLEX_SUBMINOR_VERSION 37
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -72,7 +72,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@ -171,7 +172,12 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
extern int ncgleng;
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t ncgleng;
extern FILE *ncgin, *ncgout;
@ -197,11 +203,6 @@ extern FILE *ncgin, *ncgout;
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -219,7 +220,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -289,8 +290,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when ncgtext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int ncgleng;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t ncgleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@ -318,7 +319,7 @@ static void ncg_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE ncg_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE ncg_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,int len );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,yy_size_t len );
void *ncgalloc (yy_size_t );
void *ncgrealloc (void *,yy_size_t );
@ -1324,7 +1325,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 1328 "lex.ncg.c"
#line 1329 "lex.ncg.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@ -1365,7 +1366,7 @@ FILE *ncgget_out (void );
void ncgset_out (FILE * out_str );
int ncgget_leng (void );
yy_size_t ncgget_leng (void );
char *ncgget_text (void );
@ -1426,7 +1427,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
unsigned n; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( ncgin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -1510,7 +1511,7 @@ YY_DECL
#line 168 "ncgen.l"
#line 1514 "lex.ncg.c"
#line 1515 "lex.ncg.c"
if ( !(yy_init) )
{
@ -2159,7 +2160,7 @@ YY_RULE_SETUP
#line 553 "ncgen.l"
ECHO;
YY_BREAK
#line 2163 "lex.ncg.c"
#line 2164 "lex.ncg.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -2346,21 +2347,21 @@ static int yy_get_next_buffer (void)
else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -2391,7 +2392,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@ -2501,7 +2502,7 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = (yy_n_chars) + 2;
register yy_size_t number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
@ -2550,7 +2551,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr);
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -2710,10 +2711,6 @@ static void ncg_load_buffer_state (void)
ncgfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a ncgrestart() or at EOF.
@ -2826,7 +2823,7 @@ void ncgpop_buffer_state (void)
*/
static void ncgensure_buffer_stack (void)
{
int num_to_alloc;
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@ -2918,12 +2915,12 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to ncglex() will
* scan from a @e copy of @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len )
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
@ -3010,7 +3007,7 @@ FILE *ncgget_out (void)
/** Get the length of the current token.
*
*/
int ncgget_leng (void)
yy_size_t ncgget_leng (void)
{
return ncgleng;
}