Skip to content

Commit 8c58c4c

Browse files
committed
Set '-fPIC' the correct way
1 parent b20d615 commit 8c58c4c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
1717

1818
include(SwiftSupport)
1919

20-
# Fixes error: "requires dynamic R_X86_64_PC32 reloc against 'XXX' which may overflow at runtime"
21-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
22-
2320
if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows)
2421
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2522
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -34,6 +31,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Darwin)
3431
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
3532
endif()
3633

34+
if(BUILD_SHARED_LIBS)
35+
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
36+
endif()
37+
3738
if(APPLE)
3839
find_library(CRYPTO_KIT CryptoKit)
3940
if(NOT CRYPTO_KIT)

0 commit comments

Comments
 (0)