Mingw64 build fixes

Armin Burgmeier 2010-04-18 22:02:01 +02:00
parent 3bb1d8198d
commit 70ac17c040
12 changed files with 49 additions and 24 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 2.8.1)
project (clonk CXX C)
set(CMAKE_ADDITIONAL_DEPS_PATH deps CACHE PATH "Additional directory to search for libraries and headers")
@ -28,6 +28,8 @@ if(WIN32)
else()
list(APPEND CMAKE_LIBRARY_PATH $ENV{DXSDK_DIR}/Lib/x86)
endif()
else()
endif()
else()
SET(USE_DIRECTX OFF)
@ -713,6 +715,8 @@ macro(FINDLIB lib)
endmacro(FINDLIB)
# isilkor 09-05-29: Don't use FindOpenSSL, because that wants to link to ssleay
FINDLIB(OPENSSL_LIBRARIES NAMES crypto libeay32)
include(FindOpenSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
############################################################################
# Precompiled header support, part 1 (pre-target)
@ -822,18 +826,26 @@ endforeach()
if(USE_GL)
include(FindOpenGL)
FINDLIB(GLEW_LIBRARIES NAMES GLEW glew32 glew32s)
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h)
target_link_libraries(clonk
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
)
include_directories(${GLEW_INCLUDE_DIR})
endif()
if(USE_DIRECTX)
FINDLIB(DIRECT3D_LIBRARIES d3d9)
FINDLIB(DIRECT3DX_LIBRARIES d3dx9)
FIND_PATH(DIRECT3D_INCLUDE_DIR NAMES d3d9.h)
FIND_PATH(DIRECT3DX_INCLUDE_DIR NAMES d3dx9.h)
target_link_libraries(clonk
${DIRECT3D_LIBRARIES}
${DIRECT3DX_LIBRARIES}
)
include_directories(
${DIRECT3D_INCLUDE_DIR}
${DIRECT3DX_INCLUDE_DIR}
)
endif()
if(USE_GTK)
include(FindPkgConfig)
@ -865,7 +877,16 @@ endif()
if (WIN32)
# CMake is too incompetent to check whether these libraries can be linked to
# So just pretend that everything is fine
target_link_libraries(clonk vfw32 ws2_32 winmm)
FINDLIB(VFW32_LIBRARIES vfw32)
if (VFW32_LIBRARIES)
target_link_libraries(clonk vfw32)
else()
# Mingw64 has the AviStream* and _DrawDibDraw* symbols in
# other library files
target_link_libraries(clonk wavifil32 msvfw32)
endif()
target_link_libraries(clonk ws2_32 winmm)
target_link_libraries(c4group ws2_32)
if(MSVC_VERSION)

View File

