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

Static gcc (#228)

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

Issue Number: close #222 

Problem:
gcc使用动态链接库,在复制observer到其它机器后,无法启动。

### What is changed and how it works?
使用gcc静态链接库
上级 5c3be1d5
...@@ -36,20 +36,20 @@ ENDIF(WIN32) ...@@ -36,20 +36,20 @@ ENDIF(WIN32)
# This is for clangd plugin for vscode # This is for clangd plugin for vscode
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -Wall -Werror") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -Wall -Werror")
IF(DEBUG) IF(DEBUG)
MESSAGE("DEBUG has been set as TRUE ${DEBUG}") MESSAGE(STATUS "DEBUG has been set as TRUE ${DEBUG}")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG ") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG ")
ADD_DEFINITIONS(-DENABLE_DEBUG) ADD_DEFINITIONS(-DENABLE_DEBUG)
ELSEIF(NOT DEFINED ENV{DEBUG}) ELSEIF(NOT DEFINED ENV{DEBUG})
MESSAGE("Disable debug") MESSAGE(STATUS "Disable debug")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O2 -g ") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O2 -g ")
ELSE() ELSE()
MESSAGE("Enable debug") MESSAGE(STATUS "Enable debug")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -O0 -g -DDEBUG")
ADD_DEFINITIONS(-DENABLE_DEBUG) ADD_DEFINITIONS(-DENABLE_DEBUG)
ENDIF(DEBUG) ENDIF(DEBUG)
IF (CONCURRENCY) IF (CONCURRENCY)
MESSAGE("CONCURRENCY is ON") MESSAGE(STATUS "CONCURRENCY is ON")
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -DCONCURRENCY") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -DCONCURRENCY")
ADD_DEFINITIONS(-DCONCURRENCY) ADD_DEFINITIONS(-DCONCURRENCY)
ENDIF (CONCURRENCY) ENDIF (CONCURRENCY)
...@@ -57,22 +57,29 @@ ENDIF (CONCURRENCY) ...@@ -57,22 +57,29 @@ ENDIF (CONCURRENCY)
SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fprofile-arcs -ftest-coverage") SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fprofile-arcs -ftest-coverage")
SET(CMAKE_CXX_FLAGS ${CMAKE_COMMON_FLAGS}) SET(CMAKE_CXX_FLAGS ${CMAKE_COMMON_FLAGS})
SET(CMAKE_C_FLAGS ${CMAKE_COMMON_FLAGS}) SET(CMAKE_C_FLAGS ${CMAKE_COMMON_FLAGS})
MESSAGE("CMAKE_CXX_FLAGS is " ${CMAKE_CXX_FLAGS}) MESSAGE(STATUS "CMAKE_CXX_FLAGS is " ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID is " ${CMAKE_CXX_COMPILER_ID})
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
ADD_LINK_OPTIONS(-static-libgcc -static-libstdc++)
ENDIF()
IF (ENABLE_ASAN) IF (ENABLE_ASAN)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
SET(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
ADD_LINK_OPTIONS(-static-libasan)
ENDIF()
ENDIF() ENDIF()
IF (CMAKE_INSTALL_PREFIX) IF (CMAKE_INSTALL_PREFIX)
MESSAGE("CMAKE_INSTALL_PREFIX has been set as " ${CMAKE_INSTALL_PREFIX} ) MESSAGE(STATUS "CMAKE_INSTALL_PREFIX has been set as " ${CMAKE_INSTALL_PREFIX} )
ELSEIF(DEFINED ENV{CMAKE_INSTALL_PREFIX}) ELSEIF(DEFINED ENV{CMAKE_INSTALL_PREFIX})
SET(CMAKE_INSTALL_PREFIX $ENV{CMAKE_INSTALL_PREFIX}) SET(CMAKE_INSTALL_PREFIX $ENV{CMAKE_INSTALL_PREFIX})
ELSE() ELSE()
SET(CMAKE_INSTALL_PREFIX /tmp/${PROJECT_NAME}) SET(CMAKE_INSTALL_PREFIX /tmp/${PROJECT_NAME})
ENDIF() ENDIF()
MESSAGE("Install target dir is " ${CMAKE_INSTALL_PREFIX}) MESSAGE(STATUS "Install target dir is " ${CMAKE_INSTALL_PREFIX})
IF (DEFINED ENV{LD_LIBRARY_PATH}) IF (DEFINED ENV{LD_LIBRARY_PATH})
SET(LD_LIBRARY_PATH_STR $ENV{LD_LIBRARY_PATH}) SET(LD_LIBRARY_PATH_STR $ENV{LD_LIBRARY_PATH})
......
...@@ -5,7 +5,7 @@ TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ...@@ -5,7 +5,7 @@ TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
BUILD_SH=$TOPDIR/build.sh BUILD_SH=$TOPDIR/build.sh
CMAKE_COMMAND="cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 --log-level=WARNING" CMAKE_COMMAND="cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 --log-level=STATUS"
ALL_ARGS=("$@") ALL_ARGS=("$@")
BUILD_ARGS=() BUILD_ARGS=()
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
假设系统上已经安装了make等编译工具。 假设系统上已经安装了make等编译工具。
MiniOB 需要使用: MiniOB 需要使用:
- cmake 版本 >= 3.10 - cmake 版本 >= 3.13
- gcc/clang gcc建议8.3以上,编译器需要支持c++20新标准 - gcc/clang gcc建议8.3以上,编译器需要支持c++20新标准
1. 环境初始化 1. 环境初始化
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册