diff --git a/CMakeLists.txt b/CMakeLists.txt index 908b3876..22b66f7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ file(GLOB HEADERS "*.h" "network/backend/*.h" "widgets/*.h") +option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" ON) +option(WITH_UART "Compile with libserialport" OFF) + set(SOURCES "Texture.cpp" "Timer.cpp" @@ -86,7 +89,6 @@ set(SOURCES "material.cpp" "lua.cpp" "stdafx.cpp" -"uart.cpp" "messaging.cpp" "scene.cpp" "scenenode.cpp" @@ -150,8 +152,6 @@ set(SOURCES "imgui/imgui_impl_glfw.cpp" ) -option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" ON) - if (USE_IMGUI_GL3) set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp") else() @@ -159,6 +159,10 @@ else() set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl2.cpp") endif() +if (WITH_UART) + set(SOURCES ${SOURCES} "uart.cpp") +endif() + set (PREFIX "") if (WIN32) @@ -188,7 +192,7 @@ if (WIN32) set(OPENAL_LIBRARY ${OPENAL_LIBRARY} "${DEPS_DIR}/openal/lib/${ARCH}/OpenAL32.lib") set(LIBSNDFILE_LIBRARY ${LIBSNDFILE_LIBRARY} "${DEPS_DIR}/libsndfile/lib/${ARCH}/libsndfile-1.lib") set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARIES} "${DEPS_DIR}/luajit/lib/${ARCH}/lua51.lib") - set(PYTHON_LIBRARY ${PYTHON_LIBRARY} "${DEPS_DIR}/python/lib/${ARCH}/python27.lib") + set(PYTHON_LIBRARY ${PYTHON_LIBRARY} "${DEPS_DIR}/python/lib/${ARCH}/python27.lib") set(libserialport_LIBRARY ${LIBSERIALPORT_LIBRARY} "${DEPS_DIR}/libserialport/lib/${ARCH}/libserialport-0.lib") endif() @@ -230,9 +234,7 @@ include_directories(${PYTHON_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES}) find_package(PNG REQUIRED) -include_directories(${PNG_INCLUDE_DIRS} ${PNG_PNG_INCLUDE_DIR}) -target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARIES}) -target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARY}) +target_link_libraries(${PROJECT_NAME} PNG::PNG) find_package(Threads REQUIRED) target_link_libraries(${PROJECT_NAME} Threads::Threads) @@ -252,9 +254,11 @@ find_package(LuaJIT REQUIRED) include_directories(${LUAJIT_INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME} ${LUAJIT_LIBRARIES}) -find_package(libserialport REQUIRED) -include_directories(${libserialport_INCLUDE_DIR}) -target_link_libraries(${PROJECT_NAME} ${libserialport_LIBRARY}) +if (WITH_UART) + find_package(libserialport REQUIRED) + include_directories(${libserialport_INCLUDE_DIR}) + target_link_libraries(${PROJECT_NAME} ${libserialport_LIBRARY}) +endif() find_package(ASIO REQUIRED) target_link_libraries(${PROJECT_NAME} ASIO::ASIO) diff --git a/Globals.cpp b/Globals.cpp index 5f7c1e1d..9c9c4f11 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -643,6 +643,7 @@ global_settings::ConfigParse(cParser &Parser) { Parser.getTokens(1); Parser >> Global.screenshot_dir; } +#ifdef WITH_UART else if( token == "uart" ) { uart_conf.enable = true; Parser.getTokens( 3, false ); @@ -681,6 +682,7 @@ global_settings::ConfigParse(cParser &Parser) { Parser.getTokens( 1 ); Parser >> uart_conf.debug; } +#endif else if (token == "loadinglog") { Parser.getTokens( 1 ); Parser >> loading_log; diff --git a/Globals.h b/Globals.h index 307dc642..3e4421c5 100644 --- a/Globals.h +++ b/Globals.h @@ -14,10 +14,12 @@ http://mozilla.org/MPL/2.0/. #include "dumb3d.h" #include "Float3d.h" #include "light.h" -#include "uart.h" #include "utilities.h" #include "motiontelemetry.h" #include "version.h" +#ifdef WITH_UART +#include "uart.h" +#endif struct global_settings { // members @@ -168,7 +170,9 @@ struct global_settings { 0, 0, 0, 0, 0, 0, 0 }; int iCalibrateOutDebugInfo { -1 }; // numer wyjścia kalibrowanego dla którego wyświetlać informacje podczas kalibracji int iPoKeysPWM[ 7 ] = { 0, 1, 2, 3, 4, 5, 6 }; // numery wejść dla PWM +#ifdef WITH_UART uart_input::conf_t uart_conf; +#endif // multiplayer int iMultiplayer{ 0 }; // blokada działania niektórych eventów na rzecz kominikacji // other diff --git a/audio.h b/audio.h index f8c2fe9c..d84d54a1 100644 --- a/audio.h +++ b/audio.h @@ -9,8 +9,13 @@ http://mozilla.org/MPL/2.0/. #pragma once +#ifdef __APPLE__ +#include +#include +#else #include #include +#endif namespace audio { diff --git a/drivermode.cpp b/drivermode.cpp index fd07a8b8..ed15e5cc 100644 --- a/drivermode.cpp +++ b/drivermode.cpp @@ -45,9 +45,11 @@ driver_mode::drivermode_input::poll() { if( true == Global.InputGamepad ) { gamepad.poll(); } +#ifdef WITH_UART if( uart != nullptr ) { uart->poll(); } +#endif /* // TBD, TODO: wrap current command in object, include other input sources? input::command = ( @@ -67,10 +69,12 @@ driver_mode::drivermode_input::init() { if( true == Global.InputGamepad ) { gamepad.init(); } +#ifdef WITH_UART if( true == Global.uart_conf.enable ) { uart = std::make_unique(); uart->init(); } +#endif if (Global.motiontelemetry_conf.enable) telemetry = std::make_unique(); diff --git a/drivermode.h b/drivermode.h index ec1756e6..86044961 100644 --- a/drivermode.h +++ b/drivermode.h @@ -14,10 +14,12 @@ http://mozilla.org/MPL/2.0/. #include "driverkeyboardinput.h" #include "drivermouseinput.h" #include "gamepadinput.h" -#include "uart.h" #include "Console.h" #include "Camera.h" #include "Classes.h" +#ifdef WITH_UART +#include "uart.h" +#endif class driver_mode : public application_mode { @@ -77,7 +79,9 @@ private: #ifdef _WIN32 Console console; #endif +#ifdef WITH_UART std::unique_ptr uart; +#endif std::unique_ptr telemetry; bool init();