Skip to content

Commit 81de01c

Browse files
authored
Merge pull request #2475 from nigels-com/-fPIC
cmake: set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2 parents b605127 + 34f88d4 commit 81de01c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ option(SPDLOG_BUILD_SHARED "Build shared library" OFF)
6161
# precompiled headers option
6262
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" OFF)
6363

64+
# build position independent code
65+
option(SPDLOG_BUILD_PIC "Build position independent code (-fPIC)" OFF)
66+
6467
# example options
6568
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT})
6669
option(SPDLOG_BUILD_EXAMPLE_HO "Build header only example" OFF)
@@ -132,6 +135,10 @@ if(SPDLOG_TIDY)
132135
message(STATUS "Enabled clang-tidy")
133136
endif()
134137

138+
if(SPDLOG_BUILD_PIC)
139+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
140+
endif()
141+
135142
find_package(Threads REQUIRED)
136143
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
137144
# ---------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)