Skip to content

Commit

Permalink
add cmake build_type support.
Browse files Browse the repository at this point in the history
such as DCMAKE_BUILD_TYPE=Debug.

Signed-off-by: clundro <859287553@qq.com>
  • Loading branch information
infdahai committed May 1, 2023
1 parent 2d17033 commit d1de1dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ option(PORTABLE "build a portable binary (disable arch-specific optimizations)"
# TODO: set ENABLE_NEW_ENCODING to ON when we are ready
option(ENABLE_NEW_ENCODING "enable new encoding (#1033) for storing 64bit size and expire time in milliseconds" OFF)

set(CMAKE_LINK_DEPENDS_NO_SHARED 1)

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
Expand Down Expand Up @@ -164,6 +166,12 @@ if ((PROJECT_VERSION STREQUAL "unstable") AND (GIT_SHA STREQUAL ""))
endif ()
configure_file(src/version.h.in ${PROJECT_BINARY_DIR}/version.h)

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
set (CMAKE_BUILD_TYPE "RelWithDebInfo")
message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}")
endif ()
message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")

Expand Down
2 changes: 1 addition & 1 deletion x.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def build(dir: str, jobs: Optional[int], ghproxy: bool, ninja: bool, unittest: b

makedirs(dir, exist_ok=True)

cmake_options = ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"]
cmake_options = []
if ghproxy:
cmake_options.append("-DDEPS_FETCH_PROXY=https://ghproxy.com/")
if ninja:
Expand Down

0 comments on commit d1de1dd

Please sign in to comment.