Skip to content

Commit 057e821

Browse files
committed
the toppest project includes root.pri is the root project
1 parent 4907a8a commit 057e821

6 files changed

+92
-73
lines changed

QtAV.pro

+1-63
Original file line numberDiff line numberDiff line change
@@ -14,81 +14,19 @@ OTHER_FILES += \
1414
templates/final.h templates/final.cpp
1515
#OTHER_FILES += config.test/mktest.sh
1616

17-
#cache mkspecs. compare mkspec with cached one. if not equal, remove old cache to run new compile tests
18-
#TODO: Qt5 does not have QMAKE_MKSPECS, use QMAKE_SPEC, QMAKE_XSPEC
19-
mkspecs_build = $$[QMAKE_MKSPECS]
20-
mkspecs_build ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
21-
!isEmpty(mkspecs_cached) {
22-
!isEqual(mkspecs_cached, $$mkspecs_build):CONFIG += recheck
23-
} else {
24-
CONFIG += recheck
25-
}
26-
27-
##TODO: BUILD_DIR=>BUILD_ROOT
28-
#if not empty, it means the parent project may already set it
29-
isEmpty(out_dir):out_dir = $$OUT_PWD
30-
out_dir ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
31-
isEmpty(SOURCE_ROOT):SOURCE_ROOT = $$PWD
32-
SOURCE_ROOT ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
33-
isEmpty(BUILD_DIR):BUILD_DIR=$$out_dir
34-
message("BUILD_DIR=$$BUILD_DIR")
35-
36-
greaterThan(QT_MAJOR_VERSION, 4) {
37-
#recheck:write_file($$BUILD_DIR/.qmake.cache) #FIXME: empty_file result in no qtCompileTest result in cache
38-
load(configure)
39-
} else {
40-
_QMAKE_CACHE_QT4_ = $$_QMAKE_CACHE_
41-
#_QMAKE_CACHE_QT4_ is built in and always not empty
42-
isEmpty(_QMAKE_CACHE_QT4_)|isEqual(_QMAKE_CACHE_QT4_,) {
43-
_QMAKE_CACHE_QT4_=$$BUILD_DIR/.qmake.cache
44-
}
45-
include(common.pri)
46-
#recheck:write_file($$BUILD_DIR/.qmake.cache) #FIXME: empty_file result in no qtCompileTest result in cache
47-
#use the following lines when building as a sub-project, write cache to this project src dir.
48-
#if build this project alone and do not have sub-project depends on this lib, those lines are not necessary
49-
####ASSUME compile tests and .qmake.cache is in project out root dir
50-
#vars in .qmake.cache will affect all projects in subdirs, even if qmake's working dir is not in .qmake.cache dir
51-
#write_file($$BUILD_DIR/.qmake.cache) ##TODO: erase the existing lines!!
52-
include(configure.prf)
53-
#clear config.log iff reconfigure is required
54-
write_file($$QMAKE_CONFIG_LOG)
55-
#cache() is available after include configure.prf
56-
#load(configure.prf) #what's the difference?
57-
message("cache: $$_QMAKE_CACHE_QT4_")
58-
}
59-
cache(BUILD_DIR, set, BUILD_DIR)
60-
#cache(BUILD_ROOT, set, BUILD_DIR)
61-
cache(SOURCE_ROOT, set, SOURCE_ROOT)
62-
cache(mkspecs_cached, set, mkspecs_build)
6317

6418
EssentialDepends = avutil avcodec avformat swscale
6519
OptionalDepends = portaudio direct2d gdiplus gl #openal
66-
6720
unix {
6821
isEqual(QT_MAJOR_VERSION, 4) {
6922
OptionalDepends += xv
7023
}
7124
}
7225

73-
for(d, EssentialDepends) {
74-
!config_$$d {
75-
CONFIG *= recheck
76-
}
77-
qtCompileTest($$d)|error("$$d is required, but compiler can not find it")
78-
# CONFIG -= recheck
79-
}
80-
message("checking for optional features...")
81-
for(d, OptionalDepends) {
82-
qtCompileTest($$d)
83-
}
84-
26+
include(root.pri)
8527

