--- a/CMakeLists.txt Sat Oct 03 12:38:56 2009 +0000
+++ b/CMakeLists.txt Tue Oct 06 16:30:08 2009 +0000
@@ -20,14 +20,35 @@
set(DATA_INSTALL_DIR "../Resources/")
set(target_dir ".")
-if(CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc7400" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc7400;i386" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc;i386")
+if(UNIVERSAL)
+ set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
set(universal_build true)
message(STATUS "Building a Universal Application")
-endif()
+else(UNIVERSAL)
+ if(UNIVERSAL64)
+ set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400;x86_64")
+ set(universal_build true)
+ message(STATUS "Building a Universal 64 bits Application")
+ endif(UNIVERSAL64)
+endif(UNIVERSAL)
+
else(APPLE)
set(target_dir "bin")
endif(APPLE)
+
+if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release")
+ set(CMAKE_BUILD_TYPE "Release")
+ set(OPTIMIZATIONS true)
+ message(STATUS "Building Release")
+else()
+ set(CMAKE_BUILD_TYPE "Debug")
+ set(OPTIMIZATIONS false)
+ set(CMAKE_VERBOSE_MAKEFILE true)
+ message(STATUS "Building Debug")
+endif()
+
+
if(DEFINED DATA_INSTALL_DIR)
set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
else(DEFINED DATA_INSTALL_DIR)
@@ -49,6 +70,9 @@
set(CMAKE_C_FLAGS "-Wall -pipe")
set(CMAKE_C_FLAGS_RELEASE "-w -O2 -fomit-frame-pointer")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+if(APPLE AND NOT universal_build)
+ set(CMAKE_C_FLAGS_RELEASE "-sse2 ${CMAKE_C_FLAGS_RELEASE}")
+endif()
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
--- a/gameServer/CMakeLists.txt Sat Oct 03 12:38:56 2009 +0000
+++ b/gameServer/CMakeLists.txt Tue Oct 06 16:30:08 2009 +0000
@@ -33,20 +33,20 @@
-odir ${CMAKE_CURRENT_BINARY_DIR}
-hidir ${CMAKE_CURRENT_BINARY_DIR})
-if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release")
+if(OPTIMIZATIONS)
set(ghc_flags
-w
-O2
${ghc_flags}
)
-else()
+else(OPTIMIZATIONS)
set(ghc_flags
-Wall
-debug
-dcore-lint
${ghc_flags}
)
-endif()
+endif(OPTIMIZATIONS)
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}"
COMMAND "${ghc_executable}"
--- a/hedgewars/CCHandlers.inc Sat Oct 03 12:38:56 2009 +0000
+++ b/hedgewars/CCHandlers.inc Tue Oct 06 16:30:08 2009 +0000
@@ -473,11 +473,11 @@
TargetPoint.Y:= putY
end else
begin
- {$IFDEF SDL13}
+{$IFDEF SDL13}
SDL_GetMouseState(0, @TargetPoint.X, @TargetPoint.Y);
- {$ELSE}
+{$ELSE}
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
- {$ENDIF}
+{$ENDIF}
dec(TargetPoint.X, cScreenWidth div 2);
dec(TargetPoint.X, WorldDx);
dec(TargetPoint.Y, WorldDy)
--- a/hedgewars/CMakeLists.txt Sat Oct 03 12:38:56 2009 +0000
+++ b/hedgewars/CMakeLists.txt Tue Oct 06 16:30:08 2009 +0000
@@ -5,6 +5,8 @@
find_package(SDL_net REQUIRED)
find_package(SDL_ttf REQUIRED)
+
+#SOURCE AND PROGRAMS SECTION
set(fpc_tryexe fpc)
set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
@@ -68,6 +70,50 @@
set (noexecstack_flags "")
endif (${testnoexecstack})
+
+#PASCAL DETECTION SECTION
+string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
+
+if (fpc_version)
+ 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}")
+ 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()
+ set(pascal_compiler ${fpc_executable})
+ endif ()
+endif (fpc_version)
+
+if (NOT pascal_compiler)
+ message(FATAL_ERROR "No Pascal compiler found!")
+endif (NOT pascal_compiler)
+
+
+#PASCAL FLAG SECTION
+set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-fPIC" ${hwengine_project})
+
+if(OPTIMIZATIONS)
+ set(pascal_compiler_flags "-O2" "-Xs" "-Nu" ${pascal_compiler_flags})
+ if(APPLE AND NOT universal_build)
+ set(pascal_compiler_flags "-CfSSE2" ${pascal_compiler_flags}) #instruction set for ppc is 7400
+ endif()
+else(OPTIMIZATIONS)
+ set(pascal_compiler_flags "-O-" "-gl" "-dDEBUGFILE" "-pg" "-va" ${pascal_compiler_flags})
+endif(OPTIMIZATIONS)
+
+if(LOWRES)
+ set(pascal_compiler_flags "-dLOWRES" ${pascal_compiler_flags} ${hwengine_project})
+endif(LOWRES)
+
+#special handling of MSVC compiler (no static linking)
+if(MSVC)
+ set(pascal_compiler_flags "-dMSVC" ${pascal_compiler_flags})
+endif(MSVC)
+
+
+#DEPENDECIES AND EXECUTABLES SECTION
IF(APPLE)
#let's build sdlmain, which is absent from the framework
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
@@ -78,37 +124,6 @@
set(engine_sources SDLmain ${engine_sources})
ENDIF(APPLE)
-string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
-
-if (fpc_version)
- 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}")
- math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
- if (fpc_ver LESS "020200")
- message(STATUS "Minimum required version of FreePascal is 2.2.0")
- else (fpc_ver LESS "020200")
- set(pascal_compiler ${fpc_executable})
- if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release")
- set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O2" "-Xs" ${hwengine_project})
- else()
- set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O-" "-gl" "-dDEBUGFILE" ${hwengine_project})
- endif()
- if(LOWRES)
- set(pascal_compiler_flags "-dLOWRES" ${pascal_compiler_flags} ${hwengine_project})
- endif(LOWRES)
- endif (fpc_ver LESS "020200")
-endif (fpc_version)
-
-if (NOT pascal_compiler)
- message(FATAL_ERROR "No Pascal compiler found!")
-endif (NOT pascal_compiler)
-
-#special handling of MSVC compiler (no static linking)
-if(MSVC)
- set(pascal_compiler_flags "-dMSVC" ${pascal_compiler_flags})
-endif(MSVC)
-
IF(NOT APPLE OR NOT universal_build)
#here is the standard command for any system
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
@@ -121,7 +136,7 @@
#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
+ ARGS ${pascal_compiler_flags} -ohwengine.386 -CfSSE2
MAIN_DEPENDENCY ${hwengine_project}
DEPENDS openalbridge ${engine_sources}
)