From de19589e820d388786c7ed110facfb0b37f9f591 Mon Sep 17 00:00:00 2001 From: skyjake Date: Fri, 30 Sep 2011 08:55:18 +0300 Subject: [PATCH] Mac: Linking against libdeng2 Also handling the Qt framework linking. --- doomsday/config.pri | 13 +++++- doomsday/engine/engine.pro | 74 +++++++++++++++++++++++++--------- doomsday/libdeng2/libdeng2.pro | 5 ++- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/doomsday/config.pri b/doomsday/config.pri index 85e81d5a98..00dbaab3e9 100644 --- a/doomsday/config.pri +++ b/doomsday/config.pri @@ -32,7 +32,7 @@ DENG_WIN_PRODUCTS_DIR = $$PWD/../distrib/products include(versions.pri) -# Build Options -------------------------------------------------------------- +# Macros --------------------------------------------------------------------- defineTest(echo) { !win32 { @@ -44,6 +44,17 @@ defineTest(echo) { } } +defineTest(doPostLink) { + isEmpty(QMAKE_POST_LINK) { + QMAKE_POST_LINK = $$1 + } else { + QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1 + } + export(QMAKE_POST_LINK) +} + +# Build Options -------------------------------------------------------------- + # Configure for Debug/Release build. CONFIG(debug, debug|release) { echo(Debug build.) diff --git a/doomsday/engine/engine.pro b/doomsday/engine/engine.pro index c7bb2f0be5..dfc1f78da9 100644 --- a/doomsday/engine/engine.pro +++ b/doomsday/engine/engine.pro @@ -25,7 +25,9 @@ win32 { include(../dep_directx.pri) } -# Common Definitions --------------------------------------------------------- +QT += core network + +# Definitions ---------------------------------------------------------------- DEFINES += __DOOMSDAY__ @@ -36,22 +38,33 @@ DEFINES += __DOOMSDAY__ echo(DENG_BUILD is not defined.) } -unix:!macx { +win32 { + DEFINES += WIN32_GAMMA + + RC_FILE = win32/res/doomsday.rc + OTHER_FILES += api/doomsday.def +} +else:macx { +} +else { + # Generic Unix. DEFINES += DENG_BASE_DIR=\\\"$${DENG_BASE_DIR}/\\\" DEFINES += DENG_LIBRARY_DIR=\\\"$${DENG_LIB_DIR}/\\\" +} - QMAKE_LFLAGS += -rdynamic +# Build Configuration -------------------------------------------------------- + +deng_writertypecheck { + DEFINES += DENG_WRITER_TYPECHECK } -macx { - useFramework(Cocoa) - useFramework(QTKit) + +deng_sdlnetdummy { + HEADERS += portable/include/sdlnet_dummy.h } -win32 { - DEFINES += WIN32_GAMMA - RC_FILE = win32/res/doomsday.rc - OTHER_FILES += api/doomsday.def +# Linking -------------------------------------------------------------------- +win32 { QMAKE_LFLAGS += \ /NODEFAULTLIB:libcmt \ /DEF:\"$$DENG_API_DIR/doomsday.def\" \ @@ -60,15 +73,17 @@ win32 { LIBS += -lkernel32 -lgdi32 -lole32 -luser32 -lwsock32 -lwinmm \ -lopengl32 -lglu32 } +else:macx { + useFramework(Cocoa) + useFramework(QTKit) -# Engine Configuration ------------------------------------------------------- - -deng_writertypecheck { - DEFINES += DENG_WRITER_TYPECHECK + # Link against libdeng2. + LIBS += -L../libdeng2 -ldeng2 + QMAKE_LFLAGS += -F$$OUT_PWD/../libdeng2 } - -deng_sdlnetdummy { - HEADERS += portable/include/sdlnet_dummy.h +else { + # Allow exporting symbols out of the main executable. + QMAKE_LFLAGS += -rdynamic } # Source Files --------------------------------------------------------------- @@ -497,9 +512,32 @@ SOURCES += ../plugins/common/src/m_fixed.c # Resources ------------------------------------------------------------------ macx { + FW_DIR = \"$${OUT_PWD}/doomsday.app/Contents/Frameworks/\" + # Since qmake is unable to copy directories as bundle data, let's copy # the frameworks manually. - QMAKE_POST_LINK = "rm -rf $${OUT_PWD}/doomsday.app/Contents/Frameworks && mkdir $${OUT_PWD}/doomsday.app/Contents/Frameworks && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/ && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_mixer.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/ && cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_net.framework $${OUT_PWD}/doomsday.app/Contents/Frameworks/" + doPostLink("rm -rf $$FW_DIR") + doPostLink("mkdir $$FW_DIR") + doPostLink("cp -fRp $${SDL_FRAMEWORK_DIR}/SDL.framework $$FW_DIR") + doPostLink("cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_mixer.framework $$FW_DIR") + !deng_sdlnetdummy { + doPostLink("cp -fRp $${SDL_FRAMEWORK_DIR}/SDL_net.framework $$FW_DIR") + } + + # Qt frameworks. + doPostLink("cp -fRp $$[QT_INSTALL_LIBS]/QtCore.framework $$FW_DIR") + doPostLink("cp -fRp $$[QT_INSTALL_LIBS]/QtNetwork.framework $$FW_DIR") + + # libdeng2 dynamic library. + doPostLink("cp -fRp $$OUT_PWD/../libdeng2/libdeng2.1.dylib $$FW_DIR") + + # Fix the dynamic linker paths so they point to ../Frameworks/. + defineTest(fixInstallName) { + doPostLink("install_name_tool -change $$1 @executable_path/../Frameworks/$$1 doomsday.app/Contents/MacOS/doomsday") + } + fixInstallName("libdeng2.1.dylib") + fixInstallName("QtCore.framework/Versions/4/QtCore") + fixInstallName("QtNetwork.framework/Versions/4/QtNetwork") res.files = \ mac/res/English.lproj \ diff --git a/doomsday/libdeng2/libdeng2.pro b/doomsday/libdeng2/libdeng2.pro index a19ffb4b2a..cdd01e307e 100644 --- a/doomsday/libdeng2/libdeng2.pro +++ b/doomsday/libdeng2/libdeng2.pro @@ -8,10 +8,11 @@ TARGET = deng2 include(../config.pri) -DEFINES += __DENG2__ - # Using Qt. QT += core network +include(../dep_qt.pri) + +DEFINES += __DENG2__ win32 { # Keep the version number out of the file name.