hedgewars/CMakeLists.txt
changeset 2641 b08cafb86797
parent 2629 be70fd3458c0
child 2644 52b7c4776af9
--- a/hedgewars/CMakeLists.txt	Tue Nov 24 20:40:08 2009 +0000
+++ b/hedgewars/CMakeLists.txt	Wed Nov 25 04:27:53 2009 +0000
@@ -63,12 +63,13 @@
 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
 
 exec_program(${fpc_executable} ${EXECUTABLE_OUTPUT_PATH}
-		ARGS ${noexecstack_flags} checkstack.pas
-		OUTPUT_VARIABLE noout
-		RETURN_VALUE testnoexecstack)
+	ARGS ${noexecstack_flags} checkstack.pas
+	OUTPUT_VARIABLE noout
+	RETURN_VALUE testnoexecstack
+	)
 
 if (${testnoexecstack})
-set (noexecstack_flags "")
+	set (noexecstack_flags "")
 endif (${testnoexecstack})
 
 
@@ -79,10 +80,14 @@
 	string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
 	string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
+	message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}")
 	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
 	if (fpc_ver LESS "020200")
 		message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
 	else()
+		if (APPLE AND build_64_universal AND fpc_ver LESS "020400")
+			message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications")
+		endif()
 		set(pascal_compiler ${fpc_executable})
 	endif ()
 endif (fpc_version)
@@ -107,9 +112,6 @@
 	set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
 	include_directories(${SDL_INCLUDE_DIR})
 	link_libraries(${SDL_LIBRARY})
-	
-	#apparently this variable is not exported here
-	set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")		
 
 	add_library (SDLmain STATIC SDLMain.m)
 	set(engine_sources SDLmain ${engine_sources})
@@ -125,50 +127,44 @@
 		)
 ELSE()
 #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)
+	set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
 
 	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
-		COMMAND "${pascal_x86}" 
-		ARGS ${pascal_compiler_flags} -ohwengine.386
+		COMMAND "${pascal_compiler}" 
+		ARGS ${pascal_compiler_flags} -ohwengine.386 -Pi386
 		MAIN_DEPENDENCY ${hwengine_project}
 		DEPENDS ${engine_sources}
 		)
 	add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
 
 	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc"
-		COMMAND "${pascal_ppc}"
-		ARGS ${pascal_compiler_flags} -ohwengine.ppc
+		COMMAND "${pascal_compiler}"
+		ARGS ${pascal_compiler_flags} -ohwengine.ppc -Ppowerpc
 		MAIN_DEPENDENCY ${hwengine_project}
 		DEPENDS ${engine_sources}
 		)
 	add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc")
 
-	IF(build_type MATCHES "universal64")
-		find_program(pascal_x64 NAMES ppcx64)
-		
+	IF(build_64_universal)
+		set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" ${lipo_args_list})
+	
 		add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64"
-			COMMAND "${pascal_x64}" 
-			ARGS ${pascal_compiler_flags} -ohwengine.x64
+			COMMAND "${pascal_compiler}" 
+			ARGS ${pascal_compiler_flags} -ohwengine.x64 -Px86_64
 			MAIN_DEPENDENCY ${hwengine_project}
 			DEPENDS ${engine_sources}
 			)
 		add_custom_target(hwengine.x64 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64")
+	ENDIF()
 
-		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()
+	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
+		COMMAND "lipo"
+		ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
+		DEPENDS ${lipo_args_list}
+		)
 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})