summaryrefslogtreecommitdiff
path: root/indra/cmake/Variables.cmake
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-11-16 15:27:36 -0500
committerNat Goodspeed <nat@lindenlab.com>2016-11-16 15:27:36 -0500
commit8c061ab184201df3afa4dbe690bb48621ae01ef1 (patch)
tree6d48564922825f9453edd5d8f8704ed12767f879 /indra/cmake/Variables.cmake
parent934b94e74a94f13521b67bdd016a5b591e16fe13 (diff)
DRTVWR-418: Compute ADDRESS_SIZE from arch if not specified.
Migrate the logic formerly used only for LINUX to detect whether ADDRESS_SIZE is set to 32 or 64, and if not, detect a default for the platform. But instead of using uname -m, use python's platform.machine(). On Windows, stop forcing ARCH to i686 and ADDRESS_SIZE to 32. On Mac, reset default to x86_64 instead of i386; stop forcing ADDRESS_SIZE to 32.
Diffstat (limited to 'indra/cmake/Variables.cmake')
-rw-r--r--indra/cmake/Variables.cmake60
1 files changed, 34 insertions, 26 deletions
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 464b4c402c..783d76e063 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -60,38 +60,47 @@ if (NOT CMAKE_BUILD_TYPE)
"Build type. One of: Debug Release RelWithDebInfo" FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+# If someone has specified an address size, use that to determine the
+# architecture. Otherwise, let the architecture specify the address size.
+if (ADDRESS_SIZE EQUAL 32)
+ #message(STATUS "ADDRESS_SIZE is 32")
+ set(ARCH i686)
+elseif (ADDRESS_SIZE EQUAL 64)
+ #message(STATUS "ADDRESS_SIZE is 64")
+ set(ARCH x86_64)
+else (ADDRESS_SIZE EQUAL 32)
+ #message(STATUS "ADDRESS_SIZE is UNRECOGNIZED: '${ADDRESS_SIZE}'")
+ # Use Python's platform.machine() since uname -m isn't available everywhere.
+ # Even if you can assume cygwin uname -m, the answer depends on whether
+ # you're running 32-bit cygwin or 64-bit cygwin! But even 32-bit Python will
+ # report a 64-bit processor.
+ execute_process(COMMAND
+ "${PYTHON_EXECUTABLE}" "-c"
+ "import platform; print platform.machine()"
+ OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
+ # We expect values of the form i386, i686, x86_64, AMD64.
+ # In CMake, expressing ARCH.endswith('64') is awkward:
+ string(LENGTH "${ARCH}" ARCH_LENGTH)
+ math(EXPR ARCH_LEN_2 "${ARCH_LENGTH} - 2")
+ string(SUBSTRING "${ARCH}" ${ARCH_LEN_2} 2 ARCH_LAST_2)
+ if (ARCH_LAST_2 STREQUAL 64)
+ #message(STATUS "ARCH is detected as 64; ARCH is ${ARCH}")
+ set(ADDRESS_SIZE 64)
+ else ()
+ #message(STATUS "ARCH is detected as 32; ARCH is ${ARCH}")
+ set(ADDRESS_SIZE 32)
+ endif ()
+endif (ADDRESS_SIZE EQUAL 32)
+
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS ON BOOL FORCE)
- set(ARCH i686)
set(LL_ARCH ${ARCH}_win32)
set(LL_ARCH_DIR ${ARCH}-win32)
- set(ADDRESS_SIZE 32)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX ON BOOl FORCE)
- # If someone has specified a word size, use that to determine the
- # architecture. Otherwise, let the architecture specify the word size.
- if (ADDRESS_SIZE EQUAL 32)
- #message(STATUS "ADDRESS_SIZE is 32")
- set(ARCH i686)
- elseif (ADDRESS_SIZE EQUAL 64)
- #message(STATUS "ADDRESS_SIZE is 64")
- set(ARCH x86_64)
- else (ADDRESS_SIZE EQUAL 32)
- #message(STATUS "ADDRESS_SIZE is UNDEFINED")
- execute_process(COMMAND uname -m COMMAND sed s/i.86/i686/
- OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (ARCH STREQUAL x86_64)
- #message(STATUS "ARCH is detected as 64; ARCH is ${ARCH}")
- set(ADDRESS_SIZE 64)
- else (ARCH STREQUAL x86_64)
- #message(STATUS "ARCH is detected as 32; ARCH is ${ARCH}")
- set(ADDRESS_SIZE 32)
- endif (ARCH STREQUAL x86_64)
- endif (ADDRESS_SIZE EQUAL 32)
-
if (ADDRESS_SIZE EQUAL 32)
set(DEB_ARCHITECTURE i386)
set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
@@ -143,15 +152,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym)
- # Build only for i386 by default, system default on MacOSX 10.6+ is x86_64
+ # Build only for x86_64 by default
if (NOT CMAKE_OSX_ARCHITECTURES)
- set(CMAKE_OSX_ARCHITECTURES "i386")
+ set(CMAKE_OSX_ARCHITECTURES "x86_64")
endif (NOT CMAKE_OSX_ARCHITECTURES)
set(ARCH ${CMAKE_OSX_ARCHITECTURES})
set(LL_ARCH ${ARCH}_darwin)
set(LL_ARCH_DIR universal-darwin)
- set(ADDRESS_SIZE 32)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Default deploy grid