]> granicus.if.org Git - json-c/commitdiff
modify json-c default build type, and fix up the assert() errors in testcase
authordota17 <chenguopingdota@163.com>
Sat, 29 Feb 2020 07:32:42 +0000 (15:32 +0800)
committerdota17 <chenguopingdota@163.com>
Sat, 29 Feb 2020 07:32:42 +0000 (15:32 +0800)
CMakeLists.txt
tests/CMakeLists.txt
tests/test_deep_copy.c
tests/test_json_pointer.c

index c7b5195d9bd1532649b0301f3115a16a1d5d561f..8e4fb2a62f3214b6e00e0da8de752cb6390b752c 100644 (file)
@@ -19,6 +19,11 @@ if(POLICY CMP0054)
     cmake_policy(SET CMP0054 NEW)
 endif()
 
+# set default build type if not specified by user
+if(NOT CMAKE_BUILD_TYPE)
+       set(CMAKE_BUILD_TYPE debug)
+endif()
+
 # Include file check macros honor CMAKE_REQUIRED_LIBRARIES
 # i.e. the check_include_file() calls will include -lm when checking.
 if(POLICY CMP0075)
@@ -238,6 +243,9 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
     set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} /wd4701")
 endif()
 
+set(CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS_DEBUG} -O0")
+set(CMAKE_C_FLAGS_Release   "${CMAKE_C_FLAGS_Release} -O2")
+
 if (NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"))
        check_c_source_compiles(
        [=[
index 15e325860b4d67ad9d60e377ae0f1fae978c3311..d452017026dc8cf7068f56a77409076919e47b7a 100644 (file)
@@ -52,8 +52,3 @@ target_link_libraries(
 
 endforeach(TESTNAME)
 
-# Make sure NDEBUG is always undefined for tests
-if (UNIX OR MINGW OR CYGWIN)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -UNDEBUG")
-endif()
-
index baa4e09457f74778e1b817327ffd54ae9c89148a..645b0ce805d6d204761c597e9c51fe103ff6758d 100644 (file)
@@ -2,7 +2,12 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
+#ifdef NDEBUG
+#undef NDEBUG
 #include <assert.h>
+#else
+#include <assert.h>
+#endif
 #include <errno.h>
 #include <time.h>
 
index 7891e219f62e0a42e2f1e327ad5ec8a6ce8e7c2d..9d4a54aa6298aaa8428bbcd59f515dcdc11168c7 100644 (file)
@@ -1,6 +1,11 @@
 #include "strerror_override.h"
 #include "strerror_override_private.h"
+#ifdef NDEBUG
+#undef NDEBUG
 #include <assert.h>
+#else
+#include <assert.h>
+#endif
 #include <stdio.h>
 #include <string.h>