8628
PACKAGE_VERSION = 1.1.11
8729
PACKAGE_NAME= QtAV
8830

8931
include(pack.pri)
9032
#packageSet(1.1.11, QtAV)
91-
92-
!isEmpty(EssentialDepends)|!isEmpty(OptionalDepends) {
93-
message("To recheck the dependencies, run qmake with argument 'CONFIG+=recheck'")
94-
}

configure.prf

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Designed by Wang Bin(Lucas Wang). 2013 <[email protected]>
2+
13
### ONLY FOR Qt4. common.pri must be included before it so that write_file() can be used#######
24
### .qmake.cache MUST be created before it!
35
####ASSUME compile tests and .qmake.cache is in project out root dir

doc/UseQtAVinYourProjects-zh_CN.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ myproject/myproject.pro
1010
TEMPLATE = subdirs
1111
SUBDIRS += libQtAV myplayer
1212
myplayer.depends += libQtAV
13-
libQtAV.file = QtAV/src/libQtAV.pro
13+
libQtAV.file = QtAV/QtAV.pro
14+
include(QtAV/root.pri)
1415

1516
###2. 把 QtAV 放到myproject
1617

@@ -20,6 +21,7 @@ myproject/myproject.pro
2021

2122
> myproject/myproject.pro
2223
> myproject/myplayer/myplayer.pro
24+
> myproject/QtAV/QtAV.pro
2325
> myproject/QtAV/src/libQtAV.pro
2426
> myproject/QtAV/src/libQtAV.pri
2527
@@ -31,11 +33,13 @@ myproject/myproject.pro
3133

3234
###4. 生成 Makefile
3335

34-
`qmake -r BUILD_DIR=some_dir`
36+
qmake
3537

36-
必须使用参数 **_-r_****_BUILD_DIR=some_dir_**, 否则可能会出现依赖问题.
38+
or
3739

38-
如果使用 QtCreator 来构建, 你可以点 _Projects_->_Build Steps_->_qmake_->_Additional arguments_, 添加 BUILD_DIR=your/buid/dir
40+
qmake -r
3941

4042
###5. make
41-
player 会生成在 $$BUILD_DIR/bin. 在windows下, QtAV 的 dll文件也会在那里生成
43+
player 会生成在编译目录下的bin目录. 在windows下, QtAV 的 dll文件也会在那里生成
44+
45+
注意:windows 下如果用`qmake`命令(命令行下。QtCreator 默认使用`qmake -r`),则可能需要运行`qmake`两次,否则 make 可能失败

doc/UseQtAVinYourProjects.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ myproject/myproject.pro
1010
TEMPLATE = subdirs
1111
SUBDIRS += libQtAV myplayer
1212
myplayer.depends += libQtAV
13-
libQtAV.file = QtAV/src/libQtAV.pro
13+
libQtAV.file = QtAV/QtAV.pro
14+
include(QtAV/root.pri)
1415

1516
###2. Put QtAV to myproject
1617

@@ -20,6 +21,7 @@ the directory now is
2021

2122
> myproject/myproject.pro
2223
> myproject/myplayer/myplayer.pro
24+
> myproject/QtAV/QtAV.pro
2325
> myproject/QtAV/src/libQtAV.pro
2426
> myproject/QtAV/src/libQtAV.pri
2527
@@ -30,11 +32,13 @@ in myproject/myplayer/myplayer.pro, add
3032

3133
###4. generate Makefile
3234

33-
`qmake -r BUILD_DIR=some_dir`
35+
qmake
3436

35-
YOU MUST use parameter **_-r_** and **_BUILD_DIR=some_dir_**, or the dependence will be broken when building due to my pro structure.
37+
or
3638

37-
If you are using QtCreator to build the project, you should go to _Projects_->_Build Steps_->_qmake_->_Additional arguments_, add BUILD_DIR=your/buid/dir
39+
qmake -r
3840

3941
###5. make
40-
you player binary will be created in $$BUILD_DIR/bin. If you are in windows, the QtAV dll also be there
42+
you player binary will be created in `bin` under build dir. If you are in windows, the QtAV dll also be there
43+
44+
Note: for windows user, if you run `qmake`(command line build. QtCreator uses `qmake -r` by default) you may run `qmake` twice. otherwise make may fail.

