Skip to content

Commit

Permalink
update qmake pro. use the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWang committed Jan 14, 2013
1 parent 3a10f67 commit 8d1d970
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 108 deletions.
201 changes: 113 additions & 88 deletions common.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# qmake common template pri file
# Copyright (C) 2011 Wang Bin <[email protected]>
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -22,10 +22,10 @@ isEmpty(COMMON_PRI_INCLUDED): { #begin COMMON_PRI_INCLUDED
CONFIG += profile
#profiling, -pg is not supported for msvc
debug:!*msvc*:profile {
QMAKE_CXXFLAGS_DEBUG += -pg
QMAKE_LFLAGS_DEBUG += -pg
QMAKE_CXXFLAGS_DEBUG = $$unique(QMAKE_CXXFLAGS_DEBUG)
QMAKE_LFLAGS_DEBUG = $$unique(QMAKE_LFLAGS_DEBUG)
QMAKE_CXXFLAGS_DEBUG += -pg
QMAKE_LFLAGS_DEBUG += -pg
QMAKE_CXXFLAGS_DEBUG = $$unique(QMAKE_CXXFLAGS_DEBUG)
QMAKE_LFLAGS_DEBUG = $$unique(QMAKE_LFLAGS_DEBUG)
}

#$$[TARGET_PLATFORM]
Expand All @@ -35,126 +35,151 @@ _ARCH =
_EXTRA =

unix {
_OS = _unix
*linux*: _OS = _linux
else:mac: _OS = _mac
else:*maemo* {
_OS = _maemo
*maemo5*:_OS = _maemo5
*maemo6*:_OS = _maemo6
}
else:*meego*: _OS = _meego
!isEmpty(MEEGO_EDITION): _OS = _$$MEEGO_EDITION
_OS = _unix
macx: _OS = _mac
else:*linux*: _OS = _linux
*maemo* {
_OS = _maemo
*maemo5*:_OS = _maemo5
*maemo6*:_OS = _maemo6
} else:*meego*: _OS = _meego
!isEmpty(MEEGO_EDITION): _OS = _$$MEEGO_EDITION
} else:wince* {
_OS = _wince
_OS = _wince
} else:win32 { #true for wince
_OS = _win32
_OS = _win32
}
#*arm*: _ARCH = $${_ARCH}_arm
contains(QT_ARCH, arm.*) {
_ARCH = $${_ARCH}_$${QT_ARCH}
_ARCH = $${_ARCH}_$${QT_ARCH}
}
*64: _ARCH = $${_ARCH}_x64
*64: _ARCH = $${_ARCH}_x64
*llvm*: _EXTRA = _llvm
#*msvc*:

win32-msvc* {
#Don"t warn about sprintf, fopen etc being "unsafe"
DEFINES += _CRT_SECURE_NO_WARNINGS
#Don"t warn about sprintf, fopen etc being "unsafe"
DEFINES += _CRT_SECURE_NO_WARNINGS
}

#################################functions#########################################
defineReplace(cleanPath) {
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
return($$join(out, /, $$pfx))
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
return($$join(out, /, $$pfx))
}

#Acts like qtLibraryTarget. From qtcreator.pri
defineReplace(qtLibName) {
#TEMPLATE += fakelib
#LIB_FULLNAME = $$qtLibraryTarget($$1)
#TEMPLATE -= fakelib
unset(LIBRARY_NAME)
LIBRARY_NAME = $$1
CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac:RET = $$member(LIBRARY_NAME, 0)_debug
else:win32:RET = $$member(LIBRARY_NAME, 0)d
}
}
isEmpty(RET):RET = $$LIBRARY_NAME
!win32: return($$RET)

isEmpty(2): VERSION_EXT = $$VERSION
else: VERSION_EXT = $$2
!isEmpty(VERSION_EXT) {
VERSION_EXT = $$section(VERSION_EXT, ., 0, 0)
#isEqual(VERSION_EXT, 0):unset(VERSION_EXT)
}
RET = $${RET}$${VERSION_EXT}
unset(VERSION_EXT)
return($$RET)
#TEMPLATE += fakelib
#LIB_FULLNAME = $$qtLibraryTarget($$1)
#TEMPLATE -= fakelib
unset(LIBRARY_NAME)
LIBRARY_NAME = $$1
CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac:RET = $$member(LIBRARY_NAME, 0)_debug
else:win32:RET = $$member(LIBRARY_NAME, 0)d
}
}
isEmpty(RET):RET = $$LIBRARY_NAME
!win32: return($$RET)

isEmpty(2): VERSION_EXT = $$VERSION
else: VERSION_EXT = $$2
!isEmpty(VERSION_EXT) {
VERSION_EXT = $$section(VERSION_EXT, ., 0, 0)
#isEqual(VERSION_EXT, 0):unset(VERSION_EXT)
}
RET = $${RET}$${VERSION_EXT}
unset(VERSION_EXT)
return($$RET)
}


#fakelib
defineReplace(qtStaticLib) {
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
*msvc*|win32-icc: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).lib
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).a
return($$LIB_FULLNAME)
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
*msvc*|win32-icc: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).lib
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).a
return($$LIB_FULLNAME)
}

defineReplace(qtSharedLib) {
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
win32: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).dll
else {
macx|ios: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).$${QMAKE_EXTENSION_SHLIB} #default_post.prf
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).so
}
return($$LIB_FULLNAME)
unset(LIB_FULLNAME)
LIB_FULLNAME = $$qtLibName($$1, $$2)
win32: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).dll
else {
macx|ios: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).$${QMAKE_EXTENSION_SHLIB} #default_post.prf
else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).so
}
return($$LIB_FULLNAME)
}

