Skip to content

Commit

Permalink
qmake: rpath flags
Browse files Browse the repository at this point in the history
QMAKE_RPATHDIR has different results on mac(4.x 5.x) and linux. now can
run directly on mac
  • Loading branch information
wang-bin committed Feb 8, 2015
1 parent 24e088c commit b2234d9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 81 deletions.
36 changes: 35 additions & 1 deletion common.pri
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
# qmake common template pri file
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Copyright (C) 2011-2015 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -55,6 55,8 @@ unix {
*maemo6*:_OS = _maemo6
} else:*meego*: _OS = _meego
!isEmpty(MEEGO_EDITION): _OS = _$$MEEGO_EDITION
# QMAKE_RPATHDIR will be ignored if QMAKE_LFLAGS_RPATH is not defined. e.g. qt4.8 unsupported/macx-clang-libc
isEmpty(QMAKE_LFLAGS_RPATH): QMAKE_LFLAGS_RPATH=-Wl,-rpath,
} else:wince* {
_OS = _wince
} else:win32 { #true for wince
Expand Down Expand Up @@ -381,6 383,38 @@ defineReplace(system_path) {
return($$1)
}
} #lessThan(QT_MAJOR_VERSION, 5)

# set default rpath and add user defined rpaths
defineTest(set_rpath) {
!unix: return(true)
RPATHDIR = $$ARGS #see doc
LIBS = -L/usr/local/lib
# $$[QT_INSTALL_LIBS] and $$DESTDIR and pro dir will be auto added to QMAKE_RPATHDIR if QMAKE_RPATHDIR is not empty
# Current (sub)project dir is auto added to the first value as prefix. e.g. QMAKE_RPATHDIR = .. ==> -Wl,-rpath,ROOT/..
# Executable dir search: ld -z origin, g -Wl,-R,'$ORIGIN', in makefile -Wl,-R,'$$ORIGIN'
# Working dir search: "."
# mac: install_name @rpath will search paths set in rpath link flags
# QMAKE_RPATHDIR: lflags maybe wrong, paths are modified
#isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
macx|ios {
RPATHDIR *= @loader_path/../Frameworks @executable_path/../Frameworks
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
} else {
RPATHDIR *= \$\$ORIGIN \$\$ORIGIN/lib . /usr/local/lib $$[QT_INSTALL_LIBS]
# $$PROJECT_LIBDIR only for host == target. But QMAKE_TARGET.arch is only available on windows. QT_ARCH is bad, e.g. QT_ARCH=i386 while QMAKE_HOST.arch=i686
# https://bugreports.qt-project.org/browse/QTBUG-30263
QMAKE_LFLAGS *= -Wl,-z,origin #\'-Wl,-rpath,$$join(RPATHDIR, ":")\'
}
for(R,RPATHDIR) {
QMAKE_LFLAGS *= \'$${QMAKE_LFLAGS_RPATH}$$R\'
}
# QMAKE_RPATHDIR *= $$RPATHDIR
#export(QMAKE_RPATHDIR)
export(QMAKE_LFLAGS_SONAME)
export(QMAKE_LFLAGS)
return(true)
}

#argument 1 is default dir if not defined
defineTest(getBuildRoot) {
!isEmpty(2): unset(BUILD_DIR)
Expand Down
23 changes: 4 additions & 19 deletions examples/common/libcommon.pri
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
# qmake library building template pri file
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Copyright (C) 2011-2015 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -131,25 131,10 @@ DEPENDPATH *= $$PROJECT_SRCPATH
}
}

unix {
LIBS = -L/usr/local/lib
# $$[QT_INSTALL_LIBS] and $$DESTDIR and pro dir will be auto added to QMAKE_RPATHDIR if QMAKE_RPATHDIR is not empty
# Current (sub)project dir is auto added to the first value as prefix. e.g. QMAKE_RPATHDIR = .. ==> -Wl,-rpath,ROOT/..
# Executable dir search: ld -z origin, g -Wl,-R,'$ORIGIN', in makefile -Wl,-R,'$$ORIGIN'
# Working dir search: "."
# TODO: for macx. see qtcreator/src/rpath.pri. (-rpath define rpath, @rpath exapand to that path?)
macx|ios {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$PROJECT_LIBDIR/
#QMAKE_LFLAGS = -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
} else {
RPATHDIR = \$\$ORIGIN \$\$ORIGIN/lib . /usr/local/lib
# $$PROJECT_LIBDIR only for host == target. But QMAKE_TARGET.arch is only available on windows. QT_ARCH is bad, e.g. QT_ARCH=i386 while QMAKE_HOST.arch=i686
# https://bugreports.qt-project.org/browse/QTBUG-30263
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
QMAKE_LFLAGS *= -Wl,-z,origin \'-Wl,-rpath,$$join(RPATHDIR, ":")\'
}
}
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
set_rpath($$RPATHDIR)

unset(RPATHDIR)
unset(LIB_VERSION)
unset(PROJECT_SRCPATH)
unset(PROJECT_LIBDIR)
Expand Down
23 changes: 4 additions & 19 deletions qml/libQmlAV.pri
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
# qmake library building template pri file
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Copyright (C) 2011-2015 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -129,25 129,10 @@ DEPENDPATH *= $$PROJECT_SRCPATH
}
}

