未验证 提交 2fedf8b4 编写于 作者: 羽飞's avatar 羽飞 提交者: GitHub

add static_stdlib option as there is no static gcc library on rockylinux (#248)

### What problem were solved in this pull request?

Issue Number: close #247 

Problem:
Compile miniob with static gcc and g++ failed while there is no static
gcc library on rockylinux.

### What is changed and how it works?
Add cmake option static_stdlib with default value off.
In normal case, we compile miniob and run/debug it on the same machine,
so dynamic linking works fun. If we want to move observer binary to
other machine and test, we can recompile miniob with static_stdlib ON.
上级 89239176
...@@ -13,6 +13,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) ...@@ -13,6 +13,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
OPTION(ENABLE_ASAN "Enable build with address sanitizer" ON) OPTION(ENABLE_ASAN "Enable build with address sanitizer" ON)
OPTION(WITH_UNIT_TESTS "Compile miniob with unit tests" ON) OPTION(WITH_UNIT_TESTS "Compile miniob with unit tests" ON)
OPTION(CONCURRENCY "Support concurrency operations" OFF) OPTION(CONCURRENCY "Support concurrency operations" OFF)
OPTION(STATIC_STDLIB "Link std library static or dynamic, such as libgcc, libstdc++, libasan" OFF)
MESSAGE(STATUS "HOME dir: $ENV{HOME}") MESSAGE(STATUS "HOME dir: $ENV{HOME}")
#SET(ENV{变量名} 值) #SET(ENV{变量名} 值)
...@@ -55,13 +56,13 @@ IF (CONCURRENCY) ...@@ -55,13 +56,13 @@ IF (CONCURRENCY)
ENDIF (CONCURRENCY) ENDIF (CONCURRENCY)
MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID is " ${CMAKE_CXX_COMPILER_ID}) MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID is " ${CMAKE_CXX_COMPILER_ID})
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${STATIC_STDLIB})
ADD_LINK_OPTIONS(-static-libgcc -static-libstdc++) ADD_LINK_OPTIONS(-static-libgcc -static-libstdc++)
ENDIF() ENDIF()
IF (ENABLE_ASAN) IF (ENABLE_ASAN)
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fno-omit-frame-pointer -fsanitize=address") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${STATIC_STDLIB})
ADD_LINK_OPTIONS(-static-libasan) ADD_LINK_OPTIONS(-static-libasan)
ENDIF() ENDIF()
ENDIF() ENDIF()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册