Skip to content

Commit

Permalink
Mac: Linking against libdeng2
Browse files Browse the repository at this point in the history
Also handling the Qt framework linking.
  • Loading branch information
skyjake committed Sep 30, 2011
1 parent f1ee34f commit de19589
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 21 deletions.
13 changes: 12 additions & 1 deletion doomsday/config.pri
Expand Up @@ -32,7 +32,7 @@ DENG_WIN_PRODUCTS_DIR = $$PWD/../distrib/products

include(versions.pri)

# Build Options --------------------------------------------------------------
# Macros ---------------------------------------------------------------------

defineTest(echo) {
!win32 {
Expand All @@ -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.)
Expand Down
74 changes: 56 additions & 18 deletions doomsday/engine/engine.pro
Expand Up @@ -25,7 +25,9 @@ win32 {
include(../dep_directx.pri)
}

# Common Definitions ---------------------------------------------------------
QT += core network

# Definitions ----------------------------------------------------------------

DEFINES += __DOOMSDAY__

Expand All @@ -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\" \
Expand All @@ -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 ---------------------------------------------------------------
Expand Down Expand Up @@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions doomsday/libdeng2/libdeng2.pro
Expand Up @@ -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.
Expand Down

0 comments on commit de19589

Please sign in to comment.