defineReplace(qtLongName) {
unset(LONG_NAME)
LONG_NAME = $$1$${_OS}$${_ARCH}$${_EXTRA}
return($$LONG_NAME)
unset(LONG_NAME)
LONG_NAME = $$1$${_OS}$${_ARCH}$${_EXTRA}
return($$LONG_NAME)
}

##############################paths####################################
#TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts i18n/$${TARGET}_zh_CN.ts
#argument 1 is default dir if not defined
defineTest(getBuildRoot) {
!isEmpty($$2): unset(BUILD_DIR)
isEmpty(BUILD_DIR) {
BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR) {
BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR) {
!isEmpty(1) {
BUILD_DIR=$$1
} else {
BUILD_DIR = $$OUT_PWD
warning(BUILD_DIR not specified, using $$BUILD_DIR)
}
}
}
}
export(BUILD_DIR)
message(BUILD_DIR=$$BUILD_DIR)
return(true)
}

##############################paths####################################
#for Qt2, Qt3 which does not have QT_VERSION. Qt4: $$[QT_VERSION]
MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION}
RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION}
UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION}
#obj is platform dependent
OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET)

isEqual(TEMPLATE, app) {
defineTest(preparePaths) {
getBuildRoot($$1, $$2)
MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION}
RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION}
UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION}
#obj is platform dependent
OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET)
#before target name changed
!isEmpty(PROJECTROOT):TRANSLATIONS *= $$PROJECTROOT/i18n/$${TARGET}_zh-cn.ts $$PROJECTROOT/i18n/$${TARGET}_zh_CN.ts
isEqual(TEMPLATE, app) {
DESTDIR = $$BUILD_DIR/bin
# TARGET = $$qtLongName($$TARGET)
EXE_EXT =
win32: EXE_EXT = .exe
CONFIG(release, debug|release):
!isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$DESTDIR/$${TARGET}$${EXE_EXT} #.exe in win
}else: DESTDIR = $$qtLongName($$BUILD_DIR/lib)

!build_pass:message(target: $$DESTDIR/$$TARGET)

CONFIG(release, debug|release): !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$DESTDIR/$${TARGET}$${EXE_EXT} #.exe in win
} else: DESTDIR = $$qtLongName($$BUILD_DIR/lib)
!build_pass:message(target: $$DESTDIR/$$TARGET)
#export vars outside this function
export(MOC_DIR)
export(RCC_DIR)
export(UI_DIR)
export(OBJECTS_DIR)
export(DESTDIR)
export(TARGET)
return(true)
}
COMMON_PRI_INCLUDED = 1

} #end COMMON_PRI_INCLUDED
#before target name changed
#TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts #i18n/$${TARGET}_zh_CN.ts

7 changes: 1 addition & 6 deletions gui/player.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ QT += opengl
TARGET = player
STATICLINK = 0
PROJECTROOT = $$PWD/..
isEmpty(BUILD_DIR):BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR):BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR):BUILD_IN_SRC = yes

!isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/../out
include($${PROJECTROOT}/common.pri)
include($$PROJECTROOT/src/libQtAV.pri)
preparePaths($$OUT_PWD/../out)

#win32:LIBS += -lUser32

Expand Down
15 changes: 6 additions & 9 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 Wang Bin <[email protected]>
# Copyright (C) 2011-2013 Wang Bin <[email protected]>
# Shanghai, China.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -24,10 +24,10 @@
# TEMPLATE = lib
# QT -= gui
# CONFIG *= xx-buildlib
# STATICLINK = 1 #optional. default is 0, i.e. dynamically link
# PROJECTROOT = $$PWD/..
# STATICLINK = 1 #or 0
# include(libXX.pri)
# include($${PROJECTROOT}/common.pri)
# preparePaths($$OUT_PWD/../out)
# HEADERS = ...
# SOURCES = ...
# ...
Expand All @@ -36,7 +36,7 @@
# PROJECTROOT = $$PWD/..
# STATICLINK = 1 #or 0
# include(dir_of_XX/libXX.pri)
# include($${PROJECTROOT}/common.pri)
# preparePaths($$OUT_PWD/../out)
# HEADERS = ...
# SOURCES = ...
#
Expand All @@ -58,13 +58,10 @@ TEMPLATE -= fakelib

isEmpty(PROJECTROOT): PROJECTROOT = $$PWD/..
include($${PROJECTROOT}/common.pri)
#load($${PROJECTROOT}/common.pri)
CONFIG *= depend_includepath #?
preparePaths($$OUT_PWD/../out)
CONFIG += depend_includepath #?

PROJECT_SRCPATH = $$PWD
isEmpty(BUILD_DIR):BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR):BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR):BUILD_DIR=$$OUT_PWD #remove these?
PROJECT_LIBDIR = $$qtLongName($$BUILD_DIR/lib)

#for system include path
Expand Down
6 changes: 1 addition & 5 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ CONFIG *= qtav-buildlib
#var with '_' can not pass to pri?
STATICLINK = 0
PROJECTROOT = $$PWD/..
isEmpty(BUILD_DIR):BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR):BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR):BUILD_IN_SRC = yes
!isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/../out
include($${PROJECTROOT}/common.pri)
!include(libQtAV.pri): error("could not find libQtAV.pri")
preparePaths($$OUT_PWD/../out)

win32:RC_FILE = $${PROJECTROOT}/res/QtAV.rc
OTHER_FILES += $$RC_FILE
Expand Down

0 comments on commit 8d1d970

Please sign in to comment.