From 9a6fe2b8cdf529eaf2dbee8d8488d9f7a6a6810d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 28 Jul 2018 10:38:00 +0200 Subject: [PATCH] CMakeLists.txt: add a option (BUILD_SMALL_DEBUG_FILES, default off) to create smaller binaries in debug mode. It forces link option -g1 instead og -g3 which allows basic debug. This is especially useful on Mingw because binaries in debug build are very large: _pcbnew.kiface: 1.25 Gb, small file option: 65Mb --- CMakeLists.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce4fed4f86..e924359bb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,13 @@ include( GNUInstallDirs ) # Path to local CMake modules. set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules ) +# On Windows, binaries created by link option -g3 are very large (more than 1Gb for pcbnew, +# and more than 3Gb for the full kicad suite) +# This option create binaries using link option -g1 that create much smaller files, but +# there are less info in debug (but the file names and line numbers are available) +option( BUILD_SMALL_DEBUG_FILES "In debug build: create smaller binaries." OFF ) + + # # KiCad build options should be added below. # @@ -274,8 +281,18 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}" ) set( CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}" ) - set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" ) - set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" ) + # Link flags in Debug: -g1 and -ggdb1 or -g1 and -ggdb3 can be used. + # Level 1 produces minimal information, enough for making basic backtraces. + # This includes descriptions of functions and external variables, and line number tables, + # 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 -Wno-deprecated-declarations" ) + else() + set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" ) + set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" ) + endif() if( MINGW ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )