CMakeLists.txt
changeset 2609 b67624c7d61e
parent 2606 ed687a8d081f
child 2629 be70fd3458c0
--- a/CMakeLists.txt	Mon Nov 09 20:29:21 2009 +0000
+++ b/CMakeLists.txt	Mon Nov 09 22:56:29 2009 +0000
@@ -12,11 +12,11 @@
 set(CPACK_PACKAGE_VERSION_MINOR "9")
 set(CPACK_PACKAGE_VERSION_PATCH "13-dev")
 
+set(build_type "standard")
 
 if(APPLE)
 	set(CMAKE_FIND_FRAMEWORK "FIRST")
-	set(universal_build true)
-
+	
 	#paths for creating the bundle
 	set(bundle_name Hedgewars.app)
 	set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/) 
@@ -24,23 +24,32 @@
 	set(target_dir ".")
 	
 	#build architecture / os version
-	set(MacVersion $ENV{MACOSX_DEPLOYMENT_TARGET})
-	if(MacVersion MATCHES "10.4")
-		message(STATUS "Target: Mac OS X 10.4 i386/ppc")	
+	set(minimum_os $ENV{MACOSX_DEPLOYMENT_TARGET})
+	if(minimum_os MATCHES "10.4")
+		message(STATUS "Target: Mac OS X 10.4 i386")	
 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
-		set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")		
+		set(CMAKE_OSX_ARCHITECTURES "i386")
+		set(build_type "standard")
 	endif()
-	if(MacVersion MATCHES "10.5")
+	if(minimum_os MATCHES "10.5")
 		message(STATUS "Target: Mac OS X 10.5 i386/ppc")
 		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk/")
-		set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")		
+		set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
+		set(build_type "universal")
 	endif()
-	if(MacVersion MATCHES "10.6")
-		message(STATUS "Target: Mac OS X 10.6 i386/ppc/x86_64")	
-		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk/")	
-		set(CMAKE_OSX_ARCHITECTURES "i386;x86_64;ppc7400")
+	if(minimum_os MATCHES "10.6")
+		message(STATUS "Target: Mac OS X 10.6 i386/ppc/x86_64")
+		set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk/")
+		set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
+		set(build_type "universal64")
 	endif()
-	#else use the default sysroot with default archs
+	if(NOT minimum_os)
+	#use the default sysroot with default archs	
+		EXEC_PROGRAM(sw_vers OUTPUT_VARIABLE MACOSX_VERSION)
+		string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION "${MACOSX_VERSION}")
+		STRING(REGEX REPLACE "[0-9][0-9].([0-9]+).[0-9]" "\\1" MACOSX_VERSION ${MACOSX_VERSION})
+		set(minimum_os "10.${MACOSX_VERSION}")
+	endif()
 else(APPLE)
 	set(target_dir "bin")
 endif(APPLE)
@@ -77,7 +86,8 @@
 	if(APPLE AND NOT universal_build)
 		set(CMAKE_C_FLAGS_RELEASE "-fPIC -msse2 ${CMAKE_C_FLAGS_RELEASE}")
 		set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -msse2 ${CMAKE_CXX_FLAGS_RELEASE}")
-		set(pascal_compiler_flags_cmn "-fPIC" "-CfSSE2" ${pascal_compiler_flags_cmn}) #-CF7400 for ppc
+		set(pascal_compiler_flags_cmn "-fPIC" ${pascal_compiler_flags_cmn})
+		#-Cf7400 for ppc, -CfSSE2 for x86 (but none for x86_64)
 	endif()
 else(Optz)
 	set(pascal_compiler_flags_cmn "-O-" "-gl" "-dDEBUGFILE" "-pg" "-vv" ${pascal_compiler_flags_cmn})