@ -1250,7 +1250,7 @@ C4Object* C4Game::FindObject(C4ID id,
// ActionTarget
if (!pActionTarget || (pActionDef && ((cObj->Action.Target==pActionTarget) || (cObj->Action.Target2==pActionTarget)) ))
// Container
if ( !pContainer || (cObj->Contained == pContainer) || ((reinterpret_cast<long>(pContainer)==NO_CONTAINER) && !cObj->Contained) || ((reinterpret_cast<long>(pContainer)==ANY_CONTAINER) && cObj->Contained) )
if ( !pContainer || (cObj->Contained == pContainer) || ((reinterpret_cast<intptr_t>(pContainer)==NO_CONTAINER) && !cObj->Contained) || ((reinterpret_cast<intptr_t>(pContainer)==ANY_CONTAINER) && cObj->Contained) )
// Owner
if ((iOwner==ANY_OWNER) || (cObj->Owner==iOwner))
// Area

View File

@ -1548,7 +1548,7 @@ void C4Console::UpdateNetMenu()
ClearNetMenu();
// Insert menu
#ifdef _WIN32
if (!InsertMenu(GetMenu(hWindow),MenuIndexHelp,MF_BYPOSITION | MF_POPUP,(UINT)CreateMenu(),LoadResStr("IDS_MNU_NET"))) return;
if (!InsertMenu(GetMenu(hWindow),MenuIndexHelp,MF_BYPOSITION | MF_POPUP,(UINT_PTR)CreateMenu(),LoadResStr("IDS_MNU_NET"))) return;
#elif defined(WITH_DEVELOPER_MODE)
itemNet = gtk_menu_item_new_with_label(LoadResStr("IDS_MNU_NET"));
GtkWidget* menuNet = gtk_menu_new();

View File

@ -2186,14 +2186,9 @@ void C4Command::CompileFunc(StdCompiler *pComp)
// Target X/Y
pComp->Value(Tx); pComp->Separator(StdCompiler::SEP_SEP);
pComp->Value(mkIntPackAdapt(Ty)); pComp->Separator(StdCompiler::SEP_SEP);
int32_t iPtr;
// Target
iPtr = reinterpret_cast<intptr_t>(Target);
pComp->Value(mkIntPackAdapt(iPtr)); pComp->Separator(StdCompiler::SEP_SEP);
Target = reinterpret_cast<C4Object*>(iPtr);
iPtr = reinterpret_cast<intptr_t>(Target2);
pComp->Value(mkIntPackAdapt(iPtr)); pComp->Separator(StdCompiler::SEP_SEP);
Target2 = reinterpret_cast<C4Object*>(iPtr);
pComp->Value(Target); pComp->Separator(StdCompiler::SEP_SEP);
pComp->Value(Target2); pComp->Separator(StdCompiler::SEP_SEP);
// Data
pComp->Value(Data); pComp->Separator(StdCompiler::SEP_SEP);
// Update interval
@ -2234,15 +2229,15 @@ void C4Command::CompileFunc(StdCompiler *pComp)
void C4Command::DenumeratePointers()
{
Target = ::Objects.ObjectPointer((long)Target);
Target2 = ::Objects.ObjectPointer((long)Target2);
Target.DenumeratePointers();
Target2.DenumeratePointers();
Tx.DenumeratePointer();
}
void C4Command::EnumeratePointers()
{
Target = (C4Object*) ::Objects.ObjectNumber(Target);
Target2 = (C4Object*) ::Objects.ObjectNumber(Target2);
Target.EnumeratePointers();
Target2.EnumeratePointers();
}
int32_t C4Command::CallFailed()

View File

@ -24,6 +24,7 @@
#ifndef INC_C4Command
#define INC_C4Command
#include "C4ObjectPtr.h"
#include "C4Value.h"
const int32_t C4CMD_None = 0,
@ -86,7 +87,7 @@ public:
int32_t Command;
C4Value Tx;
int32_t Ty;
C4Object *Target,*Target2;
C4ObjectPtr Target,Target2;
C4Value Data;
int32_t UpdateInterval;
int32_t Evaluated,PathChecked,Finished;

View File

@ -43,7 +43,7 @@ void C4ObjectPtr::CompileFunc(StdCompiler* pComp)
assert(data.nptr < std::numeric_limits<int32_t>::max());
int32_t nptr = static_cast<int32_t>(data.nptr);
pComp->Value(nptr);
pComp->Value(nptr); // TODO: Use mkIntPackAdapt?
data.nptr = nptr;
#ifndef NDEBUG

View File

@ -4486,7 +4486,7 @@ static long FnGetPathLength(C4AulContext* ctx, long iFromX, long iFromY, long iT
PathInfo.ilx = iFromX;
PathInfo.ily = iFromY;
PathInfo.ilen = 0;
if (!Game.PathFinder.Find(iFromX, iFromY, iToX, iToY, &SumPathLength, (long) &PathInfo))
if (!Game.PathFinder.Find(iFromX, iFromY, iToX, iToY, &SumPathLength, (intptr_t) &PathInfo))
return 0;
return PathInfo.ilen + Distance(PathInfo.ilx, PathInfo.ily, iToX, iToY);
}

View File

@ -220,7 +220,7 @@ bool C4UpdateDlg::ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4G
if (hwnd) PostMessage(hwnd, WM_CLOSE, 0, 0);
// Notice: even if the update program and update group are in the temp path, they must be executed in our working directory
StdStrBuf strUpdateArgs; strUpdateArgs.Format("\"%s\" /p -w \"" C4ENGINECAPTION "\" -w \"" C4EDITORCAPTION "\" -w 2000 %s", strUpdateFile, fDeleteUpdate ? "-yd" : "-y");
int iError = (int)ShellExecute(NULL, "open", strUpdateProgEx.getData(), strUpdateArgs.getData(), Config.General.ExePath, SW_SHOW);
int iError = (intptr_t)ShellExecute(NULL, "open", strUpdateProgEx.getData(), strUpdateArgs.getData(), Config.General.ExePath, SW_SHOW);
if (iError <= 32) return false;
// must quit ourselves for update program to work
if (succeeded) Application.Quit();

View File

@ -289,6 +289,12 @@ bool C4Surface::Copy(C4Surface &fromSfc)
// Some distributions ship jpeglib.h with extern "C", others don't - gah.
extern "C"
{
// Sigh... is it really so hard to just fucking prefix your own data types?
// TODO: Should probably do a proper cmake check for this.
#ifdef __MINGW32__
# define HAVE_BOOLEAN
#endif
#include <jpeglib.h>
}
#include <setjmp.h>

View File

@ -35,7 +35,7 @@
bool OpenURL(const char *szURL)
{
#ifdef _WIN32
if ((int)ShellExecute(NULL, "open", szURL, NULL, NULL, SW_SHOW) > 32)
if ((intptr_t)ShellExecute(NULL, "open", szURL, NULL, NULL, SW_SHOW) > 32)
return true;
#endif
#ifdef WITH_GLIB

View File

@ -167,6 +167,8 @@ namespace std { template<typename T> inline T &move (T &t) { return t; } }
#ifndef _INC_WINDOWS
#define _WIN32_WINDOWS 0x0500
#define _WIN32_WINNT 0x0501
// For shlobj.h:
#define _WIN32_IE 0x0501
#define WINVER 0x0500
//#define _WIN32_WINNT 0x0500
#define WIN32_LEAN_AND_MEAN

View File

@ -752,7 +752,7 @@ C4AulTokenType C4AulParseState::GetNextToken(char *pToken, long int *pInt, HoldS
pString = Strings.RegString(StdStrBuf(strbuf.data(),strbuf.size()));
pString->IncRef();
// return pointer on string object
*pInt = (long) pString;
*pInt = (intptr_t) pString;
return ATT_STRING;
}
else
@ -2367,7 +2367,7 @@ void C4AulParseState::Parse_Expression(int iParentPrio)
{
// add direct call to byte code
Parse_Params(Fn->OwnerOverloaded->GetParCount(), NULL, Fn->OwnerOverloaded);
AddBCC(AB_FUNC, (long) Fn->OwnerOverloaded);
AddBCC(AB_FUNC, (intptr_t) Fn->OwnerOverloaded);
}
else
// not found? raise an error, if it's not a safe call
@ -2405,7 +2405,7 @@ void C4AulParseState::Parse_Expression(int iParentPrio)
Parse_Params(FoundFn->GetParCount(), FoundFn->Name, FoundFn);
else
AddBCC(AB_STACK, FoundFn->GetParCount());
AddBCC(AB_FUNC, (long) FoundFn);
AddBCC(AB_FUNC, (intptr_t) FoundFn);
}
else
{
@ -2952,7 +2952,7 @@ bool C4AulScript::Parse()
if (Fn) if (Fn->Owner != Engine) Fn=NULL;
}
if (Fn)
Fn->Code = Code + (long) Fn->Code;
Fn->Code = Code + (intptr_t) Fn->Code;
}
// save line count