From 2dc3b4d778360f6b4418c9933cf7e68b7ac71c38 Mon Sep 17 00:00:00 2001 From: Yuan Shuai Date: Thu, 10 Oct 2019 12:15:26 +0800 Subject: [PATCH] [CMAKE] Abandon strip when CMAKE_BUILD_TYPE=Debug (#2155) * [CMAKE] Abandon strip when CMAKE_BUILD_TYPE=Debug * Add CMAKE_BUILD_TYPE info in cmake. test=develop --- CMakeLists.txt | 1 + cmake/lite.cmake | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9834de8f96..fd846b19b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,7 @@ if(NOT CMAKE_BUILD_TYPE) "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE) endif() +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") # check options if (LITE_ON_TINY_PUBLISH) diff --git a/cmake/lite.cmake b/cmake/lite.cmake index e5253072f8..37fca1bfa1 100644 --- a/cmake/lite.cmake +++ b/cmake/lite.cmake @@ -167,10 +167,12 @@ function(lite_cc_binary TARGET) target_compile_options(${TARGET} BEFORE PRIVATE -Wno-ignored-qualifiers) if (NOT APPLE) # strip binary target to reduce size - add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND "${CMAKE_STRIP}" -s - "${TARGET}" - COMMENT "Strip debug symbols done on final executable file.") + if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND "${CMAKE_STRIP}" -s + "${TARGET}" + COMMENT "Strip debug symbols done on final executable file.") + endif() endif() # collect targets need to compile for lite if (NOT args_EXCLUDE_COMPILE_DEPS) @@ -215,10 +217,12 @@ function(lite_cc_test TARGET) ) _lite_cc_test(${TARGET} SRCS ${args_SRCS} DEPS ${deps} ARGS ${args_ARGS}) # strip binary target to reduce size - add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND "${CMAKE_STRIP}" -s - "${TARGET}" - COMMENT "Strip debug symbols done on final executable file.") + if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND "${CMAKE_STRIP}" -s + "${TARGET}" + COMMENT "Strip debug symbols done on final executable file.") + endif() target_compile_options(${TARGET} BEFORE PRIVATE -Wno-ignored-qualifiers) file(APPEND ${offline_test_registry_file} "${TARGET}\n") -- GitLab