From b824051adf246c6d5d30a1a5806dd7a194f23700 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@craftyjon.com>
Date: Mon, 3 Feb 2020 17:40:03 +0100
Subject: [PATCH] Ensure DEBUG is defined on all platforms for debug builds

---
 CMakeLists.txt | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e3553e3dd..a1f5960f72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,6 +170,10 @@ if( KICAD_USE_VALGRIND )
     add_definitions( -DKICAD_USE_VALGRIND )
 endif()
 
+# Ensure DEBUG is defined for all platforms in Debug builds
+# change to add_compile_definitions() after minimum required CMake version is 3.12
+set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG> )
+
 # CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
 # and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
 if( POLICY CMP0063 )
@@ -336,11 +340,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
     # but no information about local variables.
     # Level 3 includes full information, but binaries are much larger.
     if( BUILD_SMALL_DEBUG_FILES )
-        set( CMAKE_C_FLAGS_DEBUG   "-g1 -ggdb1 -DDEBUG" )
-        set( CMAKE_CXX_FLAGS_DEBUG "-g1 -ggdb1 -DDEBUG" )
+        set( CMAKE_C_FLAGS_DEBUG   "-g1 -ggdb1" )
+        set( CMAKE_CXX_FLAGS_DEBUG "-g1 -ggdb1" )
     else()
-        set( CMAKE_C_FLAGS_DEBUG   "-g3 -ggdb3 -DDEBUG" )
-        set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" )
+        set( CMAKE_C_FLAGS_DEBUG   "-g3 -ggdb3" )
+        set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3" )
     endif()
 
     if( KICAD_SANITIZE )