From 6a959dcc1aa4e4dc8f70ad74d9116c0b682454f5 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 7 Feb 2018 14:39:22 -0800 Subject: [PATCH] Use fPIC when building as a shared library Also include a note stating that the use of shared libraries is discouraged. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb9d538..5ad7f9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,13 @@ target_include_directories(cpu_features PRIVATE include/internal) target_compile_definitions(cpu_features PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024) target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS}) +# The use of shared libraries is discouraged. +# For API / ABI compatibility reasons, it is recommended to build and use +# cpu_features in a subdirectory of your project or as an embedded dependency. +if(BUILD_SHARED_LIBS) + set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() + # # program : list_cpu_features #