diff --git a/CMakeLists.txt b/CMakeLists.txt index 19232a9920..39118e2543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,9 @@ option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON) option(TBB_FUZZ_TESTING "Enable fuzz testing" OFF) option(TBB_INSTALL "Enable installation" ON) +if(LINUX) +option(TBB_LINUX_SEPARATE_DBG "Enable separation of the debug symbols during the build" OFF) +endif() if(APPLE) option(TBB_BUILD_APPLE_FRAMEWORKS "Build as Apple Frameworks" OFF) endif() diff --git a/src/tbb/CMakeLists.txt b/src/tbb/CMakeLists.txt index b996c736a7..8c84a0b29b 100644 --- a/src/tbb/CMakeLists.txt +++ b/src/tbb/CMakeLists.txt @@ -126,6 +126,25 @@ target_link_libraries(tbb ${TBB_COMMON_LINK_LIBS} ) +# Strip debug symbols into a separate .dbg file +if(TBB_LINUX_SEPARATE_DBG) + if(NOT CMAKE_BUILD_TYPE STREQUAL "release") + find_program(OBJCOPY_COMMAND objcopy) + if(NOT OBJCOPY_COMMAND) + message(WARNING "objcopy command not found in the system") + else() + add_custom_command(TARGET tbb POST_BUILD + COMMAND objcopy --only-keep-debug $ $.dbg + COMMAND objcopy --strip-debug $ + COMMAND objcopy --add-gnu-debuglink=$.dbg $ + COMMENT "Creating and associating .dbg file with tbb" + ) + endif() + else() + message(WARNING " TBB_LINUX_SEPARATE_DBG flag is not used on release config") + endif() +endif() + if(TBB_BUILD_APPLE_FRAMEWORKS) set_target_properties(tbb PROPERTIES FRAMEWORK TRUE @@ -158,7 +177,13 @@ if (TBB_INSTALL) COMPONENT devel ) endif() - + if(TBB_LINUX_SEPARATE_DBG) + install(FILES + $.dbg + DESTINATION lib + COMPONENT devel + ) + endif() set(_tbb_pc_lib_name tbb) if (WIN32)