Browse Source

Better handling of default values for CMAKE_OSX_ARCHITECTURES and allowing for override. Rather than the Xcode default of only building for the current platform, universal binaries are always built.

Use CMAKE_OSX_ARCHITECTURES environment variable to CMake to specify the archs to build, or -DBUILD_UNIVERSAL_BINARIES=OFF argument to cmake to use Xcode default values
David Wimsey 11 years ago
parent
commit
18731055ce
1 changed files with 23 additions and 27 deletions
  1. 23 27
      Build/CMakeLists.txt

+ 23 - 27
Build/CMakeLists.txt

@@ -2,12 +2,31 @@
 # Build script for libRocket =======
 #===================================
 
-# This has to be before most other options so CMake properly handles the 
-# compiler variables, it MUST bebefore the project() definition
 if(APPLE)
+	# This has to be before most other options so CMake properly handles the 
+	# compiler variables, it MUST bebefore the project() definition
 	if(IOS_PLATFORM)
 		set(CMAKE_TOOLCHAIN_FILE cmake/Platform/iOS.cmake)
 	endif(IOS_PLATFORM)
+
+	option(BUILD_UNIVERSAL_BINARIES "Build universal binaries for all architectures supported" ON)
+	if (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
+		if(IOS)
+			# set the architecture for iOS 
+			if (${IOS_PLATFORM} STREQUAL "OS")
+				set (IOS_ARCH armv6 armv7 armv7s arm64)
+				set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string  "Build architecture for iOS")
+			else (${IOS_PLATFORM} STREQUAL "OS")
+				set (IOS_ARCH i386 x86_64)
+				set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string  "Build architecture for iOS Simulator")
+			endif (${IOS_PLATFORM} STREQUAL "OS")
+
+		else(IOS)
+			# set the architectures for OS X
+			set (OSXI_ARCH i386 x86_64)
+			set (CMAKE_OSX_ARCHITECTURES ${OSXI_ARCH} CACHE string  "Build architecture for OS X universal binaries")		
+		endif(IOS)
+	endif (NOT CMAKE_OSX_ARCHITECTURES AND BUILD_UNIVERSAL_BINARIES)
 endif(APPLE)
 
 # We use the new OSX_ARCHITECTURES property
@@ -96,16 +115,17 @@ if(NOT CMAKE_BUILD_TYPE)
         FORCE)
 endif()
 
-option(ARCHS_OVERRIDE "Override default processor architecture targets.  Currently only supported on OS X or iOS, ignored on other systems." OFF)
 if(NOT IOS)
 	option(BUILD_SHARED_LIBS "Build shared libraries" ON)
 endif(NOT IOS)
 
 option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
 option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
+
 if(APPLE)
 	option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
 endif()
+
 option(BUILD_SAMPLES "Build samples" OFF)
 if(WIN32)
 	option(SKIP_DIRECTX_SAMPLES "Skip build of all DirectX related samples.  Only applies if BUILD_SAMPLES is ON" OFF)
@@ -118,30 +138,6 @@ if(APPLE)
 		if(BUILD_SHARED_LIBS)
 			message(FATAL_ERROR "BUILD_SHARED_LIBS must be OFF for iOS builds.  iOS does not support shared libraries.")
 		endif(BUILD_SHARED_LIBS)
-
-		# make doesn't deal with $() project variables, so we use ${} and let cmake handle it instead
-		if(ARCHS_OVERRIDE)
-				set(CMAKE_OSX_ARCHITECTURES "${ARCHS_OVERRIDE}")
-		else(ARCHS_OVERRIDE)
-			if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
-				set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD}")
-			else()
-				set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
-			endif()
-		endif(ARCHS_OVERRIDE)
-	else(IOS)
-		if(ARCHS_OVERRIDE)
-				set(CMAKE_OSX_ARCHITECTURES "${ARCHS_OVERRIDE}")
-		else(ARCHS_OVERRIDE)
-			if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
-				# ARCHS_STANDARD_32_64_BIT environment variable is no longer present in xcode 6 for Makefile builds, we pass our own values in its place
-				# you can also add ppc or ppc64 here for older PPC builds
-#				set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD_32_64_BIT}")
-				set(CMAKE_OSX_ARCHITECTURES "i386;x86_64;")
-			else()
-				set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
-			endif()
-		endif(ARCHS_OVERRIDE)
 	endif(IOS)
 
 	if(BUILD_FRAMEWORK)