我正在使用odb并包括对 .pro文件的添加。

我发现读取“ QMAKE_EXTRA_COMPILERS + = odb”(倒数第二个代码块的底部)的行似乎撤消了我的INCLUDEPATH修改。如果我注释掉那行,则我的INCLUDEPATH再次正确,但是我当然不再生成必要的odb文件。

#-------------------------------------------------
#
# Project created by QtCreator 2014-06-11T15:13:24
#
#-------------------------------------------------

QT       += core
QT       -= gui

TARGET = DataAccess
TEMPLATE = lib

DEFINES += DATAACCESS_LIBRARY
CONFIG += c++11

SOURCES += dataaccess.cpp

HEADERS +=\
        dataaccess_global.h \
    dataaccess.h \
    operator.hxx

unix:!symbian {
    maemo5 {
        target.path = /opt/usr/lib
    } else {
        target.path = /usr/lib
    }
    INSTALLS += target
}


# Boost
INCLUDEPATH += $(BOOST_RT)
#LIBS += -L$(BOOST_RT)/stage/lib/ -lboost_serialization
#LIBS += -L$(BOOST_RT)/stage/lib/ -lboost_system

# List of header files that should be compiled with the ODB compiler.
#
ODB_FILES += operator.hxx

# ODB compiler flags.
#
ODB_FLAGS = --database sqlite --profile qt/basic --generate-schema --generate-query --generate-session

# Select the database we are going to use.
#
DEFINES += DATABASE_SQLITE

# Suppress unknown pragmas GCC warnings.
#
QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CXXFLAGS_WARN_ON -Wno-unknown-pragmas

# Link to the ODB runtime libraries.
#
LIBS += -lodb-sqlite
LIBS += -lodb-qt
LIBS += -lodb

# ODB compilation rules. Normally you don't need to change anything here.
#

# Add the Qt headers directory to the ODB include directory list.
#
ODB_FLAGS += -I$$[QT_INSTALL_HEADERS]

# Newer versions of QtCreator do builds in a separate directory. As a
# result, we need to append the source directory to ODB files.
#
for(dir, ODB_FILES) {
  ODB_PWD_FILES += $$PWD/$${dir}
}

odb.name = odb ${QMAKE_FILE_IN}
odb.input = ODB_PWD_FILES
odb.output = ${QMAKE_FILE_BASE}-odb.cxx
odb.commands = odb $$ODB_FLAGS ${QMAKE_FILE_IN}
odb.depends = $$ODB_PWD_FILES
odb.variable_out = SOURCES
odb.clean = ${QMAKE_FILE_BASE}-odb.cxx ${QMAKE_FILE_BASE}-odb.hxx ${QMAKE_FILE_BASE}-odb.ixx ${QMAKE_FILE_BASE}.sql
QMAKE_EXTRA_COMPILERS += odb # **<== problem line**

odbh.name = odb ${QMAKE_FILE_IN}
odbh.input = ODB_PWD_FILES
odbh.output = ${QMAKE_FILE_BASE}-odb.hxx
odbh.commands = @true
odbh.CONFIG = no_link
odbh.depends = ${QMAKE_FILE_BASE}-odb.cxx
QMAKE_EXTRA_COMPILERS += odbh

最佳答案

现在可以使用以下功能:

ODB_FLAGS + = -I $(BOOST_RT)(其中是INCLUDEPATH I中被“无效”的库。

在.pro文件中

关于c++ - QMAKE_EXTRA_COMPILERS变量使INCLUDEPATH无效,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24190362/

10-11 16:50