Added proper cmake debug support

This commit is contained in:
AlexandreRouma 2023-02-15 20:37:13 +01:00
parent 570b8dbd7c
commit 8f972ee0b2
2 changed files with 22 additions and 10 deletions

View File

@ -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 (${CMAKE_BUILD_TYPE} MATCHES "Debug")
# Debug Flags
if (MSVC)
set(SDRPP_COMPILER_ARGS /O2 /Ob2 /std:c++17 /EHsc)
set(SDRPP_COMPILER_FLAGS /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)
set(SDRPP_COMPILER_FLAGS -g -Og -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup)
else ()
set(SDRPP_COMPILER_ARGS -O3 -std=c++17)
set(SDRPP_COMPILER_FLAGS -g -Og -std=c++17)
endif ()
set(SDRPP_MODULE_COMPILER_ARGS ${SDRPP_COMPILER_ARGS})
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)

View File

@ -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}")