CMakeLists.txt: use CMAKE_POSITION_INDEPENDENT_CODE to set default only

This commit is contained in:
ds-sloth
2024-09-16 19:19:54 -04:00
parent 80d4c6215a
commit 0e44420380

View File

@@ -85,12 +85,14 @@ list(APPEND LZ4_CLI_SOURCES ${LZ4_SOURCES}) # LZ4_CLI always use liblz4 sources
# Whether to use position independent code for the static library. If
# we're building a shared library this is ignored and PIC is always
# used.
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON)
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE OR CMAKE_POSITION_INDEPENDENT_CODE)
set(LZ4_POSITION_INDEPENDENT_LIB_DEFAULT ON)
else()
set(LZ4_POSITION_INDEPENDENT_LIB OFF CACHE BOOL "Use position independent code for static library (if applicable)" FORCE)
set(LZ4_POSITION_INDEPENDENT_LIB_DEFAULT OFF)
endif()
option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ${LZ4_POSITION_INDEPENDENT_LIB_DEFAULT})
# liblz4
include(GNUInstallDirs)
set(LZ4_LIBRARIES_BUILT)