Make mape link only against the part of the Clonk engine that is needed

and not against the whole engine. This avoids pulling in unnecessary
dependencies like SDL or OpenGL.
scancodes-fix
Armin Burgmeier 2013-01-09 00:10:27 +01:00
parent 7357125368
commit aa2f3df779
2 changed files with 299 additions and 48 deletions

View File

@ -161,8 +161,6 @@ endif()
# OC_CLONK_SOURCES: Sources for OpenClonk that are needed by every build.
# OC_SYSTEM_SOURCES: Sources for OpenClonk that are only needed by specific
# configurations.
# OC_MAIN_SOURCES: The file with the executable's entry point, not to be added
# to libclonk
set(OC_CLONK_SOURCES
src/C4Globals.cpp
src/c4group/C4ComponentHost.cpp
@ -559,6 +557,75 @@ set(OC_CLONK_SOURCES
thirdparty/timsort/sort.h
)
set(MAPE_BASE_SOURCES
src/c4group/C4ComponentHost.cpp
src/c4group/C4ComponentHost.h
src/c4group/C4Group.cpp
src/c4group/C4Group.h
src/c4group/C4GroupSet.cpp
src/c4group/C4GroupSet.h
src/c4group/C4LangStringTable.cpp
src/c4group/C4LangStringTable.h
src/c4group/CStdFile.cpp
src/c4group/CStdFile.h
src/landscape/C4MapCreatorS2.cpp
src/landscape/C4MapCreatorS2.h
src/landscape/C4Material.cpp
src/landscape/C4Material.h
src/landscape/C4Texture.cpp
src/landscape/C4Texture.h
src/landscape/C4Scenario.cpp
src/landscape/C4Scenario.h
src/lib/C4InputValidation.cpp
src/lib/C4InputValidation.h
src/lib/C4Markup.cpp
src/lib/C4Markup.h
src/lib/C4NameList.cpp
src/lib/C4NameList.h
src/lib/C4Random.cpp
src/lib/C4Random.h
src/lib/C4Real.cpp
src/lib/C4Real.h
src/lib/C4Rect.cpp
src/lib/C4Rect.h
src/lib/C4SimpleLog.cpp
src/lib/Standard.cpp
src/lib/Standard.h
src/lib/StdBuf.cpp
src/lib/StdBuf.h
src/lib/StdCompiler.cpp
src/lib/StdCompiler.h
src/lib/StdResStr2.cpp
src/lib/StdResStr2.h
src/object/C4Id.cpp
src/object/C4Id.h
src/platform/GetTime.cpp
src/platform/StdFile.cpp
src/platform/StdFile.h
src/script/C4Aul.cpp
src/script/C4Aul.h
src/script/C4AulExec.cpp
src/script/C4AulExec.h
src/script/C4AulFunc.cpp
src/script/C4AulFunc.h
src/script/C4AulLink.cpp
src/script/C4AulParse.cpp
src/script/C4PropList.cpp
src/script/C4PropList.h
src/script/C4ScriptHost.cpp
src/script/C4ScriptHost.h
src/script/C4StringTable.cpp
src/script/C4StringTable.h
src/script/C4Value.cpp
src/script/C4Value.h
src/script/C4ValueArray.cpp
src/script/C4ValueArray.h
src/script/C4ValueMap.cpp
src/script/C4ValueMap.h
src/zlib/gzio.c
src/C4Include.cpp
)
set(MAPE_SOURCES
src/mape/cpp-handles/group-handle.h
src/mape/cpp-handles/group-handle.cpp
@ -570,6 +637,7 @@ set(MAPE_SOURCES
src/mape/cpp-handles/random-handle.cpp
src/mape/cpp-handles/texture-handle.h
src/mape/cpp-handles/texture-handle.cpp
src/mape/cpp-handles/stub-handle.cpp
src/mape/configfile.c
src/mape/configfile.h
src/mape/diskview.c
@ -610,7 +678,6 @@ set(MAPE_SOURCES
mark_as_advanced(OC_CLONK_SOURCES)
mark_as_advanced(OC_SYSTEM_SOURCES)
mark_as_advanced(OC_MAIN_SOURCES)
mark_as_advanced(MAPE_SOURCES)
# generated source files
@ -640,12 +707,12 @@ if(APPLE)
src/platform/C4FileMonitorMac.mm
)
list(APPEND OC_MAIN_SOURCES
list(APPEND OC_SYSTEM_SOURCES
src/platform/C4AppDelegate.h
src/platform/C4AppDelegate.mm
)
else()
list(APPEND OC_MAIN_SOURCES
list(APPEND OC_SYSTEM_SOURCES
src/game/ClonkMain.cpp
)
endif()
@ -998,18 +1065,13 @@ endif()
############################################################################
add_definitions(-DHAVE_CONFIG_H)
add_library(libclonk STATIC
add_executable(clonk WIN32 MACOSX_BUNDLE
${OC_SYSTEM_SOURCES}
${OC_CLONK_SOURCES}
)
add_executable(clonk WIN32 MACOSX_BUNDLE
${OC_MAIN_SOURCES}
)
#target_link_libraries(clonk)
if(WITH_MAPE)
add_executable(mape ${MAPE_SOURCES})
add_executable(mape ${MAPE_BASE_SOURCES} ${MAPE_SOURCES})
endif()
add_executable(c4group
@ -1108,11 +1170,7 @@ endif()
if(WITH_MAPE)
target_link_libraries(mape
${FREETYPE_LIBRARIES}
${ZLIB_LIBRARIES}
${PNG_LIBRARIES}
${JPEG_LIBRARIES}
${ICONV_LIBRARY}
)
endif()
@ -1129,6 +1187,11 @@ if(HAVE_PTHREAD)
target_link_libraries(c4script
pthread
)
if(WITH_MAPE)
target_link_libraries(mape
pthread
)
endif()
endif()
if(USE_CONSOLE)
target_link_libraries(clonk
@ -1146,11 +1209,8 @@ if(UNIX AND NOT APPLE)
endif()
set_property(TARGET clonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC)
set(OC_CLONK_LIBRARIES libclonk)
#set_property(TARGET clonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC)
#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG)
set_property(TARGET libclonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG)
# This expands some variables in Info.plist as a side-effect. XCode might then
@ -1241,7 +1301,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
option(USE_GCC_PCH "Use GCC precompiled headers" ON)
endif()
if(USE_GCC_PCH)
add_precompiled_header(libclonk src/C4Include.h)
add_precompiled_header(clonk src/C4Include.h)
add_precompiled_header(c4group src/C4Include.h)
add_precompiled_header(c4script src/C4Include.h)
endif()
@ -1287,12 +1347,12 @@ CHECK_INCLUDE_FILE_CXX(getopt.h HAVE_GETOPT_H)
if(NOT HAVE_GETOPT_H)
include_directories(thirdparty/getopt)
add_subdirectory(thirdparty/getopt)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} getopt)
target_link_libraries(clonk getopt)
elseif(MINGW)
# Link libiberty which my contain getopt with mingw
FINDLIB(iberty_LIBRARIES iberty)
if(iberty_LIBRARIES)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} iberty)
target_link_libraries(clonk iberty)
endif()
endif()
@ -1300,7 +1360,7 @@ CHECK_INCLUDE_FILE_CXX(getopt.h HAVE_GETOPT_H)
# TinyXML
add_subdirectory(thirdparty/tinyxml)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} tinyxml)
target_link_libraries(clonk tinyxml)
if(WIN32)
find_package(DbgHelp)
@ -1315,7 +1375,10 @@ if(USE_GL)
include(FindOpenGL)
FINDLIB(GLEW_LIBRARIES NAMES GLEW glew32 glew32s)
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
target_link_libraries(clonk
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
)
include_directories(${GLEW_INCLUDE_DIR})
endif()
if(USE_DIRECTX)
@ -1323,7 +1386,10 @@ if(USE_DIRECTX)
FINDLIB(DIRECT3DX_LIBRARIES d3dx9)
FIND_PATH(DIRECT3D_INCLUDE_DIR NAMES d3d9.h)
FIND_PATH(DIRECT3DX_INCLUDE_DIR NAMES d3dx9.h)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${DIRECT3D_LIBRARIES} ${DIRECT3DX_LIBRARIES})
target_link_libraries(clonk
${DIRECT3D_LIBRARIES}
${DIRECT3DX_LIBRARIES}
)
include_directories(
${DIRECT3D_INCLUDE_DIR}
${DIRECT3DX_INCLUDE_DIR}
@ -1333,9 +1399,9 @@ if(USE_GTK)
SET(WITH_DEVELOPER_MODE ${GTK_FOUND})
SET(WITH_GLIB ${GTK_FOUND})
if(USE_GTK3)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${GTK3_LIBRARIES})
target_link_libraries(clonk ${GTK3_LIBRARIES})
else()
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${GTK_LIBRARIES})
target_link_libraries(clonk ${GTK_LIBRARIES})
endif()
endif()
if(WITH_MAPE)
@ -1347,13 +1413,16 @@ if(WITH_MAPE)
# hrm, cmake doesn't have target_include_directories...
include_directories(${MAPE_GTK_INCLUDE_DIRS})
link_directories(${MAPE_GTK_LIBRARY_DIRS})
set(MAPE_LIBRARIES ${MAPE_LIBRARIES} ${MAPE_GTK_LIBRARIES})
target_link_libraries(mape ${MAPE_GTK_LIBRARIES})
endif()
endif()
if(USE_X11)
FINDLIB(X11_LIBRARIES X11)
FINDLIB(XRANDR_LIBRARIES Xrandr)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARIES})
target_link_libraries(clonk
${X11_LIBRARIES}
${XRANDR_LIBRARIES}
)
endif()
if(USE_COCOA)
#stupid fix: just link to iconv that way
@ -1365,14 +1434,14 @@ if (WIN32)
FINDLIB(VFW32_LIBRARIES vfw32)
FINDLIB(wavifil32_LIBRARIES wavifil32)
if (VFW32_LIBRARIES)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} vfw32)
target_link_libraries(clonk vfw32)
set(HAVE_VFW32 TRUE)
elseif(wavifil32_LIBRARIES)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} msvfw32)
target_link_libraries(clonk msvfw32)
set(HAVE_VFW32 TRUE)
endif()
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ws2_32 winmm)
target_link_libraries(clonk ws2_32 winmm)
target_link_libraries(c4group ws2_32)
target_link_libraries(netpuncher ws2_32 winmm)
target_link_libraries(c4script ws2_32 winmm)
@ -1381,7 +1450,7 @@ if (WIN32)
find_package(FMod)
if(FMOD_FOUND)
set(HAVE_FMOD TRUE)
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${FMOD_LIBRARIES})
target_link_libraries(clonk ${FMOD_LIBRARIES})
include_directories(${FMOD_INCLUDE_DIR})
else()
set(HAVE_FMOD FALSE)
@ -1397,26 +1466,13 @@ if(NOT HAVE_FMOD AND NOT USE_OPEN_AL OR USE_SDL_MAINLOOP AND NOT USE_OPEN_AL)
if(SDLMIXER_LIBRARIES)
SET(HAVE_LIBSDL_MIXER ON)
endif()
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${SDL_LIBRARY} ${SDLMIXER_LIBRARIES})
target_link_libraries(clonk ${SDL_LIBRARY} ${SDLMIXER_LIBRARIES})
endif()
endif()
if(HAVE_UPNP)
include_directories(${UPNP_INCLUDE_DIR})
set(OC_CLONK_LIBRARIES ${OC_CLONK_LIBRARIES} ${UPNP_LIBRARIES})
endif()
target_link_libraries(clonk
${OC_CLONK_LIBRARIES}
)
if(WITH_MAPE)
# TODO: Remove duplicates in MAPE_LIBRARIES and OC_CLONK_LIBRARIES...
# GTK+ might be in both.
target_link_libraries(mape
${MAPE_LIBRARIES}
${OC_CLONK_LIBRARIES}
)
target_link_libraries(clonk ${UPNP_LIBRARIES})
endif()
# GTest

