[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45895] trunk/blender: First MinGW-w64 support for cmake has been added.

Antony Riakiotakis kalast at gmail.com
Mon Apr 23 22:09:59 CEST 2012


Revision: 45895
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45895
Author:   psy-fi
Date:     2012-04-23 20:09:59 +0000 (Mon, 23 Apr 2012)
Log Message:
-----------
First MinGW-w64 support for cmake has been added. To test I recommend this build:

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/ray_linn/GCC-4.7.0-with-ada/mingw-w64-gcc-4.7.0-runtime-2.0.1-static-ada-20120330.7z/download

Other builds may also work but due to the constantly changing nature of the compiler this cannot be guaranteed. I often had to change compilers while building the libraries and this one is the one that did the job for most of them.

This first support is experimental and considered "advanced". To enable pass -DWITH_MINGW64 during cmake configuration. Also make sure to extract the compiler on C:/MinGW and that MinGW/bin is in your path. To build check out lib/mingw64.

Initially the support is lacking until I get every library compiled correctly. For now you should disable WITH_CYCLES(sorry, I know some people are dying to do benchmarks, but still a few libs to go), WITH_IMAGE_OPENEXR, WITH_OPENCOLLADA, WITH_LIBMV and WITH_CODEC_FFMPEG(links but hangs on startup).

Still the tools are working, the memory limit is increased and due to the experimental nature of the setup, full optimization with SSE2 is available, which makes the build quite fast. Also the compiler and especially, the linker are way faster than regular MinGW.

The wiki docs have also updated. Happy testing!

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    trunk/blender/intern/guardedalloc/MEM_sys_types.h
    trunk/blender/source/blender/blenkernel/BKE_armature.h
    trunk/blender/source/blender/blenlib/BLI_winstuff.h
    trunk/blender/source/blender/blenlib/intern/fileops.c
    trunk/blender/source/blender/blenloader/BLO_sys_types.h
    trunk/blender/source/creator/CMakeLists.txt
    trunk/blender/source/gameengine/Expressions/KX_HashedPtr.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_IPO_SGController.cpp

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/CMakeLists.txt	2012-04-23 20:09:59 UTC (rev 45895)
@@ -233,6 +233,8 @@
 	option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
 endif()
 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
+option(WITH_MINGW64                   "Use the 64-bit version of MinGW" OFF)
+mark_as_advanced(WITH_MINGW64)
 
 # Cycles
 option(WITH_CYCLES					"Enable cycles Render Engine" ON)
@@ -370,6 +372,10 @@
 		                    "because it is currently unsupported, remove this "
 		                    "line if youre a developer who wants to add support.")
 	endif()
+	
+	if((WITH_MINGW64) AND (WITH_IMAGE_OPENEXR OR WITH_CYCLES OR WITH_OPENCOLLADA OR WITH_LIBMV OR WITH_CODEC_FFMPEG))
+		message(FATAL_ERROR "MINGW64 still doesn't support: WITH_CYCLES/WITH_IMAGE_OPENEXR/WITH_OPENCOLLADA/WITH_LIBMV/WITH_CODEC_FFMPEG")
+	endif()
 endif()
 
 TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
@@ -737,6 +743,12 @@
 
 	if(CMAKE_COMPILER_IS_GNUCC)
 		set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
+
+		# Setup 64bit and 64bit windows systems		
+		if(WITH_MINGW64)
+			message("Set 64 bit compiler for MinGW.")
+			set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
+		endif()
 	else()
 		set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
 
@@ -995,12 +1007,19 @@
 		set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
 
 	elseif(CMAKE_COMPILER_IS_GNUCC)
-	# keep GCC specific stuff here
-		set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
-		
+	# keep GCC specific stuff here		
 		set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
 		set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
 
+		if(WITH_MINGW64)
+			#Yes, the point for MinGW64 is moar optimization by default :)
+			set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -msse -msse2 -O3")
+			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
+			set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lsetupapi -lpthread")
+			
+			add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
+		endif()
+
 		add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
 
 
