Przeglądaj źródła

Merge pull request #335 from CIB/mingw

MinGW fix for linux cross-compilation
Ivan Safrin 12 lat temu
rodzic
commit
3a4bff747a

+ 100 - 0
CMake/PolycodeDependencies.cmake

@@ -0,0 +1,100 @@
+# Find the required dependency libraries to use the polycode static library.
+#
+# Required variables by this cmake file:
+# ${POLYCODE_CMAKE_DIR} points to the directory with all of polycode's cmake scripts(including this one)
+# ${POLYCODE_RELEASE_DIR} points to the directory where the binares are produced to(Polycode/Release/${SYSTEM_NAME}) by default
+#
+# Sets ${POLYCODE_DEPENDENCY_LIBS} to something you can pass to TARGET_LINK_LIBRARIES
+# It will use the "debug" and "optimized" cmake keywords, so it will not work for anything other than TARGET_LINK_LIBRARIES
+#
+#
+# Uses INCLUDE_DIRECTORIES AND LINK_DIRECTORIES to add the necessary directories for the given links/includes to work.
+
+
+INCLUDE(${POLYCODE_CMAKE_DIR}/PolycodeIncludes.cmake)
+INCLUDE(${POLYCODE_CMAKE_DIR}/FindBullet.cmake)
+
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Include
+		${POLYCODE_RELEASE_DIR}/Framework/Core/include
+        ${POLYCODE_RELEASE_DIR}/Framework/Modules/include
+        ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include
+        ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include/AL
+        ${PolycodeIDE_SOURCE_DIR}/include)
+
+LINK_DIRECTORIES(${POLYCODE_RELEASE_DIR}/Framework/Core/lib
+        ${POLYCODE_RELEASE_DIR}/Framework/Modules/lib
+        ${POLYCODE_RELEASE_DIR}/Framework/Bindings/Lua/Core/lib
+		${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/lib)
+
+
+IF(MSVC OR MINGW)
+	SET(POLYCODE_DEPENDENCY_LIBS 
+        PolycodeLua_d
+        Polycore_d
+        ${ZLIB_LIBRARIES}
+        ${LUA_LIBRARY}
+        ${OPENGL_LIBRARIES}
+        ${OPENAL_LIBRARY}
+        ${PNG_LIBRARIES}
+        ${FREETYPE_LIBRARIES}
+        ${PHYSFS_LIBRARY}
+        ${OGG_LIBRARY}
+        ${VORBIS_LIBRARY}
+        ${VORBISFILE_LIBRARY}
+        opengl32
+        glu32
+        winmm
+        ws2_32
+		Polycode2DPhysics
+		Polycode3DPhysics
+		PolycodeUI
+		optimized ${BOX2D_RELEASE_LIBRARY}
+		debug ${BOX2D_DEBUG_LIBRARY}
+        optimized ${LIBBULLETMULTITHREADED}
+        optimized ${LIBBULLETSOFTBODY}
+        optimized ${LIBBULLETDYNAMICS}
+        optimized ${LIBBULLETCOLLISION}
+        optimized ${LIBBULLETMATH}
+        debug ${LIBBULLETMULTITHREADED_DEBUG}
+        debug ${LIBBULLETSOFTBODY_DEBUG}
+        debug ${LIBBULLETDYNAMICS_DEBUG}
+        debug ${LIBBULLETCOLLISION_DEBUG}
+        debug ${LIBBULLETMATH_DEBUG})
+ELSEIF(APPLE)
+	# TODO: Add apple support
+ELSE(MSVC OR MINGW)
+	SET(POLYCODE_DEPENDENCY_LIBS 
+		rt
+		pthread
+		PolycodeLua_d
+		PolycodeUI_d
+		Polycore_d
+		${LUA_LIBRARY}
+		${FREETYPE_LIBRARIES}
+		${VORBISFILE_LIBRARY}
+		${VORBIS_LIBRARY}
+		${OGG_LIBRARY}
+		${OPENAL_LIBRARY}
+		${PHYSFS_LIBRARY}
+		${PNG_LIBRARIES}
+		${ZLIB_LIBRARY}
+		${OPENGL_LIBRARIES}
+		${SDL_LIBRARY}
+		dl
+		Polycode2DPhysics_d
+		Polycode3DPhysics_d
+		${BOX2D_RELEASE_LIBRARY}
+
+		optimized ${LIBBULLETMULTITHREADED}
+		optimized ${LIBBULLETSOFTBODY}
+		optimized ${LIBBULLETDYNAMICS}
+		optimized ${LIBBULLETCOLLISION}
+		optimized ${LIBBULLETMATH}
+
+		debug ${LIBBULLETMULTITHREADED_DEBUG}
+		debug ${LIBBULLETSOFTBODY_DEBUG}
+		debug ${LIBBULLETDYNAMICS_DEBUG}
+		debug ${LIBBULLETCOLLISION_DEBUG}
+		debug ${LIBBULLETMATH_DEBUG})
+ENDIF(MSVC OR MINGW)

+ 0 - 44
CMakeLists.txt

@@ -46,50 +46,6 @@ SET(CMAKE_PREFIX_PATH
     ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies
     ${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies)
 
-MESSAGE(DEBUG " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
-
-# If the following large ugly mess is not present, failures can occur with -G "Unix Makefiles".
-# Even WITH this, you may get "library not found" errors on mingw first run; if so just re-run.
-# FIXME: Shouldn't be necessary if FIND_LIBRARY were working on mingw.
-IF (MINGW)
-LINK_DIRECTORIES(${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/lib)
-LINK_DIRECTORIES(${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies/lib)
-SET(ZLIB_LIBRARY zlib)
-SET(ZLIB_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(OGG_LIBRARY libogg)
-SET(OGG_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(PNG_LIBRARY png)
-SET(PNG_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(PHYSFS_LIBRARY physfs)
-SET(PHYSFS_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(OPENAL_LIBRARY OpenAL32)
-SET(OPENAL_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include/AL)
-SET(FREETYPE_LIBRARY freetype)
-SET(FREETYPE_INCLUDE_DIRS ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(VORBIS_LIBRARY libvorbis)
-SET(VORBIS_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(VORBISFILE_LIBRARY libvorbisfile)
-SET(VORBISFILE_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(LUA_LIBRARY lua5.1)
-SET(LUA_LIBRARIES lua5.1)
-SET(LUA_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include/lua5.1)
-SET(BOX2D_RELEASE_LIBRARY Box2D)
-SET(BOX2D_DEBUG_LIBRARY Box2D)
-SET(BOX2D_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies/include)
-SET(ASSIMP_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/include)
-SET(BULLET_INCLUDE_DIR ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies/include/bullet)
-SET(LIBBULLETCOLLISION BulletCollision)
-SET(LIBBULLETDYNAMICS BulletDynamics)
-SET(LIBBULLETMATH LinearMath)
-SET(LIBBULLETMULTITHREADED BulletMultiThreaded)
-SET(LIBBULLETSOFTBODY BulletSoftBody)
-SET(LIBBULLETCOLLISION_DEBUG BulletCollision)
-SET(LIBBULLETDYNAMICS_DEBUG BulletDynamics)
-SET(LIBBULLETMATH_DEBUG LinearMath)
-SET(LIBBULLETMULTITHREADED_DEBUG BulletMultiThreaded)
-SET(LIBBULLETSOFTBODY_DEBUG BulletSoftBody)
-ENDIF()
-
 # Process subdirectories
 ADD_SUBDIRECTORY(Core/Contents)
 ADD_SUBDIRECTORY("Assets/Default asset pack")

+ 2 - 0
Core/Contents/Include/PolyGLHeaders.h

@@ -98,6 +98,8 @@ typedef GLEEPFNGLBINDATTRIBLOCATIONPROC PFNGLBINDATTRIBLOCATIONPROC;
 typedef GLEEPFNGLUNIFORM2FPROC PFNGLUNIFORM2FPROC;
 typedef GLEEPFNWGLSWAPINTERVALEXTPROC PFNWGLSWAPINTERVALEXTPROC;
 typedef GLEEPFNWGLGETSWAPINTERVALEXTPROC PFNWGLGETSWAPINTERVALEXTPROC;
+typedef GLEEPFNGLGETPROGRAMIVPROC PFNGLGETPROGRAMIVPROC;
+typedef GLEEPFNGLGETACTIVEUNIFORMPROC PFNGLGETACTIVEUNIFORMPROC;
 #endif
 
 #if defined(__APPLE__) && defined(__MACH__)

+ 2 - 2
Core/Contents/Include/PolyWinCore.h

@@ -31,9 +31,9 @@
 #include <winsock2.h>
 #include <windows.h>
 #include <windowsx.h>
-#include <WinUser.h>
+#include <winuser.h>
 
-#include <MMSystem.h>
+#include <mmsystem.h>
 #include <regstr.h>
 
 

+ 1 - 1
Core/Contents/Source/OSBasics.cpp

@@ -23,7 +23,7 @@
 #include "OSBasics.h"
 #ifdef _WINDOWS
 	#include <windows.h>
-	#include <Shellapi.h>
+	#include <shellapi.h>
 #else
 	#include <dirent.h>
 	#include <sys/types.h>

+ 9 - 5
Core/Contents/Source/PolyWinCore.cpp

@@ -34,11 +34,15 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <Shlobj.h>
-#include <Shellapi.h>
-#include <Commdlg.h>
-
-#if !defined(_MINGW)
+#include <shlobj.h>
+#include <shellapi.h>
+#include <commdlg.h>
+
+#if defined(_MINGW)
+#ifndef MAPVK_VSC_TO_VK_EX
+#define MAPVK_VSC_TO_VK_EX 3
+#endif
+#else
 PFNWGLSWAPINTERVALEXTPROC       wglSwapIntervalEXT = NULL;
 PFNWGLGETSWAPINTERVALEXTPROC    wglGetSwapIntervalEXT = NULL;
 #endif

+ 122 - 0
IDE/Contents/CMakeLists.txt

@@ -0,0 +1,122 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+PROJECT(PolycodeIDE)
+
+SET(POLYCODE_ROOT_DIR ${PolycodeIDE_SOURCE_DIR}/../../)
+SET(POLYCODE_RELEASE_DIR ${POLYCODE_ROOT_DIR}/Release/${CMAKE_SYSTEM_NAME})
+SET(POLYCODE_CMAKE_DIR ${POLYCODE_ROOT_DIR}/CMake)
+SET(CMAKE_INSTALL_PREFIX ${POLYCODE_RELEASE_DIR}/Standalone/)
+
+SET(CMAKE_PREFIX_PATH
+    ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies
+    ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies
+    ${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies)
+
+SET(CMAKE_DEBUG_POSTFIX "_d")
+SET(CMAKE_MODULE_PATH ${POLYCODE_ROOT_DIR}/CMake)
+INCLUDE(${POLYCODE_CMAKE_DIR}/PolycodeDependencies.cmake)
+
+IF(MSVC OR MINGW)
+	SET(MAIN_CPP ../Build/Windows/main.cpp)
+ELSEIF(APPLE)
+		MESSAGE("Target system not currently supported.")
+ELSE(MSVC OR MINGW)
+	SET(MAIN_CPP ../Build/Linux/main.cpp)
+ENDIF(MSVC OR MINGW)
+
+
+SET(PolycodeIDE_SRCS
+		${MAIN_CPP}
+		Source/ExampleBrowserWindow.cpp
+		Source/PolycodeProject.cpp
+		Source/ExportProjectWindow.cpp
+		Source/PolycodeProjectBrowser.cpp
+		Source/NewFileWindow.cpp
+		Source/PolycodeProjectEditor.cpp
+		Source/NewProjectWindow.cpp
+		Source/PolycodeProjectManager.cpp
+		Source/PolycodeClipboard.cpp
+		Source/PolycodeProps.cpp
+		Source/PolycodeConsole.cpp
+		Source/PolycodeRemoteDebugger.cpp
+		Source/PolycodeEditor.cpp
+		Source/PolycodeScreenEditor.cpp
+		Source/PolycodeEditorManager.cpp
+		Source/PolycodeSpriteEditor.cpp
+		Source/PolycodeFontEditor.cpp
+		Source/PolycodeTextEditor.cpp
+		Source/PolycodeFrame.cpp
+		Source/PolycodeToolLauncher.cpp
+		Source/PolycodeIDEApp.cpp
+		Source/SettingsWindow.cpp
+		Source/PolycodeImageEditor.cpp
+		Source/TextureBrowser.cpp
+		Source/PolycodeMaterialEditor.cpp
+		Source/ToolWindows.cpp
+)
+
+SET(PolycodeIDE_HDRS
+		Include/ExampleBrowserWindow.h
+		Include/PolycodeFrame.h
+		Include/PolycodeProps.h
+		Include/ExportProjectWindow.h
+		Include/PolycodeGlobals.h
+		Include/PolycodeRemoteDebugger.h
+		Include/NewFileWindow.h
+		Include/PolycodeIDEApp.h
+		Include/PolycodeScreenEditor.h
+		Include/NewProjectWindow.h
+		Include/PolycodeImageEditor.h
+		Include/PolycodeSpriteEditor.h
+		Include/PolycodeClipboard.h
+		Include/PolycodeMaterialEditor.h
+		Include/PolycodeTextEditor.h
+		Include/PolycodeConsole.h
+		Include/PolycodeProject.h
+		Include/PolycodeToolLauncher.h
+		Include/PolycodeEditor.h
+		Include/PolycodeProjectBrowser.h
+		Include/SettingsWindow.h
+		Include/PolycodeEditorManager.h
+		Include/PolycodeProjectEditor.h
+		Include/TextureBrowser.h
+		Include/PolycodeFontEditor.h
+		Include/PolycodeProjectManager.h
+		Include/ToolWindows.h
+
+)
+
+INSTALL(FILES ${POLYCODE_ROOT_DIR}/LICENSE.txt
+		DESTINATION ./)
+
+# WIN32 makes it build a GUI application on windows(no effect on other platforms)
+ADD_EXECUTABLE(PolycodeIDE WIN32 ${PolycodeIDE_SRCS} ${PolycodeIDE_HDRS})
+
+IF(MSVC OR MINGW)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies/bin/OpenAL32.dll DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/default.pak DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/hdr.pak DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/api.pak DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/UI.pak DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/Physics2D.pak DESTINATION bin)
+	INSTALL(FILES ${POLYCODE_RELEASE_DIR}/Framework/Player/Physics3D.pak DESTINATION bin)
+
+	TARGET_LINK_LIBRARIES(PolycodeIDE
+		${POLYCODE_DEPENDENCY_LIBS}
+     )
+
+ELSEIF(APPLE)
+		MESSAGE("Target system not currently supported.")
+ELSE(MSVC OR MINGW)
+	TARGET_LINK_LIBRARIES(PolycodeIDE
+		${POLYCODE_DEPENDENCY_LIBS}
+	)
+	
+	# Install resources etc. after the build is finished
+	ADD_CUSTOM_COMMAND(TARGET PolycodeIDE POST_BUILD 
+		COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Resources/ ${CMAKE_BINARY_DIR}
+		COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../Release/Linux/Framework/Core/Assets/default.pak ${CMAKE_BINARY_DIR}
+		COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/../../Release/Linux/Standalone ${CMAKE_BINARY_DIR}/Standalone
+	)
+
+ENDIF(MSVC OR MINGW)

+ 21 - 0
Toolchain-mingw32.cmake

@@ -0,0 +1,21 @@
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER i486-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER i486-mingw32-g++)
+SET(CMAKE_RC_COMPILER i486-mingw32-windres)
+
+# here is the target environment located
+SET(POLYCODE_DIRECTORY "/home/cib/projects/Polycode")
+SET(CMAKE_FIND_ROOT_PATH  /usr/i486-mingw32; ${POLYCODE_DIRECTORY}/Release/Windows/Framework/Core/Dependencies; ${POLYCODE_DIRECTORY}/Release/Windows/Framework/Tools/Dependencies; /home/cib/projects/Polycode/Release/Windows/Framework/Modules/Dependencies; )
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search 
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# Paste the below into the relevant cmake files.
+#set(CMAKE_CXX_FLAGS "-D_WINDOWS -D_MINGW -D_WIN32 -DWIN32 -D__MINGW__")