From 31cfdd5910affe4316706b11bdd54b6799a8c651 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 28 Aug 2012 22:31:07 +0000 Subject: [PATCH] Added 'examples' directory to CMake --- CMakeLists.txt | 24 +++++++++- examples/C/CMakeLists.txt | 13 +++++ examples/CDL/CMakeLists.txt | 17 +++++++ examples/CDL/create_sample_files.sh | 14 ++++++ examples/CDL/do_comps.sh | 14 ++++++ examples/CMakeLists.txt | 10 ++++ ncdap_test/CMakeLists.txt | 27 ++++------- ncdump/CMakeLists.txt | 74 ++++++++++++++--------------- ncgen3/ncgentab.c | 8 ---- 9 files changed, 136 insertions(+), 65 deletions(-) create mode 100644 examples/C/CMakeLists.txt create mode 100644 examples/CDL/CMakeLists.txt create mode 100644 examples/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 26f95c4f4..4a55d7a57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,19 @@ MACRO(GEN_m4 filename) ) ENDMACRO(GEN_m4) +MACRO(add_bin_test prefix F) + ADD_EXECUTABLE(${prefix}_${F} ${F}.c) + TARGET_LINK_LIBRARIES(${prefix}_${F} netcdf) + ADD_TEST(${prefix}_${F} ${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F}) + +ENDMACRO() + +# Shell script Macro +MACRO(add_sh_test prefix F) + ADD_TEST(${prefix}_${F} sh ${CMAKE_CURRENT_BINARY_DIR}/${F}.sh) +ENDMACRO() + + ##### # Option checks ##### @@ -89,6 +102,10 @@ OPTION (BUILD_UTILITIES "Build ncgen, ncgen3, ncdump." ON) # Option to use MMAP OPTION (BUILD_MMAP "Use MMAP." OFF) +# Option to use examples. +OPTION (ENABLE_EXAMPLES "Build Examples" ON) + + # Option to use Diskless OPTION (ENABLE_DISKLESS "Build Diskless." OFF) IF(ENABLE_DISKLESS) @@ -123,7 +140,7 @@ ENDIF (USE_HDF4) # Option to Build DLL OPTION (ENABLE_DLL "Build a Windows DLL." OFF) IF (ENABLE_DLL) - SET(BUILD_DLL ON) + SET(BUILD_DLL ON CACHE BOOL "") ADD_DEFINITIONS(-DDLL_NETCDF) ADD_DEFINITIONS(-DDLL_EXPORT) ENDIF () @@ -467,6 +484,11 @@ IF(ENABLE_TESTS) IF(USE_DAP) ADD_SUBDIRECTORY(ncdap_test) ENDIF() + + IF(ENABLE_EXAMPLES) + ADD_SUBDIRECTORY(examples) + ENDIF() + ENDIF() ##### diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt new file mode 100644 index 000000000..9b9cdcfe3 --- /dev/null +++ b/examples/C/CMakeLists.txt @@ -0,0 +1,13 @@ +SET(CMAKE_INCLUDE_CURRENT_DIR ON) + +INCLUDE_DIRECTORIES(".") + +SET(exam_C_tests simple_xy_wr simple_xy_rd sfc_pres_temp_wr sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd) + +FOREACH(F ${exam_C_tests}) + add_bin_test(C_tests ${F}) +ENDFOREACH() + +SET(CLEANFILES sfc_pres_temp.nc simple_xy.nc pres_temp_4D.nc simple_nc4.nc simple_xy_nc4.nc) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") + diff --git a/examples/CDL/CMakeLists.txt b/examples/CDL/CMakeLists.txt new file mode 100644 index 000000000..261112d57 --- /dev/null +++ b/examples/CDL/CMakeLists.txt @@ -0,0 +1,17 @@ +SET(CMAKE_INCLUDE_CURRENT_DIR ON) + +INCLUDE_DIRECTORIES(".") + + +SET(CDL_EXAMPLE_TESTS create_sample_files do_comps) + +FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl) +FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE) + +FOREACH(F ${CDL_EXAMPLE_TESTS}) + add_sh_test(cdl ${F}) +ENDFOREACH() + +SET(CLEANFILES simple_xy.nc sfc_pres_temp.nc pres_temp_4D.nc) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") + diff --git a/examples/CDL/create_sample_files.sh b/examples/CDL/create_sample_files.sh index f2fa5a529..265a4b971 100755 --- a/examples/CDL/create_sample_files.sh +++ b/examples/CDL/create_sample_files.sh @@ -1,6 +1,20 @@ #!/bin/sh # This shell script creates the netCDF example files from CDL scipts. # $Id: create_sample_files.sh,v 1.2 2006/07/14 18:39:45 ed Exp $ +srcdir=`dirname $0` + +# compute the build directory +# Do a hack to remove e.g. c: for CYGWIN +cd `pwd` +builddir=`pwd`/.. + +# Hack for CYGWIN +cd $srcdir +srcdir=`pwd` +if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then + srcdir=`pwd | sed 's/\/c\//c:\//g'` + builddir=`echo $builddir | sed 's/\/c\//c:\//g'` +fi set -e echo "" diff --git a/examples/CDL/do_comps.sh b/examples/CDL/do_comps.sh index faaa6fa4c..1aad7eae6 100755 --- a/examples/CDL/do_comps.sh +++ b/examples/CDL/do_comps.sh @@ -1,6 +1,20 @@ #!/bin/sh # This shell script runs the cmp test on the example programs. # $Id: do_comps.sh,v 1.1 2006/06/27 17:44:54 ed Exp $ +srcdir=`dirname $0` + +# compute the build directory +# Do a hack to remove e.g. c: for CYGWIN +cd `pwd` +builddir=`pwd`/.. + +# Hack for CYGWIN +cd $srcdir +srcdir=`pwd` +if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then + srcdir=`pwd | sed 's/\/c\//c:\//g'` + builddir=`echo $builddir | sed 's/\/c\//c:\//g'` +fi set -e echo "" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..3b94aaef5 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,10 @@ +SET(CMAKE_INCLUDE_CURRENT_DIR ON) + +INCLUDE_DIRECTORIES(".") + +ADD_SUBDIRECTORY(C) + +IF(BUILD_UTILITIES) + ADD_SUBDIRECTORY(CDL) +ENDIF() + diff --git a/ncdap_test/CMakeLists.txt b/ncdap_test/CMakeLists.txt index d1ba21555..7b2a3ad49 100644 --- a/ncdap_test/CMakeLists.txt +++ b/ncdap_test/CMakeLists.txt @@ -21,33 +21,22 @@ IF(ENABLE_TESTS) # must be run in a particular order. It is painful but will use macros to help # keep it from being too bad. # Binary Test Macro - MACRO(add_bin_test F) - ADD_EXECUTABLE(ncdap_${F} ${F}.c) - TARGET_LINK_LIBRARIES(ncdap_${F} netcdf) - ADD_TEST(ncdap_${F} ${EXECUTABLE_OUTPUT_PATH}/ncdap_${F}) - - ENDMACRO() - - # Shell script Macro - MACRO(add_sh_test F) - ADD_TEST(ncdap_${F} sh ${CMAKE_CURRENT_BINARY_DIR}/${F}.sh) - ENDMACRO() - add_sh_test(tst_ncdap3) + add_sh_test(ncdap tst_ncdap3) IF(ENABLE_DAP_REMOTE_TESTS) - add_sh_test(tst_remote3) + add_sh_test(ncdap tst_remote3) ENDIF() IF(ENABLE_DAP_LONG_TESTS) - add_sh_test(tst_longremote3) + add_sh_test(ncdap tst_longremote3) ENDIF() - add_bin_test(t_dap3a) - add_bin_test(test_cvt) - add_bin_test(test_vara) - add_bin_test(test_partvar) - add_bin_test(test_varm3) + add_bin_test(ncdap t_dap3a) + add_bin_test(ncdap test_cvt) + add_bin_test(ncdap test_vara) + add_bin_test(ncdap test_partvar) + add_bin_test(ncdap test_varm3) ENDIF() diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt index 3eaa1c5b0..2d368ff4f 100644 --- a/ncdump/CMakeLists.txt +++ b/ncdump/CMakeLists.txt @@ -39,58 +39,58 @@ IF(ENABLE_TESTS) # must be run in a particular order. It is painful but will use macros to help # keep it from being too bad. # Binary Test Macro - MACRO(add_bin_test F) - ADD_EXECUTABLE(ncdump_${F} ${F}.c) - TARGET_LINK_LIBRARIES(ncdump_${F} netcdf) - ADD_TEST(ncdump_${F} ${EXECUTABLE_OUTPUT_PATH}/ncdump_${F}) + #MACRO(add_bin_test F) + # ADD_EXECUTABLE(ncdump_${F} ${F}.c) + # TARGET_LINK_LIBRARIES(ncdump_${F} netcdf) + # ADD_TEST(ncdump_${F} ${EXECUTABLE_OUTPUT_PATH}/ncdump_${F}) - ENDMACRO() + #ENDMACRO() # Shell script Macro - MACRO(add_sh_test F) - IF(NOT MSVC) - ADD_TEST(ncdump_${F} sh ${CMAKE_CURRENT_BINARY_DIR}/${F}.sh) - ENDIF() - ENDMACRO() + #MACRO(add_sh_test F) + # IF(NOT MSVC) + # ADD_TEST(ncdump_${F} sh ${CMAKE_CURRENT_BINARY_DIR}/${F}.sh) + # ENDIF() + #ENDMACRO() ## Start adding tests in the appropriate order - add_sh_test(run_tests) - add_sh_test(tst_64bit) - add_bin_test(ctest) - add_bin_test(ctest64) - add_sh_test(tst_output) - add_sh_test(tst_lengths) - add_sh_test(tst_calendars) - add_bin_test(tst_utf8) - add_sh_test(run_utf8_tests) - add_sh_test(tst_nccopy3) - add_sh_test(tst_charfill) - add_sh_test(tst_iter) + add_sh_test(ncdump run_tests) + add_sh_test(ncdump tst_64bit) + add_bin_test(ncdump ctest) + add_bin_test(ncdump ctest64) + add_sh_test(ncdump tst_output) + add_sh_test(ncdump tst_lengths) + add_sh_test(ncdump tst_calendars) + add_bin_test(ncdump tst_utf8) + add_sh_test(ncdump run_utf8_tests) + add_sh_test(ncdump tst_nccopy3) + add_sh_test(ncdump tst_charfill) + add_sh_test(ncdump tst_iter) IF(EXTRA_TESTS) - add_sh_test(run_back_comp_tests) + add_sh_test(ncdump run_back_comp_tests) ENDIF() IF(USE_NETCDF4) - add_bin_test(tst_create_files) - add_bin_test(tst_group_data) - add_bin_test(tst_enum_data) - add_bin_test(tst_opaque_data) - add_bin_test(tst_string_data) - add_bin_test(tst_vlen_data) - add_bin_test(tst_comp) - add_bin_test(tst_comp2) - add_bin_test(tst_nans) - add_bin_test(tst_special_atts) + add_bin_test(ncdump tst_create_files) + add_bin_test(ncdump tst_group_data) + add_bin_test(ncdump tst_enum_data) + add_bin_test(ncdump tst_opaque_data) + add_bin_test(ncdump tst_string_data) + add_bin_test(ncdump tst_vlen_data) + add_bin_test(ncdump tst_comp) + add_bin_test(ncdump tst_comp2) + add_bin_test(ncdump tst_nans) + add_bin_test(ncdump tst_special_atts) #add_sh_test(tst_netcdf4) #add_bin_test(tst_h_rdc0) - add_bin_test(tst_unicode) + add_bin_test(ncdump tst_unicode) #add_bin_test(tst_fillbug) #add_sh_test(tst_fillbug) - add_sh_test(tst_netcdf4_4) - add_bin_test(tst_compress) + add_sh_test(ncdump tst_netcdf4_4) + add_bin_test(ncdump tst_compress) #add_sh_test(tst_nccopy4) - add_sh_test(tst_grp_spec) + add_sh_test(ncdump tst_grp_spec) ENDIF() #add_sh_test(tst_ncgen4_classic) diff --git a/ncgen3/ncgentab.c b/ncgen3/ncgentab.c index e74c4309a..20552d418 100644 --- a/ncgen3/ncgentab.c +++ b/ncgen3/ncgentab.c @@ -72,9 +72,6 @@ /* Line 336 of yacc.c */ #line 9 "/Users/wfisher/Desktop/win_netcdf/ncgen3/ncgen.y" -/* Line 268 of yacc.c */ -#line 9 "/home/wfisher/Desktop/win_netcdf/ncgen3/ncgen.y" - #ifdef sccs static char SccsId[] = "$Id: ncgen.y,v 1.34 2010/03/31 18:18:41 dmh Exp $"; #endif @@ -157,11 +154,6 @@ int yyerror(char*); # endif # endif -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE