diff --git a/cmake/modules/CompilerFlags.cmake b/cmake/modules/CompilerFlags.cmake index 70c7f874982..41829d67f26 100644 --- a/cmake/modules/CompilerFlags.cmake +++ b/cmake/modules/CompilerFlags.cmake @@ -92,8 +92,12 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -fno-strict-aliasing -DNDEBUG -g") # Add linker flags to generate separate debug files - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -Wl,--build-id") - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} -Wl,--build-id") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -Wl,--build-id" + ) + set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} -Wl,--build-id" + ) else() # MSVC set(MINIMAL_BUILD ON) @@ -113,7 +117,9 @@ else() # MSVC # Ensure linker generates PDB files for MSVC set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG") + set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG" + ) set(CMAKE_C_FLAGS "${FALCOSECURITY_LIBS_COMMON_FLAGS}") set(CMAKE_CXX_FLAGS "${FALCOSECURITY_LIBS_COMMON_FLAGS}") diff --git a/userspace/falco/CMakeLists.txt b/userspace/falco/CMakeLists.txt index 7685b8b0f58..60cf976de35 100644 --- a/userspace/falco/CMakeLists.txt +++ b/userspace/falco/CMakeLists.txt @@ -197,10 +197,14 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo" AND NOT WIN32) find_program(OBJCOPY_EXECUTABLE NAMES objcopy) if(OBJCOPY_EXECUTABLE) - add_custom_command(TARGET falco POST_BUILD - COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug $ $.debug + add_custom_command( + TARGET falco + POST_BUILD + COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug $ + $.debug COMMAND ${OBJCOPY_EXECUTABLE} --strip-debug --strip-unneeded $ - COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=$.debug $ + COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=$.debug + $ COMMENT "Generating separate debug file for falco" ) else()