Merge pull request #36 from floitschG/fpic
Add fPIC flag on x86_64 if the compiler supports it.
diff --git a/double-conversion/CMakeLists.txt b/double-conversion/CMakeLists.txt
index 4a87b3e..d8ec02a 100644
--- a/double-conversion/CMakeLists.txt
+++ b/double-conversion/CMakeLists.txt
@@ -1,4 +1,3 @@
-
set(headers
bignum.h
cached-powers.h
@@ -25,6 +24,14 @@
target_include_directories(double-conversion PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
+# Add fPIC on x86_64 when supported.
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-fPIC CXX_HAS_FPIC)
+
+if(CXX_HAS_FPIC AND CMAKE_SYSTEM_PROCESSOER STREQUAL "x86_64")
+ set_target_properties(double-conversion PROPERTIES COMPILE_FLAGS "-fPIC")
+endif()
+
#
# associates the list of headers with the library
# for the purposes of installation/import into other projects