From 7811ecc7cc29e65233e0845f9a385c55c0efb065 Mon Sep 17 00:00:00 2001 From: zhangyi1357 <34409786+zhangyi1357@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:58:36 +0800 Subject: [PATCH] build: enable position-independent code (#43) Set CMAKE_POSITION_INDEPENDENT_CODE to ON to ensure compatibility with shared libraries and enhance portability across different architectures. Removed explicit compiler flags for PIC that were previously set. --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99e11cd27..6be31e9d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,9 +79,6 @@ if(AIMRT_MASTER_PROJECT) set(BUILD_SHARED_LIBS OFF) if(UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - if(AIMRT_BUILD_TESTS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") @@ -91,6 +88,8 @@ if(AIMRT_MASTER_PROJECT) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if(MSVC) add_compile_options(/utf-8 /wd4819) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")