Programming/Linux Programming

libfmt fPIC로 build 하기

Roiei 2022. 12. 27. 08:36
반응형

 

fmt/CMakeLists.txt에서 다음의 코드들을 추가합니다. 

 

 우선 가장 상단에 다음을 include 합니다.

include(CheckCXXCompilerFlag)

 

option을 추가합니다.

...
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF)
option(FMT_HAS_FPIC_FLAG "FPIC " ON)  <- 추가

 

target_compile_feature 직전에 아래의 코드를 추가합니다.

check_cxx_compiler_flag(-fPIC FMT_HAS_FPIC_FLAG)
if (FMT_HAS_FPIC_FLAG)
    target_compile_options(fmt PRIVATE -fPIC)
endif()

 

이제 다음과 같이 cmake를 진행합니다. (in fmt/build directory)

cmake ..  -D FMT_HAS_FPIC_FLAG=ON
반응형