add a x86_64 mac target
authorkoda
Mon, 09 Nov 2009 22:56:29 +0000
changeset 2609 b67624c7d61e
parent 2608 cebfea02f8b5
child 2610 8c00c1ee6cac
add a x86_64 mac target
CMakeLists.txt
cmake_modules/FindOggVorbis.cmake
hedgewars/CMakeLists.txt
hedgewars/options.inc
hedgewars/uWorld.pas
share/Info.plist.in
--- 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})
--- a/cmake_modules/FindOggVorbis.cmake	Mon Nov 09 20:29:21 2009 +0000
+++ b/cmake_modules/FindOggVorbis.cmake	Mon Nov 09 22:56:29 2009 +0000
@@ -20,9 +20,9 @@
 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
 #  [koda] (for Hedgewars) added libraries with capital names for compatibility with Mac frameworks
 
-find_library(OGG_LIBRARY NAMES ogg Ogg)
-find_library(VORBIS_LIBRARY NAMES vorbis Vorbis)
-find_library(VORBISFILE_LIBRARY NAMES vorbisfile Vorbis)
+find_library(OGG_LIBRARY NAMES ogg)
+find_library(VORBIS_LIBRARY NAMES vorbis)
+find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
 
 if (OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    set(OGGVORBIS_FOUND TRUE)
--- a/hedgewars/CMakeLists.txt	Mon Nov 09 20:29:21 2009 +0000
+++ b/hedgewars/CMakeLists.txt	Mon Nov 09 22:56:29 2009 +0000
@@ -117,41 +117,60 @@
 	set(engine_sources SDLmain ${engine_sources})
 ENDIF(APPLE)
 
-IF(NOT APPLE OR NOT universal_build)
+IF(build_type MATCHES "standard")
 #here is the standard command for any system
-add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
+	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
 		COMMAND "${pascal_compiler}"
 		ARGS ${pascal_compiler_flags}
 		MAIN_DEPENDENCY ${hwengine_project}
 		DEPENDS ${engine_sources}
 		)
 ELSE()
-#these are the two dependencies for building a universal binary on Mac OS X
-add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
-		COMMAND "ppc386" 
-		ARGS ${pascal_compiler_flags} -ohwengine.386 -CfSSE2
+#these are the dependencies for building a universal binary on Mac OS X
+	find_program(pascal_x86 NAMES ppc386)
+	find_program(pascal_ppc NAMES ppcppc)
+
+	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
+		COMMAND "${pascal_x86}" 
+		ARGS ${pascal_compiler_flags} -ohwengine.386
 		MAIN_DEPENDENCY ${hwengine_project}
 		DEPENDS ${engine_sources}
 		)
-add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
+	add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
 
-add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
-		COMMAND "ppcppc"
+	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
+		COMMAND "${pascal_ppc}"
 		ARGS ${pascal_compiler_flags} -ohwengine.ppc
 		MAIN_DEPENDENCY ${hwengine_project}
 		DEPENDS ${engine_sources}
 		)
-add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
+	add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
+
+	IF(build_type MATCHES "universal64")
+		find_program(pascal_x64 NAMES ppcx64)
+		
+		add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64"
+			COMMAND "${pascal_x64}" 
+			ARGS ${pascal_compiler_flags} -ohwengine.x64
+			MAIN_DEPENDENCY ${hwengine_project}
+			DEPENDS ${engine_sources}
+			)
+		add_custom_target(hwengine.x64 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64")
 
-#this is the command that bundles the two executables into one
-add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
-		COMMAND "lipo"
-		ARGS ${EXECUTABLE_OUTPUT_PATH}/hwengine.386 ${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
-		DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
-		)
+		add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
+			COMMAND "lipo"
+			ARGS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
+			DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64"
+			)
+	else()
+		add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
+			COMMAND "lipo"
+			ARGS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
+			DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
+			)
+	endif()
 ENDIF()
 
-
 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
 
 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
--- a/hedgewars/options.inc	Mon Nov 09 20:29:21 2009 +0000
+++ b/hedgewars/options.inc	Mon Nov 09 22:56:29 2009 +0000
@@ -36,3 +36,4 @@
 {$IFDEF TOUCHINPUT}
   {$DEFINE SDL13}
 {$ENDIF}
+
--- a/hedgewars/uWorld.pas	Mon Nov 09 20:29:21 2009 +0000
+++ b/hedgewars/uWorld.pas	Mon Nov 09 22:56:29 2009 +0000
@@ -383,8 +383,8 @@
 				tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
 				for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
 					DrawSprite(sprPower,
-							hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
-							hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
+							hwRound(Gear^.X) + round(WorldDx + tdx * (24 + i * 2)) - 16,
+							hwRound(Gear^.Y) + round(WorldDy + tdy * (24 + i * 2)) - 12,
 							i)
 				end
 		end;
--- a/share/Info.plist.in	Mon Nov 09 20:29:21 2009 +0000
+++ b/share/Info.plist.in	Mon Nov 09 22:56:29 2009 +0000
@@ -25,7 +25,7 @@
 	<key>LSExecutableArchitectures</key>
    	<string>i386</string>
 	<key>LSMinimumSystemVersion</key>
-	<string>10.4.0</string>
+	<string>${minimum_os}</string>
 	<key>LSRequiresNativeExecution</key>
         <true/>
 	<key>SUPublicDSAKeyFile</key>