@@ -1017,7 +1036,11 @@
 		set(PNG_INCLUDE_DIR "${PNG}/include")
 		set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
-		set(JPEG_LIBRARIES libjpeg)
+		if(WITH_MINGW64)
+			set(JPEG_LIBRARIES jpeg)
+		else()
+			set(JPEG_LIBRARIES libjpeg)
+		endif()
 		set(PNG_LIBRARIES png)
 
 		set(ZLIB ${LIBDIR}/zlib)
@@ -1025,11 +1048,14 @@
 		set(ZLIB_LIBPATH ${ZLIB}/lib)
 		set(ZLIB_LIBRARIES z)
 
-		set(PTHREADS ${LIBDIR}/pthreads)
-		set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
-		set(PTHREADS_LIBPATH ${PTHREADS}/lib)
-		set(PTHREADS_LIBRARIES pthreadGC2)
-
+		#comes with own pthread library
+		if(NOT WITH_MINGW64)
+			set(PTHREADS ${LIBDIR}/pthreads)
+			set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
+			set(PTHREADS_LIBPATH ${PTHREADS}/lib)
+			set(PTHREADS_LIBRARIES pthreadGC2)
+		endif()
+		
 		set(FREETYPE ${LIBDIR}/freetype)
 		set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
 		set(FREETYPE_LIBPATH ${FREETYPE}/lib)
@@ -1101,8 +1127,13 @@
 		if(WITH_BOOST)
 			set(BOOST ${LIBDIR}/boost)
 			set(BOOST_INCLUDE_DIR ${BOOST}/include)
-			set(BOOST_POSTFIX "mgw46-mt-s-1_47")
-			set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_47")
+			if(WITH_MINGW64)
+				set(BOOST_POSTFIX "mgw47-mt-s-1_49")
+				set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
+			else()
+				set(BOOST_POSTFIX "mgw46-mt-s-1_47")
+				set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_47")
+			endif()		
 			set(BOOST_LIBRARIES
 				optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
 				boost_regex-${BOOST_POSTFIX} boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2012-04-23 20:09:59 UTC (rev 45895)
@@ -815,9 +815,10 @@
 	// send motion. Mark as 'sent' so motion will always get dispatched.
 	eventSent = true;
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(FREE_WINDOWS64)
 	// using Microsoft compiler & header files
-	// they invented the RawInput API, so this version is (probably) correct
+	// they invented the RawInput API, so this version is (probably) correct.
+	// MinGW64 also works fine with this
 	BYTE const* data = raw.data.hid.bRawData;
 	// struct RAWHID {
 	// DWORD dwSizeHid;

Modified: trunk/blender/intern/guardedalloc/MEM_sys_types.h
===================================================================
--- trunk/blender/intern/guardedalloc/MEM_sys_types.h	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/intern/guardedalloc/MEM_sys_types.h	2012-04-23 20:09:59 UTC (rev 45895)
@@ -108,8 +108,10 @@
 #include <inttypes.h>
 
 #elif defined(FREE_WINDOWS)
+#ifndef FREE_WINDOWS64
 /* define htoln here, there must be a syntax error in winsock2.h in MinGW */
 unsigned long __attribute__((__stdcall__)) htonl(unsigned long);
+#endif
 #include <stdint.h>
 
 #else

Modified: trunk/blender/source/blender/blenkernel/BKE_armature.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-04-23 20:09:59 UTC (rev 45895)
@@ -89,7 +89,7 @@
 
 struct Bone *get_named_bone (struct bArmature *arm, const char *name);
 
-float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist);
+float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float r1, float r2, float rdist);
 
 void where_is_armature (struct bArmature *arm);
 void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone);

Modified: trunk/blender/source/blender/blenlib/BLI_winstuff.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_winstuff.h	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/blender/blenlib/BLI_winstuff.h	2012-04-23 20:09:59 UTC (rev 45895)
@@ -113,7 +113,9 @@
 /* python uses HAVE_SSIZE_T */
 #  ifndef HAVE_SSIZE_T
 #    define HAVE_SSIZE_T 1
