From deb52841381fdfa7d73b1855dd36798fbbe7a8bf Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 18 Nov 2014 12:14:46 -0800 Subject: [PATCH] Make build work on OS X with older cmake versions. `uname -p` is still i386 on OS X for some reason, which causes cmake 2.8 to set CMAKE_SYSTEM_PROCESSOR to i386, making the build think it's doing a 32-bit build. However, since the system is almost completely 64-bit these days, clang defaults to producing 64-bit object files unless told otherwise. As a result, the produced .o files are all 64-bit except for the .o files from assembly, and then linking fails. Fix this by forcing ARCH to 64-bit on OS X. This matches the default behavior of cmake 3.0, where CMAKE_SYSTEM_PROCESSOR is x86_64. Change-Id: I7a2abc4cef84dfbaf205852a9d7b647e83dd249f Reviewed-on: https://boringssl-review.googlesource.com/2330 Reviewed-by: Adam Langley Reviewed-by: Piotr Sikora --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdfaee444..d4c7a6ec5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ else() message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR}) endif() +if (${ARCH} STREQUAL "x86" AND APPLE) + # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X, + # but clang defaults to 64-bit builds on OS X unless otherwise told. + # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3. + set(ARCH "x86_64") +endif() + add_subdirectory(crypto) add_subdirectory(ssl) add_subdirectory(ssl/test)