Skip to content

Commit

Permalink
Merge branch 'oceanbase:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hnwyllmm authored Nov 8, 2024
2 parents d69f47b + 51825fc commit 11a55f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
29 changes: 16 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

# 设置默认构建类型为 Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type:Default is debug" FORCE)
endif()
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)

# 输出当前构建类型
message(STATUS "Using build type: ${CMAKE_BUILD_TYPE}")

OPTION(ENABLE_ASAN "Enable build with address sanitizer" ON)
OPTION(ENABLE_TSAN "Build with thread sanitizer" OFF)
OPTION(ENABLE_UBSAN "Build with undefined behavior sanitizer" OFF)
Expand Down Expand Up @@ -46,6 +55,12 @@ ENDIF(WIN32)
# This is for clangd plugin for vscode
# mute sign-compare error in lex/yacc
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -Wall -Werror -Wno-error=sign-compare")
IF ("${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "debug")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -DDEBUG -g -O0")
ELSEIF ("${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "release")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -g -O2")
ENDIF()

IF (ENABLE_NOPIE)
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -no-pie")
ADD_LINK_OPTIONS(-no-pie)
Expand All @@ -57,19 +72,6 @@ IF(USE_SIMD)
ADD_DEFINITIONS(-DUSE_SIMD)
ENDIF(USE_SIMD)

IF(DEBUG)
MESSAGE(STATUS "DEBUG has been set as TRUE ${DEBUG}")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG ")
ADD_DEFINITIONS(-DENABLE_DEBUG)
ELSEIF(NOT DEFINED ENV{DEBUG})
MESSAGE(STATUS "Disable debug")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O2 -g ")
ELSE()
MESSAGE(STATUS "Enable debug")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG")
ADD_DEFINITIONS(-DENABLE_DEBUG)
ENDIF(DEBUG)

IF (CONCURRENCY)
MESSAGE(STATUS "CONCURRENCY is ON")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -DCONCURRENCY")
Expand Down Expand Up @@ -164,6 +166,7 @@ ENDIF(WITH_UNIT_TESTS)

SET(CMAKE_CXX_FLAGS ${CMAKE_COMMON_FLAGS})
SET(CMAKE_C_FLAGS ${CMAKE_COMMON_FLAGS})

MESSAGE(STATUS "CMAKE_CXX_FLAGS is " ${CMAKE_CXX_FLAGS})

# ADD_SUBDIRECTORY(src bin) bin 为目标目录, 可以省略
Expand Down
27 changes: 12 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,20 @@ function do_clean
find . -maxdepth 1 -type d -name 'build_*' | xargs rm -rf
}

function build
{
set -- "${BUILD_ARGS[@]}"
case "x$1" in
xrelease)
do_build "$@" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEBUG=OFF
;;
xdebug)
do_build "$@" -DCMAKE_BUILD_TYPE=Debug -DDEBUG=ON
;;
*)
BUILD_ARGS=(debug "${BUILD_ARGS[@]}")
build
;;
esac
function build {
# 默认参数是 debug
if [ -z "${BUILD_ARGS[0]}" ]; then
set -- "debug" # 如果没有参数,则设置默认值
else
set -- "${BUILD_ARGS[@]}" # 否则使用 BUILD_ARGS 的第一个参数
fi
local build_type_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]') # 转换为小写
echo "Build type: $build_type_lower" # 输出构建类型

do_build "$build_type_lower" -DCMAKE_BUILD_TYPE="$build_type_lower" # 调用 do_build
}


function main
{
case "$1" in
Expand Down

0 comments on commit 11a55f7

Please sign in to comment.