From 0349d8f212b3c10bb8a3f10ced86b729e77678c7 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 10 Mar 2014 21:50:54 +0100 Subject: [PATCH] Added a build flag for FSX specific code FSX SimConnect code is build and linked only if enabled by the build configuration. refs #145 --- config.pri | 1 + externals.pri | 3 --- libraries.pri | 6 ++++++ src/blackcore/blackcore.pro | 9 ++++++--- src/blackcore/context_settings.h | 1 + src/blackcore/context_simulator_impl.cpp | 19 ++++++++++++++++--- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/config.pri b/config.pri index 78c230f5a..aa9af2967 100644 --- a/config.pri +++ b/config.pri @@ -26,4 +26,5 @@ BLACK_CONFIG += BlackSound BLACK_CONFIG += BlackSim BLACK_CONFIG += Samples BLACK_CONFIG += Unittests +#BLACK_CONFIG += FSX #BLACK_CONFIG += Doxygen diff --git a/externals.pri b/externals.pri index e898acff4..56e45ec92 100644 --- a/externals.pri +++ b/externals.pri @@ -21,7 +21,6 @@ isEmpty(EXTERNALDIR) { } # Everything is fine. Add the include path -message("Found externals: $$EXTERNALDIR") INCLUDEPATH *= $$EXTERNALDIR/include # and the library path depending on the used compiler @@ -50,11 +49,9 @@ linux-g++ { GCC64 = $$system($$QMAKE_CXX -Q --help=target | grep m64) contains(GCC64,[enabled]) { LIBS *= -L$$EXTERNALDIR/linux64/lib - message("64 bit") } else { LIBS *= -L$$EXTERNALDIR/linux32/lib - message("32 bit") } } diff --git a/libraries.pri b/libraries.pri index d296ba18f..e04010cbc 100644 --- a/libraries.pri +++ b/libraries.pri @@ -8,6 +8,12 @@ blackgui { blackcore { LIBS += -lblackcore -lvatlib + + win32 { + contains(BLACK_CONFIG, FSX) { + LIBS += -lSimConnect + } + } } blacksound { diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index 294a20317..37776b0cc 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -37,12 +37,15 @@ DEFINES += LOG_IN_FILE HEADERS += *.h SOURCES += *.cpp -HEADERS += $$PWD/fsx/*.h -SOURCES += $$PWD/fsx/*.cpp - win32 { HEADERS += $$PWD/win/*.h SOURCES += $$PWD/win/*.cpp + + contains(BLACK_CONFIG, FSX) { + DEFINES += BLACK_WITH_FSX + HEADERS += $$PWD/fsx/*.h + SOURCES += $$PWD/fsx/*.cpp + } } win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib diff --git a/src/blackcore/context_settings.h b/src/blackcore/context_settings.h index 1652900a2..2fbb557bc 100644 --- a/src/blackcore/context_settings.h +++ b/src/blackcore/context_settings.h @@ -34,6 +34,7 @@ namespace BlackCore public: + //! \brief Settings type enum SettingsType { SettingsHotKeys, diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index a91b588bf..a811c7fd6 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -5,7 +5,10 @@ #include "context_simulator_impl.h" #include "coreruntime.h" -#include "fsx/simulator_fsx.h" + +#ifdef BLACK_WITH_FSX + #include "fsx/simulator_fsx.h" +#endif using namespace BlackMisc; using namespace BlackMisc::PhysicalQuantities; @@ -17,13 +20,17 @@ namespace BlackCore // Init this context CContextSimulator::CContextSimulator(QObject *parent) : IContextSimulator(parent), - m_simulator(new BlackCore::FSX::CSimulatorFSX(this)), + m_simulator(nullptr), m_updateTimer(nullptr), m_contextNetwork(nullptr) - { m_updateTimer = new QTimer(this); + +#ifdef BLACK_WITH_FSX + m_simulator = new BlackCore::FSX::CSimulatorFSX(this); connect(m_simulator, &ISimulator::connectionChanged, this, &CContextSimulator::setConnectionStatus); +#endif + connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft); } @@ -34,6 +41,9 @@ namespace BlackCore bool CContextSimulator::isConnected() const { + if (!m_simulator) + return false; + return m_simulator->isConnected(); } @@ -44,6 +54,9 @@ namespace BlackCore void CContextSimulator::updateOwnAircraft() { + if (!m_simulator) + return; + m_ownAircraft = m_simulator->getOwnAircraft(); if (!m_contextNetwork)