From d833e45c28a5d3e3605b161a1b6bcf7c06093d25 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Wed, 16 Nov 2016 15:32:01 -0500
Subject: [PATCH] DRTVWR-418: Pass ADDRESS_SIZE down into C++ compilation by
 adding -DADDRESS_SIZE= to the compile switches.

Remove hack to work around limitations of gcc 4.1 build hosts.

Streamline a bit of logic to specify correct -m32 or -m64 switch.

Use ADDRESS_SIZE instead of ARCH to control -march=pentiumpro.
---
 indra/cmake/00-Common.cmake | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 4f335b50ec4..ec30db685dd 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -2,16 +2,28 @@
 #
 # Compilation options shared by all Second Life components.
 
+#*****************************************************************************
+#   It's important to realize that CMake implicitly concatenates
+#   CMAKE_CXX_FLAGS with (e.g.) CMAKE_CXX_FLAGS_RELEASE for Release builds. So
+#   set switches in CMAKE_CXX_FLAGS that should affect all builds, but in
+#   CMAKE_CXX_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELWITHDEBINFO for switches
+#   that should affect only that build variant.
+#
+#   Also realize that CMAKE_CXX_FLAGS may already be partially populated on
+#   entry to this file.
+#*****************************************************************************
+
 if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
 set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
 
 include(Variables)
 
 # Portable compilation flags.
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DADDRESS_SIZE=${ADDRESS_SIZE}")
+
 set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DLL_DEBUG=1")
 set(CMAKE_CXX_FLAGS_RELEASE
     "-DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -DNDEBUG") 
-
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO 
     "-DLL_RELEASE=1 -DNDEBUG -DLL_RELEASE_WITH_DEBUG_INFO=1")
 
@@ -138,13 +150,6 @@ if (LINUX)
   # Let's actually get a numerical version of gxx's version
   STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.([0-9]).*" "\\1\\2\\3" CXX_VERSION_NUMBER ${CXX_VERSION})
 
-  # Hacks to work around gcc 4.1 TC build pool machines which can't process pragma warning disables
-  # This is pure rubbish; I wish there was another way.
-  #
-  if(${CXX_VERSION_NUMBER} LESS 420)
-    set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-uninitialized -Wno-unused-variable -Wno-unused-function ${CMAKE_CXX_FLAGS}")
-  endif (${CXX_VERSION_NUMBER} LESS 420)
-
   if(${CXX_VERSION_NUMBER} GREATER 459)
     set(CMAKE_CXX_FLAGS "-Wno-deprecated -Wno-unused-but-set-variable -Wno-unused-variable ${CMAKE_CXX_FLAGS}")
   endif (${CXX_VERSION_NUMBER} GREATER 459)
@@ -231,22 +236,17 @@ if (LINUX OR DARWIN)
   set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
   set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
 
-  if (ADDRESS_SIZE EQUAL 32)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
-  elseif (ADDRESS_SIZE EQUAL 64)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
-  endif (ADDRESS_SIZE EQUAL 32)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m${ADDRESS_SIZE}")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m${ADDRESS_SIZE}")
 endif (LINUX OR DARWIN)
 
 
 if (USESYSTEMLIBS)
   add_definitions(-DLL_USESYSTEMLIBS=1)
 
-  if (LINUX AND ${ARCH} STREQUAL "i686")
+  if (LINUX AND ADDRESS_SIZE EQUAL 32)
     add_definitions(-march=pentiumpro)
-  endif (LINUX AND ${ARCH} STREQUAL "i686")
+  endif (LINUX AND ADDRESS_SIZE EQUAL 32)
 
 else (USESYSTEMLIBS)
   set(${ARCH}_linux_INCLUDES
-- 
GitLab