View File

@ -0,0 +1,195 @@
/*
* mape - C4 Landscape.txt editor
*
* Copyright (c) 2005-2009 Armin Burgmeier
*
* Portions might be copyrighted by other authors who have contributed
* to OpenClonk.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* See isc_license.txt for full license and disclaimer.
*
* "Clonk" is a registered trademark of Matthes Bender.
* See clonk_trademark_license.txt for full license.
*/
#include "C4Include.h"
#include "C4Aul.h"
#include "C4AulDebug.h"
#include "C4GameControl.h"
#include "C4Def.h"
#include "C4DefList.h"
#include "C4Facet.h"
#include "C4GameObjects.h"
#include "C4GameParameters.h"
#include "C4GraphicsResource.h"
#include "C4Landscape.h"
#include "C4PXS.h"
#include "C4RoundResults.h"
#include "CSurface8.h"
/* This file implements stubs for the parts of the engine that are not used
* by mape. It also instantiates global variables required by mape that are
* not instantiated elsewhere. In particular, we avoid C4Globals.cpp. */
/* These are actually used by mape: */
#ifdef _DEBUG
C4Set<C4PropList *> C4PropList::PropLists;
#endif
C4Set<C4PropListNumbered *> C4PropListNumbered::PropLists;
int32_t C4PropListNumbered::EnumerationIndex = 0;
C4StringTable Strings;
C4AulScriptEngine ScriptEngine;
/* These are just stubs used by dead code: */
C4Landscape Landscape;
C4PXSSystem PXS;
C4Config Config;
C4GameObjects Objects;
C4Reloc Reloc;
class C4Draw *pDraw = NULL;
bool EraseItemSafe(const char *szFilename) {return false;}
void Smoke(int, int, int, unsigned int) {}
class C4SoundInstance *StartSoundEffectAt(const char *, int32_t, int32_t, bool, int32_t) { return NULL; }
C4Config::C4Config() {}
C4Config::~C4Config() {}
const char* C4Config::AtTempPath(const char *) { return NULL; }
const char* C4Config::AtRelativePath(char const* s) {return s;}
bool C4Reloc::Open(C4Group&, char const*) const {return false;}
bool C4Draw::TextOut(const char *, CStdFont &, float, C4Surface *, float, float, DWORD, BYTE, bool) { return false; }
CSurface8::CSurface8(int, int) {}
C4Facet::C4Facet() {}
void C4Facet::Set(C4Surface*, float, float, float, float) {}
int32_t C4Facet::GetSectionCount() { return 0; }
C4Facet C4Facet::TruncateSection(int32_t) { return *this; }
C4Surface::C4Surface() {}
C4Surface::~C4Surface() {}
bool C4Surface::Read(CStdStream &, const char *) { return false; }
bool C4Surface::Lock() { return false; }
bool C4Surface::Unlock() { return false; }
DWORD C4Surface::GetPixDw(int iX, int iY, bool fApplyModulation) { return 0; }
C4Pattern::C4Pattern() {}
void C4Pattern::Clear() {}
bool C4Pattern::Set(C4Surface *, int) { return false; }
DWORD C4Pattern::PatternClr(unsigned int, unsigned int) const { return 0; }
C4Pattern& C4Pattern::operator=(C4Pattern const&) { return *this; }
C4IDList::C4IDList() {}
C4IDList::~C4IDList() {}
void C4IDList::Default() {}
void C4IDList::Clear() {}
C4IDList& C4IDList::operator=(C4IDList const&) { return *this; }
bool C4IDList::operator==(const C4IDList&) const { return false; }
int32_t C4IDList::GetIDCount(C4ID, int32_t) const { return 0; }
bool C4IDList::SetIDCount(C4ID, int32_t, bool) { return false; }
void C4IDList::CompileFunc(StdCompiler *, bool) {}
C4IDListChunk::C4IDListChunk() {}
C4IDListChunk::~C4IDListChunk() {}
void C4Def::IncludeDefinition(C4Def*) {}
C4Def* C4DefList::ID2Def(C4ID) {return NULL;}
void C4DefList::Draw(C4ID, C4Facet &, bool, int32_t) {}
C4Def * C4DefList::GetDef(int) {return 0;}
int C4DefList::GetDefCount() {return 0;}
void C4DefList::CallEveryDefinition() {}
void C4DefList::ResetIncludeDependencies() {}
C4Landscape::C4Landscape() {}
C4Landscape::~C4Landscape() {}
bool C4Landscape::FindMatSlide(int&, int&, int, int, int) { return false; }
int32_t C4Landscape::ExtractMaterial(int32_t, int32_t) { return 0; }
bool C4Landscape::InsertMaterial(int32_t, int32_t, int32_t, int32_t, int32_t) { return false; }
bool C4Landscape::Incinerate(int32_t, int32_t) { return false; }
bool C4Landscape::ClearPix(int32_t, int32_t) { return false; }
void C4Landscape::CheckInstabilityRange(int32_t, int32_t) {}
void C4Landscape::HandleTexMapUpdate() {}
void C4Sky::Default() {}
C4Sky::~C4Sky() {}
void C4LSector::Clear() {}
C4ObjectList::C4ObjectList() {}
C4ObjectList::~C4ObjectList() {}
void C4ObjectList::Default() {}
void C4ObjectList::Clear() {}
void C4ObjectList::InsertLinkBefore(C4ObjectLink*, C4ObjectLink*) {}
void C4ObjectList::InsertLink(C4ObjectLink*, C4ObjectLink*) {}
void C4ObjectList::RemoveLink(C4ObjectLink*) {}
bool C4ObjectList::Add(C4Object*, C4ObjectList::SortType, C4ObjectList*) {return 0;}
bool C4ObjectList::Remove(C4Object*) {return 0;}
bool C4ObjectList::AssignInfo() {return 0;}
bool C4ObjectList::ValidateOwners() {return 0;}
void C4NotifyingObjectList::InsertLinkBefore(C4ObjectLink *pLink, C4ObjectLink *pBefore) {}
void C4NotifyingObjectList::InsertLink(C4ObjectLink*, C4ObjectLink*) {}
void C4NotifyingObjectList::RemoveLink(C4ObjectLink*) {}
C4GameObjects::C4GameObjects() {}
C4GameObjects::~C4GameObjects() {}
void C4GameObjects::Clear(bool) {}
void C4GameObjects::Default() {}
bool C4GameObjects::Remove(C4Object*) {return 0;}
bool C4GameObjects::AssignInfo() {return 0;}
bool C4GameObjects::ValidateOwners() {return 0;}
C4Object * C4GameObjects::ObjectPointer(int) {return 0;}
void C4GameObjects::UpdateScriptPointers() {}
C4Value C4GameObjects::GRBroadcast(char const*, C4AulParSet*, bool, bool) {return C4Value();}
C4PXSSystem::C4PXSSystem() {}
C4PXSSystem::~C4PXSSystem() {}
bool C4PXSSystem::Create(int, C4Real, C4Real, C4Real, C4Real) { return false; }
#if 0
/* Pulled in by C4Game... */
CStdFont::CStdFont() {}
C4PathFinder::C4PathFinder() {}
C4PathFinder::~C4PathFinder() {}
C4TransferZones::C4TransferZones() {}
C4TransferZones::~C4TransferZones() {}
C4PacketBase::C4PacketBase() {}
C4PacketList::C4PacketList() {}
C4PacketBase::~C4PacketBase() {}
C4PacketList::~C4PacketList() {}
C4Control::C4Control() {}
C4Control::~C4Control() {}
C4GameControl::C4GameControl(): Network(this) {}
C4GameControl::~C4GameControl() {}
C4GameControlNetwork::C4GameControlNetwork(C4GameControl*): pParent(NULL) {}
C4GameControlNetwork::~C4GameControlNetwork() {}
C4GraphicsResource::C4GraphicsResource(): CaptionFont(FontCaption), TitleFont(FontTitle), TextFont(FontRegular), MiniFont(FontTiny), TooltipFont(FontTooltip) {}
C4GraphicsResource::~C4GraphicsResource() {}
C4GameParameters::C4GameParameters() {}
C4GameParameters::~C4GameParameters() {}
//C4Extra::C4Extra() {}
//C4Extra::~C4Extra() {}
void C4Extra::Clear() {}
static C4KeyboardInput KeyboardInput;
void C4KeyboardInput::Clear() {}
bool C4KeyboardInput::IsValid = false;
C4KeyboardInput &C4KeyboardInput_Init() { return KeyboardInput; }
static C4GameParameters GameParameters;
static C4RoundResults GameRoundResults;
C4Game::C4Game(): Parameters(GameParameters), Clients(Parameters.Clients), Teams(Parameters.Teams), PlayerInfos(Parameters.PlayerInfos), RestorePlayerInfos(Parameters.RestorePlayerInfos), RoundResults(GameRoundResults), Input(Control.Input), KeyboardInput(C4KeyboardInput_Init()) {}
C4Game::~C4Game() {}
#endif
C4AulDebug *C4AulDebug::pDebug;
void C4AulDebug::DebugStepIn(C4AulBCC*) {}
void C4AulDebug::DebugStepOut(C4AulBCC*, C4AulScriptContext*, C4Value*) {}
void C4AulDebug::DebugStep(C4AulBCC*) {}