--- a/CMakeLists.txt Sun Dec 20 20:35:15 2009 +0000
+++ b/CMakeLists.txt Thu Dec 24 02:02:12 2009 +0000
@@ -29,22 +29,29 @@
set(DATA_INSTALL_DIR "../Resources/")
set(target_dir ".")
+ #what system are we building for
+ set(minimum_macosx $ENV{MACOSX_DEPLOYMENT_TARGET})
+
#detect on which system are we
EXEC_PROGRAM("/usr/bin/sw_vers" OUTPUT_VARIABLE MACOSX_VERSION_TMP)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
STRING(REGEX REPLACE "([0-9][0-9].[0-9]+).[0-9]" "\\1" current_macosx_version ${MACOSX_VERSION_TMP})
- set(minimum_macosx $ENV{MACOSX_DEPLOYMENT_TARGET})
-
if(NOT minimum_macosx)
+ #if nothing is set, we build only for the current system
set(minimum_macosx ${current_macosx_version})
endif()
- #create universal binaries only when it's time to bundle the application
+ #create universal binaries only when it's time to bundle the application, also build server
IF(BUNDLE)
set(WITH_SERVER false)
if(current_macosx_version MATCHES "10.6")
- set(CMAKE_OSX_ARCHITECTURES "x86_64;i386") #;ppc7400
+ if(minimum_macosx MATCHES "10.6")
+ #prevent building ppc for 10.6
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
+ else()
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
+ endif()
else()
set(CMAKE_OSX_ARCHITECTURES "i386;ppc7400")
endif()
@@ -58,6 +65,8 @@
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${minimum_macosx}.sdk/")
endif()
+ set(pascal_compiler_flags_cmn "-k${PROJECT_BINARY_DIR}/bin/libSDLmain.a" "-k-macosx_version_min" "-k${minimum_macosx}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_compiler_flags_cmn})
+
else(APPLE)
set(target_dir "bin")
endif(APPLE)
@@ -89,7 +98,7 @@
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
-set(pascal_compiler_flags_cmn "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi")
+set(pascal_compiler_flags_cmn "-B" "-FE../bin" "-Cs2000000" "-vwi" ${pascal_compiler_flags_cmn})
if(LOWRES)
set(pascal_compiler_flags_cmn "-dLOWRES" ${pascal_compiler_flags_cmn})
add_definitions(-DLOWRES)
@@ -127,7 +136,6 @@
add_subdirectory(bin)
-#add_subdirectory(openalbridge)
add_subdirectory(QTfrontend)
add_subdirectory(hedgewars)
add_subdirectory(share)
--- a/hedgewars/CMakeLists.txt Sun Dec 20 20:35:15 2009 +0000
+++ b/hedgewars/CMakeLists.txt Thu Dec 24 02:02:12 2009 +0000
@@ -82,6 +82,7 @@
endif()
endif(APPLE)
+
#PASCAL DETECTION SECTION
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
@@ -94,7 +95,7 @@
if(fpc_ver LESS "020200")
message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
- elseif(APPLE AND i386_build AND fpc_ver LESS "020400")
+ elseif(APPLE AND x86_64_build AND fpc_ver LESS "020400")
message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications!")
endif()
else()
@@ -106,19 +107,6 @@
#DEPENDECIES AND EXECUTABLES SECTION
-IF(APPLE)
-#let's build sdlmain, which is absent from the framework
- find_package(SDL REQUIRED)
-
- set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
-
- set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
- include_directories(${SDL_INCLUDE_DIR})
- link_libraries(${SDL_LIBRARY})
-
- add_library (SDLmain STATIC SDLMain.m)
-ENDIF(APPLE)
-
IF(NOT APPLE)
#here is the standard command for any system
add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
@@ -128,6 +116,16 @@
DEPENDS ${engine_sources}
)
ELSE()
+ #let's build sdlmain, which is absent from the framework
+ find_package(SDL REQUIRED)
+
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
+ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+ include_directories(${SDL_INCLUDE_DIR})
+
+ add_library (SDLmain STATIC SDLMain.m)
+# set_target_properties(SDLmain PROPERTIES COMPILE_FLAGS "-mmacosx-version-min=${minimum_macosx} --sysroot=${CMAKE_OSX_SYSROOT} ")
+
#these are the dependencies for building a universal binary on Mac OS X
foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
--- a/hedgewars/SDLh.pas Sun Dec 20 20:35:15 2009 +0000
+++ b/hedgewars/SDLh.pas Thu Dec 24 02:02:12 2009 +0000
@@ -50,7 +50,6 @@
{$linkframework SDL_image}
{$linkframework SDL_ttf}
{$linkframework SDL_mixer}
- {$linklib SDLmain}
{$ENDIF}
{$ENDIF}
@@ -195,6 +194,10 @@
SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
+ {* SDL_image *}
+ IMG_INIT_JPG = $00000001;
+ IMG_INIT_PNG = $00000002;
+ IMG_INIT_TIF = $00000004;
/////////////////////////////////////////////////////////////////
/////////////////////// TYPE DEFINITIONS ///////////////////////
@@ -693,8 +696,10 @@
function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
(* SDL_image *)
+function IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
function IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
+procedure IMG_Quit; cdecl; external SDL_ImageLibName;
(* SDL_net *)
function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
--- a/hedgewars/hwengine.pas Sun Dec 20 20:35:15 2009 +0000
+++ b/hedgewars/hwengine.pas Thu Dec 24 02:02:12 2009 +0000
@@ -564,6 +564,10 @@
SDL_EnableUNICODE(1);
+WriteToConsole('Init SDL_image... ');
+SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
+WriteLnToConsole(msgOK);
+
WriteToConsole('Init SDL_ttf... ');
SDLTry(TTF_Init <> -1, true);
WriteLnToConsole(msgOK);
--- a/hedgewars/uStore.pas Sun Dec 20 20:35:15 2009 +0000
+++ b/hedgewars/uStore.pas Thu Dec 24 02:02:12 2009 +0000
@@ -267,6 +267,8 @@
i: LongInt;
begin
+AddProgress;
+
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
@@ -356,6 +358,8 @@
//SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
{$ENDIF}
AddProgress;
+
+IMG_Quit();
end;
procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);