PhilBot
PhilBot

Reputation: 50

Qt QtCreator Detect if compiled from IDE in PRO file

I want to have certain variables defined when I am compiling my program with QtCreator versus our build system for an embedded Linux application. This would do things like turn on debugging I've been looking at the docs here: http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html, but have not found a solution. Ideally I'd like something like this:

ide {
    # Build release version
    #    CONFIG+=debug
    #    CONFIG+=declarative_debug
    CONFIG+=release

    ## Optimize flags
    QMAKE_CXXFLAGS_RELEASE += -O3
    QMAKE_CXXFLAGS_DEBUG += -O3
    QMAKE_LFLAGS += -O3
}

Upvotes: 1

Views: 411

Answers (1)

ratchet freak
ratchet freak

Reputation: 48196

in the project tab in QtCreator you can specify a custom environment variable that will be used for the build

with $$(VAR) you can query it during qmake and

ide = $$(IDE)

contains(ide, qtcreator){

    CONFIG+=debug
}else{

    # Build release version
    #    CONFIG+=debug
    #    CONFIG+=declarative_debug
    CONFIG+=release

    ## Optimize flags
    QMAKE_CXXFLAGS_RELEASE += -O3
    QMAKE_CXXFLAGS_DEBUG += -O3
    QMAKE_LFLAGS += -O3
}

Upvotes: 3

Related Questions