From 8e68a63d7bc5376d486193e78a517f4b3af0cffd Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 5 Apr 2021 23:26:03 -0500 Subject: [PATCH] Set debug flags on non-Win32 according to CONFIG; add -g as well. --- CMakeLists.txt | 14 +++++++++----- src/CMakeLists.txt | 1 + src/libslic3r/CMakeLists.txt | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 239876188..2a061bf06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,15 @@ else() endif() endif() +if(NOT WIN32) + # Add DEBUG flags to debug builds. + # Also add -g to RELWITHDEBINFO on non-win32 + set(_CC_DEBUG_FLAGS $<$:-DwxDEBUG_LEVEL=1> + $<$:-g> + $<$:-g> + ) +endif() + option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL}) option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1) option(SLIC3R_FHS "Assume Slic3r is to be installed in a FHS directory structure" 0) @@ -113,11 +122,6 @@ enable_testing () set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(NOT WIN32) - # Add DEBUG flags to debug builds. - add_compile_options("$<$:-DDEBUG>") -endif() - # To be able to link libslic3r with the Perl XS module. # Once we get rid of Perl and libslic3r is linked statically, we can get rid of -fPIC set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cbd3da2c8..d3101be35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,6 +99,7 @@ if (WIN32) add_library(Slic3r SHARED PrusaSlicer.cpp PrusaSlicer.hpp) else () add_executable(Slic3r PrusaSlicer.cpp PrusaSlicer.hpp) + target_compile_options(Slic3r PRIVATE ${_CC_DEBUG_FLAGS}) endif () if (MINGW) diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 45d9cfa8a..cd329c334 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -1,6 +1,11 @@ project(libslic3r) cmake_minimum_required(VERSION 3.13) +if(NOT WIN32) + # Add DEBUG flags to debug builds. + add_compile_options(${_CC_DEBUG_FLAGS}) +endif() + include(PrecompiledHeader) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libslic3r_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h @ONLY)