First, manually build the SDKInclude
directory path where U want deploy your module, like:
{root dir}/sdk/include
And add a text file sign.txt
into SDKInclude
Directory, its content just a symbol:
#
Second, add a line to .pro
:
SDKInclude = $$PWD\..\..\sdk\include
Then add:
# SDK Deploy -------------------------------------------------------------------------------------------
# 作用
#
# a. 将头文件发布到SDK目录下
h_searchlist += *.h
for(searchvar, h_searchlist) {
hlist += $$files($$searchvar, true)
}
#message($$hlist"(hlist)")
for (hvar, hlist) {
_desDirpath = $$SDKInclude/$$TARGET # 目标头文件根目录
_srcFilepath = $$absolute_path($$hvar) # 源头文件绝对路径
_desReleFilepath = $$relative_path($$_srcFilepath, $$_desDirpath) # sdk 头文件引用路径
_srcReleFilepath = $$relative_path($$_srcFilepath, $$_PRO_FILE_PWD_) # 源头文件相对于项目的相对路径
_desFilepath = $$_desDirpath/$$_srcReleFilepath # 目标头文件的绝对路径
SDK_H_FILE_CONTENT = "$$cat($$SDKInclude/sign.txt)include \"../$$_desReleFilepath\""
write_file($$_desFilepath, SDK_H_FILE_CONTENT)
# message($$SDK_H_FILE_CONTENT)
}
# \end SDK Deploy -------------------------------------------------------------------------------------------
Last, run qmake command on .pro
by right mouse-click, and U will get:
And every *.h
file in SDKInclude
will becomes:
#include "../../../../src/{path}/file_name.h"
Update:
- Actually, there is another efficient way to add
#
symbol to deployed header file, and it says:
SDK_H_FILE_CONTENT = $$LITERAL_HASH"include \"../$$_desReleFilepath\""
Yeah, it simply just use