Skip to content

Commit

Permalink
modify json-c default build type, and fix up the assert() errors in t…
Browse files Browse the repository at this point in the history
…estcase
  • Loading branch information
dota17 committed Feb 29, 2020
1 parent 30e00cf commit 2d44f86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
[=[
Expand Down
5 changes: 0 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

5 changes: 5 additions & 0 deletions tests/test_deep_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
5 changes: 5 additions & 0 deletions tests/test_json_pointer.c
Original file line number Diff line number Diff line change
@@ -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>

Expand Down

0 comments on commit 2d44f86

Please sign in to comment.