diff --git a/CMakeLists.txt b/CMakeLists.txt index 6acc8474..e45ed5af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,14 +64,26 @@ set(SDRPP_MODULE_CMAKE "${CMAKE_SOURCE_DIR}/sdrpp_module.cmake") set(SDRPP_CORE_ROOT "${CMAKE_SOURCE_DIR}/core/src/") # Compiler flags -if (MSVC) - set(SDRPP_COMPILER_ARGS /O2 /Ob2 /std:c++17 /EHsc) -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(SDRPP_COMPILER_ARGS -O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup) -else () - set(SDRPP_COMPILER_ARGS -O3 -std=c++17) -endif () -set(SDRPP_MODULE_COMPILER_ARGS ${SDRPP_COMPILER_ARGS}) +if (${CMAKE_BUILD_TYPE} MATCHES "Debug") + # Debug Flags + if (MSVC) + set(SDRPP_COMPILER_FLAGS /std:c++17 /EHsc) + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(SDRPP_COMPILER_FLAGS -g -Og -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup) + else () + set(SDRPP_COMPILER_FLAGS -g -Og -std=c++17) + endif () +else() + # Normal Flags + if (MSVC) + set(SDRPP_COMPILER_FLAGS /O2 /Ob2 /std:c++17 /EHsc) + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(SDRPP_COMPILER_FLAGS -O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup) + else () + set(SDRPP_COMPILER_FLAGS -O3 -std=c++17) + endif () +endif() +set(SDRPP_MODULE_COMPILER_FLAGS ${SDRPP_COMPILER_FLAGS}) # Set a default install prefix if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -254,7 +266,7 @@ add_executable(sdrpp "src/main.cpp" "win32/resources.rc") target_link_libraries(sdrpp PRIVATE sdrpp_core) # Compiler arguments -target_compile_options(sdrpp PRIVATE ${SDRPP_COMPILER_ARGS}) +target_compile_options(sdrpp PRIVATE ${SDRPP_COMPILER_FLAGS}) # Copy dynamic libs over if (MSVC) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 9e4d34b7..bcf0495a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -30,7 +30,7 @@ endif (OPT_BACKEND_ANDROID) add_library(sdrpp_core SHARED ${SRC} ${BACKEND_SRC}) # Set compiler options -target_compile_options(sdrpp_core PRIVATE ${SDRPP_COMPILER_ARGS}) +target_compile_options(sdrpp_core PRIVATE ${SDRPP_COMPILER_FLAGS}) # Set the install prefix target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")