diff --git a/CMakeLists.txt b/CMakeLists.txt index a086e85..661cd91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,13 @@ 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() + +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") + # Include file check macros honor CMAKE_REQUIRED_LIBRARIES # i.e. the check_include_file() calls will include -lm when checking. if(POLICY CMP0075) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 15e3258..d452017 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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() - diff --git a/tests/test_deep_copy.c b/tests/test_deep_copy.c index baa4e09..a913015 100644 --- a/tests/test_deep_copy.c +++ b/tests/test_deep_copy.c @@ -2,6 +2,9 @@ #include #include #include +#ifdef NDEBUG +#undef NDEBUG +#endif #include #include #include diff --git a/tests/test_json_pointer.c b/tests/test_json_pointer.c index 7891e21..f98a6a2 100644 --- a/tests/test_json_pointer.c +++ b/tests/test_json_pointer.c @@ -1,5 +1,8 @@ #include "strerror_override.h" #include "strerror_override_private.h" +#ifdef NDEBUG +#undef NDEBUG +#endif #include #include #include