unix {
LIBS = -L/usr/local/lib
# $$[QT_INSTALL_LIBS] and $$DESTDIR and pro dir will be auto added to QMAKE_RPATHDIR if QMAKE_RPATHDIR is not empty
# Current (sub)project dir is auto added to the first value as prefix. e.g. QMAKE_RPATHDIR = .. ==> -Wl,-rpath,ROOT/..
# Executable dir search: ld -z origin, g -Wl,-R,'$ORIGIN', in makefile -Wl,-R,'$$ORIGIN'
# Working dir search: "."
# TODO: for macx. see qtcreator/src/rpath.pri. (-rpath define rpath, @rpath exapand to that path?)
macx|ios {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/Frameworks/
#QMAKE_LFLAGS = -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
} else {
RPATHDIR = \$\$ORIGIN \$\$ORIGIN/lib . /usr/local/lib
# $$PROJECT_LIBDIR only for host == target. But QMAKE_TARGET.arch is only available on windows. QT_ARCH is bad, e.g. QT_ARCH=i386 while QMAKE_HOST.arch=i686
# https://bugreports.qt-project.org/browse/QTBUG-30263
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
QMAKE_LFLAGS *= -Wl,-z,origin \'-Wl,-rpath,$$join(RPATHDIR, ":")\'
}
}
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
set_rpath($$RPATHDIR)

unset(RPATHDIR)
unset(LIB_VERSION)
unset(PROJECT_SRCPATH)
unset(PROJECT_LIBDIR)
Expand Down
26 changes: 4 additions & 22 deletions src/libQtAV.pri
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
# qmake library building template pri file
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Copyright (C) 2011-2015 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -131,29 131,11 @@ DEPENDPATH *= $$PROJECT_SRCPATH
INSTALLS = target
}
}

unix {
LIBS = -L/usr/local/lib
# $$[QT_INSTALL_LIBS] and $$DESTDIR and pro dir will be auto added to QMAKE_RPATHDIR if QMAKE_RPATHDIR is not empty
# Current (sub)project dir is auto added to the first value as prefix. e.g. QMAKE_RPATHDIR = .. ==> -Wl,-rpath,ROOT/..
# Executable dir search: ld -z origin, g -Wl,-R,'$ORIGIN', in makefile -Wl,-R,'$$ORIGIN'
# Working dir search: "."
# TODO: for macx. see qtcreator/src/rpath.pri. (-rpath define rpath, @rpath exapand to that path?)
macx|ios {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$PROJECT_LIBDIR/
# 5.4
#QMAKE_LFLAGS = -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
} else {
RPATHDIR = \$\$ORIGIN \$\$ORIGIN/lib . /usr/local/lib $$[QT_INSTALL_LIBS]
# $$PROJECT_LIBDIR only for host == target. But QMAKE_TARGET.arch is only available on windows. QT_ARCH is bad, e.g. QT_ARCH=i386 while QMAKE_HOST.arch=i686
# https://bugreports.qt-project.org/browse/QTBUG-30263
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
QMAKE_LFLAGS *= -Wl,-z,origin \'-Wl,-rpath,$$join(RPATHDIR, ":")\'
}
}
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
set_rpath($$RPATHDIR)

*maemo*: QMAKE_LFLAGS = -lasound

unset(RPATHDIR)
unset(LIB_VERSION)
unset(PROJECT_SRCPATH)
unset(PROJECT_LIBDIR)
Expand Down
24 changes: 4 additions & 20 deletions widgets/libQtAVWidgets.pri
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
# qmake library building template pri file
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Copyright (C) 2011-2015 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -132,26 132,10 @@ DEPENDPATH *= $$PROJECT_SRCPATH
}
}

unix {
LIBS = -L/usr/local/lib
# $$[QT_INSTALL_LIBS] and $$DESTDIR and pro dir will be auto added to QMAKE_RPATHDIR if QMAKE_RPATHDIR is not empty
# Current (sub)project dir is auto added to the first value as prefix. e.g. QMAKE_RPATHDIR = .. ==> -Wl,-rpath,ROOT/..
# Executable dir search: ld -z origin, g -Wl,-R,'$ORIGIN', in makefile -Wl,-R,'$$ORIGIN'
# Working dir search: "."
# TODO: for macx. see qtcreator/src/rpath.pri. (-rpath define rpath, @rpath exapand to that path?)
macx|ios {
QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$PROJECT_LIBDIR/
# 5.4
#QMAKE_LFLAGS = -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
} else {
RPATHDIR = \$\$ORIGIN \$\$ORIGIN/lib . /usr/local/lib $$[QT_INSTALL_LIBS]
# $$PROJECT_LIBDIR only for host == target. But QMAKE_TARGET.arch is only available on windows. QT_ARCH is bad, e.g. QT_ARCH=i386 while QMAKE_HOST.arch=i686
# https://bugreports.qt-project.org/browse/QTBUG-30263
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
QMAKE_LFLAGS *= -Wl,-z,origin \'-Wl,-rpath,$$join(RPATHDIR, ":")\'
}
}
isEmpty(CROSS_COMPILE): RPATHDIR *= $$PROJECT_LIBDIR
set_rpath($$RPATHDIR)

unset(RPATHDIR)
unset(LIB_VERSION)
unset(PROJECT_SRCPATH)
unset(PROJECT_LIBDIR)
Expand Down

0 comments on commit b2234d9

Please sign in to comment.