From 29f7c4c0d50c0128e4c7fb985919352280e2014e Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 8 Aug 2020 17:32:48 -0400
Subject: [PATCH] Use cmake flag to enable PIC on linux

---
 indra/llcommon/CMakeLists.txt                 | 20 +++----------------
 indra/media_plugins/cef/CMakeLists.txt        | 12 +----------
 indra/media_plugins/example/CMakeLists.txt    | 10 ++--------
 .../media_plugins/gstreamer010/CMakeLists.txt | 10 ++--------
 indra/media_plugins/libvlc/CMakeLists.txt     | 10 ++--------
 5 files changed, 10 insertions(+), 52 deletions(-)

diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index b1c49de9dcd..fc23da2b70b 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -265,23 +265,9 @@ endif (BUGSPLAT_DB)
 
 list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES})
 
-if(LLCOMMON_LINK_SHARED)
-  add_library (llcommon SHARED ${llcommon_SOURCE_FILES})
-  if(NOT ADDRESS_SIZE EQUAL 32)
-    if(WINDOWS)
-      ##add_definitions(/FIXED:NO)
-    else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
-      add_definitions(-fPIC)
-    endif(WINDOWS)
-  endif(NOT ADDRESS_SIZE EQUAL 32)
-  if(WINDOWS)
-    # always generate llcommon.pdb, even for "Release" builds
-    set_target_properties(llcommon PROPERTIES LINK_FLAGS "/DEBUG")
-  endif(WINDOWS)
-  ll_stage_sharedlib(llcommon)
-else(LLCOMMON_LINK_SHARED)
-    add_library (llcommon ${llcommon_SOURCE_FILES})
-endif(LLCOMMON_LINK_SHARED)
+add_library (llcommon ${llcommon_SOURCE_FILES})
+
+set_target_properties(llcommon PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
 
 target_link_libraries(
     llcommon
diff --git a/indra/media_plugins/cef/CMakeLists.txt b/indra/media_plugins/cef/CMakeLists.txt
index ce6278963db..375f3530640 100644
--- a/indra/media_plugins/cef/CMakeLists.txt
+++ b/indra/media_plugins/cef/CMakeLists.txt
@@ -34,14 +34,6 @@ include_directories(SYSTEM
 
 ### media_plugin_cef
 
-if(NOT ADDRESS_SIZE EQUAL 32)
-  if(WINDOWS)
-    ##add_definitions(/FIXED:NO)
-  else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
-    add_definitions(-fPIC)
-  endif(WINDOWS)
-endif(NOT ADDRESS_SIZE EQUAL 32)
-
 set(media_plugin_cef_SOURCE_FILES
     media_plugin_cef.cpp
     )
@@ -83,9 +75,7 @@ add_library(media_plugin_cef
     ${media_plugin_cef_SOURCE_FILES}
     )
 
-#add_dependencies(media_plugin_cef
-#  ${MEDIA_PLUGIN_BASE_LIBRARIES}
-#)
+set_target_properties(media_plugin_cef PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
 
 target_link_libraries(media_plugin_cef
   ${media_plugin_cef_LINK_LIBRARIES}
diff --git a/indra/media_plugins/example/CMakeLists.txt b/indra/media_plugins/example/CMakeLists.txt
index 305a38dcd54..2c3eed0ef52 100644
--- a/indra/media_plugins/example/CMakeLists.txt
+++ b/indra/media_plugins/example/CMakeLists.txt
@@ -32,14 +32,6 @@ include_directories(SYSTEM
 
 ### media_plugin_example
 
-if(NOT ADDRESS_SIZE EQUAL 32)
-  if(WINDOWS)
-    ##add_definitions(/FIXED:NO)
-  else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
-    add_definitions(-fPIC)
-  endif(WINDOWS)
-endif(NOT ADDRESS_SIZE EQUAL 32)
-
 set(media_plugin_example_SOURCE_FILES
     media_plugin_example.cpp
     )
@@ -49,6 +41,8 @@ add_library(media_plugin_example
     ${media_plugin_example_SOURCE_FILES}
     )
 
+set_target_properties(media_plugin_example PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+
 target_link_libraries(media_plugin_example
   ${LLPLUGIN_LIBRARIES}
   ${MEDIA_PLUGIN_BASE_LIBRARIES}
diff --git a/indra/media_plugins/gstreamer010/CMakeLists.txt b/indra/media_plugins/gstreamer010/CMakeLists.txt
index c6913e6c749..068e7fc291c 100644
--- a/indra/media_plugins/gstreamer010/CMakeLists.txt
+++ b/indra/media_plugins/gstreamer010/CMakeLists.txt
@@ -33,14 +33,6 @@ include_directories(SYSTEM
 
 ### media_plugin_gstreamer010
 
-if(NOT ADDRESS_SIZE EQUAL 32)
-  if(WINDOWS)
-    ##add_definitions(/FIXED:NO)
-  else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
-    add_definitions(-fPIC)
-  endif(WINDOWS)
-endif(NOT ADDRESS_SIZE EQUAL 32)
-
 set(media_plugin_gstreamer010_SOURCE_FILES
     media_plugin_gstreamer010.cpp
     llmediaimplgstreamer_syms.cpp
@@ -58,6 +50,8 @@ add_library(media_plugin_gstreamer010
     ${media_plugin_gstreamer010_SOURCE_FILES}
     )
 
+set_target_properties(media_plugin_gstreamer010 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+
 target_link_libraries(media_plugin_gstreamer010
   ${LLPLUGIN_LIBRARIES}
   ${MEDIA_PLUGIN_BASE_LIBRARIES}
diff --git a/indra/media_plugins/libvlc/CMakeLists.txt b/indra/media_plugins/libvlc/CMakeLists.txt
index 7fcb96f7566..16adac25a5f 100644
--- a/indra/media_plugins/libvlc/CMakeLists.txt
+++ b/indra/media_plugins/libvlc/CMakeLists.txt
@@ -33,14 +33,6 @@ include_directories(SYSTEM
 
 ### media_plugin_libvlc
 
-if(NOT ADDRESS_SIZE EQUAL 32)
-  if(WINDOWS)
-    ##add_definitions(/FIXED:NO)
-  else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
-    add_definitions(-fPIC)
-  endif(WINDOWS)
-endif(NOT ADDRESS_SIZE EQUAL 32)
-
 set(media_plugin_libvlc_SOURCE_FILES
     media_plugin_libvlc.cpp
     )
@@ -58,6 +50,8 @@ target_link_libraries(media_plugin_libvlc
   ${PLUGIN_API_WINDOWS_LIBRARIES}
 )
 
+set_target_properties(media_plugin_libvlc PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+
 if (WINDOWS)
   set_target_properties(
     media_plugin_libvlc
-- 
GitLab