+#    ifndef FREE_WINDOWS64
 typedef long ssize_t;
+#    endif
 #  endif
 #endif
 

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2012-04-23 20:09:59 UTC (rev 45895)
@@ -209,7 +209,7 @@
 	return ufopen(filename, mode);
 }
 
-gzFile BLI_gzopen(const char *filename, const char *mode)
+void *BLI_gzopen(const char *filename, const char *mode)
 {
 	gzFile gzfile;
 

Modified: trunk/blender/source/blender/blenloader/BLO_sys_types.h
===================================================================
--- trunk/blender/source/blender/blenloader/BLO_sys_types.h	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/blender/blenloader/BLO_sys_types.h	2012-04-23 20:09:59 UTC (rev 45895)
@@ -100,8 +100,10 @@
 #include <inttypes.h>
 
 #elif defined(FREE_WINDOWS)
+#ifndef FREE_WINDOWS64
 /* define htoln here, there must be a syntax error in winsock2.h in MinGW */
 unsigned long __attribute__((__stdcall__)) htonl(unsigned long);
+#endif
 #include <stdint.h>
 
 #else

Modified: trunk/blender/source/creator/CMakeLists.txt
===================================================================
--- trunk/blender/source/creator/CMakeLists.txt	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/creator/CMakeLists.txt	2012-04-23 20:09:59 UTC (rev 45895)
@@ -448,7 +448,7 @@
 		DESTINATION ${TARGETDIR}
 	)
 
-	if(WITH_INTERNATIONAL)
+	if(WITH_INTERNATIONAL AND (NOT WITH_MINGW64))
 		install(
 			FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
 			DESTINATION ${TARGETDIR}
@@ -523,11 +523,14 @@
 			DESTINATION ${TARGETDIR}
 		)
 	else()
-		install(
-			FILES
-				${LIBDIR}/zlib/lib/zlib.dll
-			DESTINATION ${TARGETDIR}
-		)
+		#not needed since we link statically, maybe also unneeded for MinGW?
+		if(NOT WITH_MINGW64)
+			install(
+				FILES
+					${LIBDIR}/zlib/lib/zlib.dll
+				DESTINATION ${TARGETDIR}
+			)
+		endif()
 	endif()
 
 	if(MSVC)
@@ -536,10 +539,13 @@
 			DESTINATION ${TARGETDIR}
 		)
 	else()
-		install(
-			FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
-			DESTINATION ${TARGETDIR}
-		)
+		#MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
+		if(NOT WITH_MINGW64)
+			install(
+				FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
+				DESTINATION ${TARGETDIR}
+			)
+		endif()
 	endif()
 
 	if(WITH_CODEC_FFMPEG)

Modified: trunk/blender/source/gameengine/Expressions/KX_HashedPtr.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/KX_HashedPtr.cpp	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/gameengine/Expressions/KX_HashedPtr.cpp	2012-04-23 20:09:59 UTC (rev 45895)
@@ -34,7 +34,7 @@
 
 unsigned int KX_Hash(void * inDWord)
 {
-#if defined(_WIN64)
+#if defined(_WIN64) && !defined(FREE_WINDOWS64)
 	unsigned __int64 key = (unsigned __int64)inDWord;
 #else
 	unsigned long key = (unsigned long)inDWord;

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-04-23 20:07:50 UTC (rev 45894)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-04-23 20:09:59 UTC (rev 45895)
@@ -31,7 +31,7 @@
  */
 
 
-#if defined(_WIN64)
+#if defined(_WIN64) && !defined(FREE_WINDOWS64)
 typedef unsigned __int64 uint_ptr;
 #else
 typedef unsigned long uint_ptr;

Modified: trunk/blender/source/gameengine/Ketsji/KX_IPO_SGController.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_IPO_SGController.cpp	2012-04-23 20:07:50 UTC (rev 45894)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list