Reputation: 267
I create qmake project with "Subdirs" template, header library and testing console-application.
Main.pro:
TEMPLATE = subdirs
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += ordered
SUBDIRS += tests Config
Config.pro:
HEADERS += \
Reader.h \
Builder.h\
Store.h\
Setter.h
tests.pro:
HEADERS += \
CheckConfig.h \
CheckReader.h \
JsonGenerator.h \
Setter.h
SOURCES += \
CheckReader.cpp \
JsonGenerator.cpp \
main.cpp \
Setter.cpp
#my util functions and vars
include(../common/settings.pri)
include(../common/common.pri)
#generate application config
ConsoleApplication(test)
#enable flags for exports libs in depends.pri file
EnableModuleExport()
include(../Config/depends.pri)
#setup includepath for Config library
SetHeadersPath(../)
qmake generate makefile for project Config.pro, after run build with gcc, I have error. That's okay, because I did not ask the build targets and no function main(). It is necessary to disable the generation of a Makefile for qmake, or generate a makefile without build targets.
I did the project Config as fake static library, but it is not the best solution
Upvotes: 1
Views: 1534
Reputation: 49
Comment system not working for me, so one needs the following lines:
TEMPLATE=lib
LIB=dummy
HEADERS=...
headers.files=$$HEADERS
headers.path=$$PREFIX/include
INSTALLS+=headers
Upvotes: 0
Reputation: 49
@Kopysov Evgeniy
requires(false) prevents the install target from running too! Header only libraries still need to be installed.
Upvotes: 0
Reputation: 267
In Headear-only library need use requires(false)
HEADERS += <your headers files>
#needed in QtCreator for correct display "#include" directives
INCLUDEPATH += <your deps>
requires(false) #disable building
Upvotes: 1