pack.pri

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Designed by Wang Bin(Lucas Wang). 2013 <[email protected]>
2+
13
##TODO: Why use function to add makefile target failed
24
# add a make command
35
defineReplace(mcmd) {

root.pri

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#Designed by Wang Bin(Lucas Wang). 2013 <[email protected]>
2+
3+
#cache mkspecs. compare mkspec with cached one. if not equal, remove old cache to run new compile tests
4+
#TODO: Qt5 does not have QMAKE_MKSPECS, use QMAKE_SPEC, QMAKE_XSPEC
5+
mkspecs_build = $$[QMAKE_MKSPECS]
6+
mkspecs_build ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
7+
!isEmpty(mkspecs_cached) {
8+
!isEqual(mkspecs_cached, $$mkspecs_build):CONFIG += recheck
9+
} else {
10+
CONFIG += recheck
11+
}
12+
13+
##TODO: BUILD_DIR=>BUILD_ROOT
14+
#if not empty, it means the parent project may already set it
15+
isEmpty(out_dir):out_dir = $$OUT_PWD
16+
out_dir ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
17+
isEmpty(SOURCE_ROOT):SOURCE_ROOT = $$PWD
18+
SOURCE_ROOT ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/'
19+
isEmpty(BUILD_DIR):BUILD_DIR=$$out_dir
20+
message("BUILD_DIR=$$BUILD_DIR")
21+
22+
greaterThan(QT_MAJOR_VERSION, 4) {
23+
#recheck:write_file($$BUILD_DIR/.qmake.cache) #FIXME: empty_file result in no qtCompileTest result in cache
24+
load(configure)
25+
} else {
26+
_QMAKE_CACHE_QT4_ = $$_QMAKE_CACHE_
27+
#_QMAKE_CACHE_QT4_ is built in and always not empty
28+
isEmpty(_QMAKE_CACHE_QT4_)|isEqual(_QMAKE_CACHE_QT4_,) {
29+
_QMAKE_CACHE_QT4_=$$BUILD_DIR/.qmake.cache
30+
}
31+
include(common.pri)
32+
#recheck:write_file($$BUILD_DIR/.qmake.cache) #FIXME: empty_file result in no qtCompileTest result in cache
33+
#use the following lines when building as a sub-project, write cache to this project src dir.
34+
#if build this project alone and do not have sub-project depends on this lib, those lines are not necessary
35+
####ASSUME compile tests and .qmake.cache is in project out root dir
36+
#vars in .qmake.cache will affect all projects in subdirs, even if qmake's working dir is not in .qmake.cache dir
37+
#write_file($$BUILD_DIR/.qmake.cache) ##TODO: erase the existing lines!!
38+
include(configure.prf)
39+
#clear config.log iff reconfigure is required
40+
write_file($$QMAKE_CONFIG_LOG)
41+
#cache() is available after include configure.prf
42+
#load(configure.prf) #what's the difference?
43+
message("cache: $$_QMAKE_CACHE_QT4_")
44+
}
45+
cache(BUILD_DIR, set, BUILD_DIR)
46+
#cache(BUILD_ROOT, set, BUILD_DIR)
47+
cache(SOURCE_ROOT, set, SOURCE_ROOT)
48+
cache(mkspecs_cached, set, mkspecs_build)
49+
50+
#config.tests
51+
isEmpty(EssentialDepends) {
52+
for(d, EssentialDepends) {
53+
!config_$$d {
54+
CONFIG *= recheck
55+
}
56+
qtCompileTest($$d)|error("$$d is required, but compiler can not find it")
57+
# CONFIG -= recheck
58+
}
59+
}
60+
!isEmpty(OptionalDepends) {
61+
message("checking for optional features...")
62+
for(d, OptionalDepends) {
63+
qtCompileTest($$d)
64+
}
65+
}
66+
67+
!isEmpty(EssentialDepends)|!isEmpty(OptionalDepends) {
68+
message("To recheck the dependencies, run qmake with argument 'CONFIG+=recheck'")
69+
}

0 commit comments

Comments
 (0)