aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Karpey <paunia@protonmail.com>2020-03-12 01:54:42 +0500
committerGitHub <noreply@github.com>2020-03-11 21:54:42 +0100
commiteb168a2da2e14a85834b98c3961eee909dc618f9 (patch)
tree45231abdd242b0a3a2df179f3e832e30e93d902a
parenta83f9d88cd37af7065d8e3e1a48c77a9e54cca22 (diff)
downloadplatform_external_cpu_features-eb168a2da2e14a85834b98c3961eee909dc618f9.tar.gz
platform_external_cpu_features-eb168a2da2e14a85834b98c3961eee909dc618f9.tar.bz2
platform_external_cpu_features-eb168a2da2e14a85834b98c3961eee909dc618f9.zip
Fix shared build (#113)
* Fix PIC property in util library. * Force PIC when building shared lib on unix. * Enable CMP0077 for better option handling.
-rw-r--r--CMakeLists.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index daf21ae..2c52e77 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.0)
+# option() honors normal variables.
+# see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html
+if(POLICY CMP0077)
+ cmake_policy(SET CMP0077 NEW)
+endif()
+
project(CpuFeatures VERSION 0.1.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
@@ -23,6 +29,12 @@ option(BUILD_SHARED_LIBS "Build library as shared." OFF)
# PIC
option(BUILD_PIC "Build with Position Independant Code." OFF) # Default is off at least for GCC
+# Force PIC on unix when building shared libs
+# see: https://en.wikipedia.org/wiki/Position-independent_code
+if(BUILD_SHARED_LIBS AND UNIX)
+ set(BUILD_PIC ON)
+endif()
+
include(CheckIncludeFile)
include(CheckSymbolExists)
include(GNUInstallDirs)
@@ -92,6 +104,7 @@ add_library(utils OBJECT
${PROJECT_SOURCE_DIR}/src/stack_line_reader.c
${PROJECT_SOURCE_DIR}/src/string_view.c
)
+set_property(TARGET utils PROPERTY POSITION_INDEPENDENT_CODE ${BUILD_PIC})
setup_include_and_definitions(utils)
#