summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorEvan Nemerson <evan@nemerson.com>2016-11-12 23:44:41 (GMT)
committerEvan Nemerson <evan@nemerson.com>2016-11-12 23:53:52 (GMT)
commitb6bcb84eae4b1df4e83329d09c5bed6abdaedc0a (patch)
tree25799b4cf2e52a509148d958e77035ed40a593a8 /contrib
parent94542d845884c922f809725807ecbd2cf7454ace (diff)
downloadlz4-b6bcb84eae4b1df4e83329d09c5bed6abdaedc0a.zip
lz4-b6bcb84eae4b1df4e83329d09c5bed6abdaedc0a.tar.gz
lz4-b6bcb84eae4b1df4e83329d09c5bed6abdaedc0a.tar.bz2
cmake: make PIC optional when generating a static library
See https://github.com/lz4/lz4/pull/260 for details. PIC is enabled by default; to disable it, define the LZ4_POSITION_INDEPENDENT_LIB variable to ON (cmake -DLZ4_POSITION_INDEPENDENT_LIB=ON ...).
Diffstat (limited to 'contrib')
-rw-r--r--contrib/cmake_unofficial/CMakeLists.txt12
1 files changed, 11 insertions, 1 deletions
diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt
index 9324338..01af33e 100644
--- a/contrib/cmake_unofficial/CMakeLists.txt
+++ b/contrib/cmake_unofficial/CMakeLists.txt
@@ -74,12 +74,22 @@ set(LZ4_CLI_SOURCES
"${LZ4_PROG_SOURCE_DIR}/lz4io.c"
"${LZ4_PROG_SOURCE_DIR}/datagen.c")
+# 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.
+option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON)
+if(LZ4_POSITION_INDEPENDENT_LIB OR BUILD_SHARED_LIBS)
+ set(LZ4_POSITION_INDEPENDENT_CODE TRUE)
+else()
+ set(LZ4_POSITION_INDEPENDENT_CODE FALSE)
+endif()
+
# liblz4
add_library(lz4 ${LZ4_SOURCES})
set_target_properties(lz4 PROPERTIES
SOVERSION "${LZ4_VERSION_STRING}"
VERSION "${LZ4_VERSION_STRING}"
- POSITION_INDEPENDENT_CODE TRUE)
+ POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_CODE})
# lz4
add_executable(lz4cli ${LZ4_CLI_SOURCES})