add an uninstall target (to be tested)
authorkoda
Thu, 29 Oct 2009 23:59:46 +0000
changeset 2593 dd995a9c8871
parent 2592 d86618629e20
child 2594 0047e16dbacb
add an uninstall target (to be tested) workaround for a bug with mac sdl_image
hedgewars/uStore.pas
tools/CMakeLists.txt
tools/cmake_uninstall.cmake.in
--- a/hedgewars/uStore.pas	Thu Oct 29 17:51:54 2009 +0000
+++ b/hedgewars/uStore.pas	Thu Oct 29 23:59:46 2009 +0000
@@ -262,6 +262,10 @@
     ai: TAmmoType;
     tmpsurf: PSDL_Surface;
     i: LongInt;
+{$IFDEF DARWIN}
+tmpP: PLongWordArray;
+tmpA, tmpR, tmpG, tmpB: LongWord;
+{$ENDIF}
 begin
 
 for fi:= Low(THWFont) to High(THWFont) do
@@ -298,6 +302,34 @@
 
 			if tmpsurf <> nil then
 				begin
+{$IFDEF DARWIN}   
+{* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868
+   remove this when it's fixed in upstream; it causes problems on ppc *}
+					tmpP := tmpsurf^.pixels;                                             
+					for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do 
+					begin
+						tmpA:= tmpP^[i] shr 24 and $FF;
+						tmpR:= tmpP^[i] shr 16 and $FF;
+						tmpG:= tmpP^[i] shr 8 and $FF;
+						tmpB:= tmpP^[i] and $FF;
+
+						if tmpA <> 0 then
+						begin
+						tmpR:= round(tmpR * 255/tmpA);
+						tmpG:= round(tmpG * 255/tmpA);
+						tmpB:= round(tmpB * 255/tmpA);
+						end;
+
+						if tmpR > 255 then tmpR:= 255;
+						if tmpG > 255 then tmpG:= 255;
+						if tmpB > 255 then tmpB:= 255;
+
+						tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; 
+
+						//AddFileLog(inttostr(tmpP^[i*128] shr 24) + ' | ' + inttostr(tmpP^[i*128] shr 16 and $FF) + ' | ' + inttostr(tmpP^[i*128] shr 8 and $FF)+ ' | ' + inttostr(tmpP^[i*128] and $FF));  
+				end;                                                   
+{$ENDIF}
+				
 				if imageWidth = 0 then imageWidth := tmpsurf^.w;
 				if imageHeight = 0 then imageHeight := tmpsurf^.h;
 				if Width = 0 then Width:= tmpsurf^.w;
--- a/tools/CMakeLists.txt	Thu Oct 29 17:51:54 2009 +0000
+++ b/tools/CMakeLists.txt	Thu Oct 29 23:59:46 2009 +0000
@@ -1,3 +1,13 @@
+if (NOT APPLE)
+CONFIGURE_FILE(
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+  IMMEDIATE @ONLY)
+
+ADD_CUSTOM_TARGET(uninstall
+  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+endif()
+
 if (APPLE AND BUNDLE)
 
 find_package(OGGVORBIS REQUIRED)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/cmake_uninstall.cmake.in	Thu Oct 29 23:59:46 2009 +0000
@@ -0,0 +1,22 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/../install_manifest.txt")
+  MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/../install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/../install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/../install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+  MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+  IF(EXISTS "$ENV{DESTDIR}${file}")
+    EXEC_PROGRAM(
+      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+      OUTPUT_VARIABLE rm_out
+      RETURN_VALUE rm_retval
+      )
+    IF(NOT "${rm_retval}" STREQUAL 0)
+      MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+    ENDIF(NOT "${rm_retval}" STREQUAL 0)
+  ELSE(EXISTS "$ENV{DESTDIR}${file}")
+    MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+  ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
+