From 2ea988f84d3776a55ab3c19de299033c4abc0857 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 22 Dec 2015 12:02:18 -0700 Subject: [PATCH] Added a check for signed char. --- CMakeLists.txt | 18 +++++++++++++++++- config.h.cmake.in | 3 +++ nc_test/CMakeLists.txt | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1f0206f9..ca9cd6f69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -997,8 +997,24 @@ MARK_AS_ADVANCED(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS DOXYGEN_ENABLE_TASKS ENABLE_D # Option checks ################################ +#### +# Check to see if char is signed or unsigned. +#### + +SET(SIGNED_TEST_SOURCE "\n + #include \n + int main(void) {\n + char is_signed = (char) - 1;\n + if(is_signed < 0)\n + return 0;\n + else\n + return 1;\n +}\n") + +CHECK_C_SOURCE_RUNS("${SIGNED_TEST_SOURCE}" CHAR_IS_SIGNED) +MESSAGE(STATUS "Type 'char' is signed: ${CHAR_IS_SIGNED}") + -# # Library include checks CHECK_INCLUDE_FILE("math.h" HAVE_MATH_H) CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) diff --git a/config.h.cmake.in b/config.h.cmake.in index 65e6d0cce..d173a50b5 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -209,6 +209,9 @@ are set when opening a binary file on Windows. */ /* Define if we have filelengthi64. */ #cmakedefine HAVE_FILE_LENGTH_I64 @HAVE_FILE_LENGTH_I64@ +/* Define whether char is signed by default. */ +#cmakedefine CHAR_IS_SIGNED + /* The size of `void*` as computed by sizeof. */ #cmakedefine SIZEOF_VOIDSTAR @SIZEOF_VOIDSTAR@ /* The size of `char` as computed by sizeof. */ diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt index 0f84673e2..fcb20cee9 100644 --- a/nc_test/CMakeLists.txt +++ b/nc_test/CMakeLists.txt @@ -14,12 +14,29 @@ SET (nc_test_SRC test_write.c util.c ) + +SET (nc_test2_SRC + nc_test2.c + error.c + test_get.c + test_put.c + test_read.c + test_write.c + util.c + ) + ADD_EXECUTABLE(nc_test ${nc_test_SRC}) TARGET_LINK_LIBRARIES(nc_test netcdf ${HAVE_LIBM} ) +ADD_EXECUTABLE(nc_test2 ${nc_test2_SRC}) +TARGET_LINK_LIBRARIES(nc_test2 + netcdf + ${HAVE_LIBM} + ) + # Some extra stand-alone tests SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta) @@ -66,6 +83,7 @@ FOREACH(CTEST ${TESTS}) ENDFOREACH() ADD_TEST(nc_test ${EXECUTABLE_OUTPUT_PATH}/nc_test) +ADD_TEST(nc_test2 ${EXECUTABLE_OUTPUT_PATH}/nc_test) IF(BUILD_DISKLESS) add_sh_test(nc_test run_diskless)