Skip to content

Commit

Permalink
mac: build as a framework if Qt is and user not force dylib
Browse files Browse the repository at this point in the history
If Qt is build as frameworks, then QtAV will be a framework too by
default.
But you can change to dylib. just add `CONFIG+=no-framework` in
QtAV_src_root/user.conf.
  • Loading branch information
wang-bin committed Aug 9, 2014
1 parent 2a964d9 commit 6eea7da
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 33 deletions.
2 changes: 2 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

isEmpty(COMMON_PRI_INCLUDED): { #begin COMMON_PRI_INCLUDED

mac:contains(QT_CONFIG, qt_framework):!mac_dylib: CONFIG += mac_framework

CONFIG += profile
#profiling, -pg is not supported for msvc
debug:!*msvc*:profile {
Expand Down
8 changes: 8 additions & 0 deletions root.pri
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ cache(BUILD_DIR, set, BUILD_DIR)
cache(SOURCE_ROOT, set, SOURCE_ROOT)
cache(mkspecs_cached, set, mkspecs_build)

# no-framework can be defined in user.conf. default is the same as QT_CONFIG
MAC_LIB = mac_dylib
no-framework {
cache(CONFIG, add, MAC_LIB)
} else {
cache(CONFIG, sub, MAC_LIB)
}

defineTest(runConfigTests) {
no_config_tests:return(false)
#config.tests
Expand Down
25 changes: 14 additions & 11 deletions src/libQtAV.pri
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ DEPENDPATH *= $$PROJECT_SRCPATH
!contains(CONFIG, $$lower($$NAME)-buildlib) {
#The following may not need to change
CONFIG *= link_prl
LIBS *= -L$$PROJECT_LIBDIR -l$$qtLibName($$NAME)
isEqual(STATICLINK, 1) {
PRE_TARGETDEPS += $$PROJECT_LIBDIR/$$qtStaticLib($$NAME)
} else {
win32 {
PRE_TARGETDEPS *= $$PROJECT_LIBDIR/$$qtSharedLib($$NAME, $$LIB_VERSION)
} else {
PRE_TARGETDEPS *= $$PROJECT_LIBDIR/$$qtSharedLib($$NAME)

}
}
mac_framework {
LIBS += -F$$PROJECT_LIBDIR -framework $$NAME
} else {
LIBS *= -L$$PROJECT_LIBDIR -l$$qtLibName($$NAME)
isEqual(STATICLINK, 1) {
PRE_TARGETDEPS += $$PROJECT_LIBDIR/$$qtStaticLib($$NAME)
} else {
win32 {
PRE_TARGETDEPS *= $$PROJECT_LIBDIR/$$qtSharedLib($$NAME, $$LIB_VERSION)
} else {
PRE_TARGETDEPS *= $$PROJECT_LIBDIR/$$qtSharedLib($$NAME)
}
}
}
} else {
#Add your additional configuration first. e.g.

Expand Down
59 changes: 44 additions & 15 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TEMPLATE = lib
MODULE_INCNAME = QtAV # for mac framework. also used in install_sdk.pro
TARGET = QtAV
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4) {
Expand Down Expand Up @@ -30,7 +31,7 @@ win32 {
QMAKE_EXTRA_TARGETS += rc
}
# copy runtime libs to qt sdk
!ios: copy_sdk_libs = $$DESTDIR/$$qtSharedLib($$NAME)
!mac_framework: copy_sdk_libs = $$DESTDIR/$$qtSharedLib($$NAME)
#plugin.depends = #makefile target
#windows: copy /y file1+file2+... dir. need '+'
for(f, copy_sdk_libs) {
Expand Down Expand Up @@ -259,6 +260,7 @@ SOURCES += \
SDK_HEADERS *= \
QtAV/QtAV.h \
QtAV/dptr.h \
QtAV/prepost.h \
QtAV/QtAV_Global.h \
QtAV/AudioResampler.h \
QtAV/AudioResamplerTypes.h \
Expand Down Expand Up @@ -299,20 +301,7 @@ SDK_HEADERS *= \
QtAV/SurfaceInterop.h \
QtAV/version.h

# QtAV/private/* may be used by developers to extend QtAV features without changing QtAV library
# headers not in QtAV/ and it's subdirs are used only by QtAV internally
HEADERS *= \
$$SDK_HEADERS \
utils/BlockingQueue.h \
utils/GPUMemCopy.h \
utils/OpenGLHelper.h \
QtAV/prepost.h \
QtAV/AVDemuxThread.h \
QtAV/AVThread.h \
QtAV/AudioThread.h \
QtAV/VideoThread.h \
QtAV/ColorTransform.h \
QtAV/VideoDecoderFFmpegHW.h \
SDK_PRIVATE_HEADERS *= \
QtAV/private/factory.h \
QtAV/private/singleton.h \
QtAV/private/AVCompat.h \
Expand All @@ -335,5 +324,45 @@ HEADERS *= \
QtAV/private/VideoRenderer_p.h \
QtAV/private/QPainterRenderer_p.h

# QtAV/private/* may be used by developers to extend QtAV features without changing QtAV library
# headers not in QtAV/ and it's subdirs are used only by QtAV internally
HEADERS *= \
$$SDK_HEADERS \
$$SDK_PRIVATE_HEADERS \
utils/BlockingQueue.h \
utils/GPUMemCopy.h \
utils/OpenGLHelper.h \
QtAV/AVDemuxThread.h \
QtAV/AVThread.h \
QtAV/AudioThread.h \
QtAV/VideoThread.h \
QtAV/ColorTransform.h \
QtAV/VideoDecoderFFmpegHW.h


# from mkspecs/features/qt_module.prf
# OS X and iOS frameworks
mac_framework { # from common.pri
#QMAKE_FRAMEWORK_VERSION = 4.0
CONFIG += lib_bundle sliced_bundle qt_framework
CONFIG -= qt_install_headers #no need to install these as well
!debug_and_release|!build_all|CONFIG(release, debug|release) {
FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files = $$SDK_HEADERS
FRAMEWORK_HEADERS.path = Headers
FRAMEWORK_PRIVATE_HEADERS.files = $$SDK_PRIVATE_HEADERS
FRAMEWORK_PRIVATE_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/private
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS FRAMEWORK_PRIVATE_HEADERS
}
}

mac {
CONFIG += explicitlib
macx-g++ {
QMAKE_CFLAGS += -fconstant-cfstrings
QMAKE_CXXFLAGS += -fconstant-cfstrings
}
}

SDK_INCLUDE_FOLDER = QtAV
include($$PROJECTROOT/deploy.pri)
29 changes: 22 additions & 7 deletions tools/install_sdk/install_sdk.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ win32 {
MOVE = move /y
COPY = copy /y
COPY_DIR = xcopy /s /q /y /i
MKDIR = mkdir
RM_DIR = rd /s /q
*g++* {
LIBSUFFIX = a
Expand All @@ -30,6 +31,7 @@ win32 {
MOVE = mv
COPY = cp -f
COPY_DIR = $$COPY -R
MKDIR = mkdir -p
RM_DIR = rm -rf
macx: LIBSUFFIX = dylib
else: LIBSUFFIX = so
Expand All @@ -44,9 +46,14 @@ greaterThan(QT_MAJOR_VERSION, 4) {
MKSPECS_DIR=$$[QMAKE_MKSPECS]
}

sdk_install.commands = $$quote($$COPY $$system_path($$PROJECT_LIBDIR/*QtAV*) $$system_path($$[QT_INSTALL_LIBS]))
sdk_install.commands += $$quote($$COPY $$system_path($$PROJECT_LIBDIR/$$ORIG_LIB) $$system_path($$[QT_INSTALL_LIBS]/$$NEW_LIB))
sdk_install.commands += $$quote($$COPY_DIR $$system_path($$PROJECTROOT/src/QtAV) $$system_path($$[QT_INSTALL_HEADERS]/QtAV))
mac_framework {
sdk_install.commands = $$quote($$COPY_DIR $$system_path($$PROJECT_LIBDIR/QtAV.framework) $$system_path($$[QT_INSTALL_LIBS]))
} else {
sdk_install.commands = $$quote($$MKDIR $$system_path($$[QT_INSTALL_HEADERS]/QtAV/))
sdk_install.commands += $$quote($$COPY $$system_path($$PROJECTROOT/src/QtAV/*.h) $$system_path($$[QT_INSTALL_HEADERS]/QtAV/))
sdk_install.commands += $$quote($$COPY $$system_path($$PROJECT_LIBDIR/*QtAV*) $$system_path($$[QT_INSTALL_LIBS]))
sdk_install.commands += $$quote($$COPY $$system_path($$PROJECT_LIBDIR/$$ORIG_LIB) $$system_path($$[QT_INSTALL_LIBS]/$$NEW_LIB))
}
sdk_install.commands += $$quote($$COPY_DIR $$system_path($$PROJECTROOT/qml/QmlAV) $$system_path($$[QT_INSTALL_HEADERS]/QmlAV))
greaterThan(QT_MAJOR_VERSION, 4) {
sdk_install.commands += $$quote($$COPY_DIR $$system_path($$BUILD_DIR/bin/QtAV) $$system_path($$[QT_INSTALL_QML]/QtAV))
Expand All @@ -60,7 +67,11 @@ win32: sdk_install.commands += $$quote($$MOVE $$system_path($$[QT_INSTALL_LIBS]/
## copy libcommon.so requred by QMLPlayer and player
android: sdk_install.commands += $$quote($$COPY $$system_path($$PROJECT_LIBDIR/libcommon.so) $$system_path($$[QT_INSTALL_LIBS]))

sdk_uninstall.commands = $$quote($$QMAKE_DEL_FILE $$system_path($$[QT_INSTALL_LIBS]/*QtAV*))
mac_framework {
sdk_uninstall.commands = $$quote($$RM_DIR $$system_path($$[QT_INSTALL_LIBS]/QtAV.framework))
} else {
sdk_uninstall.commands = $$quote($$QMAKE_DEL_FILE $$system_path($$[QT_INSTALL_LIBS]/*QtAV*))
}
sdk_uninstall.commands += $$quote($$QMAKE_DEL_FILE $$system_path($$[QT_INSTALL_LIBS]/$$NEW_LIB))
sdk_uninstall.commands += $$quote($$RM_DIR $$system_path($$[QT_INSTALL_HEADERS]/QtAV))
sdk_uninstall.commands += $$quote($$RM_DIR $$system_path($$[QT_INSTALL_HEADERS]/QmlAV))
Expand Down Expand Up @@ -90,9 +101,12 @@ AV_PRF_CONT += "!contains(QT, av): QT *= av"
write_file($$OUT_PWD/mkspecs/features/av.prf, AV_PRF_CONT)


VERSION = $${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
VERSION = 1.3.4
# windows: Qt5AV.dll, not Qt1AV.dll
win32: VERSION = $${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
MODULE_QMAKE_OUTDIR = $$OUT_PWD
MODULE_CONFIG = av
MODULE_INCNAME = QtAV

## the following is from mkspecs/features/qt_module_pris.prf
mod_work_pfx = $$MODULE_QMAKE_OUTDIR/mkspecs/modules
Expand All @@ -115,6 +129,7 @@ else: \
MODULE_PRI = $$mod_inst_pfx/qt_lib_$${MODULE_ID}.pri
MODULE_FWD_PRI = $$mod_work_pfx/qt_lib_$${MODULE_ID}.pri


!build_pass {

# Create a module .pri file
Expand Down Expand Up @@ -253,15 +268,15 @@ MODULE_FWD_PRI = $$mod_work_pfx/qt_lib_$${MODULE_ID}.pri
include($$mod_work_pfx/qt_lib_$${pri}.pri)
for(mod, mods_to_load) {
for(var, $$list(VERSION MAJOR_VERSION MINOR_VERSION PATCH_VERSION \
name depends module_config CONFIG DEFINES sources \
name depends run_depends plugin_types module_config CONFIG DEFINES \
includes bins libs libexecs plugins imports qml \
rpath_link \
)):defined(QT.$${mod}.$$var, var):cache(QT.$${mod}.$$var, transient)
}
cache(QT_MODULES, transient)

} # !build_pass


# Schedule the regular .pri file for installation
CONFIG += qt_install_module
}

0 comments on commit 6eea7da

Please sign in to comment.