From c09160d8f5da36849b560587b26bead26ebc9e83 Mon Sep 17 00:00:00 2001 From: milek Date: Mon, 25 Mar 2019 19:53:44 +0000 Subject: [PATCH] uart now optional, macos openal fix --- CMakeLists.txt | 24 ++++++++++++++---------- Globals.cpp | 2 ++ Globals.h | 6 +++++- audio.h | 5 +++++ drivermode.cpp | 4 ++++ drivermode.h | 6 +++++- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10f6f35f..39a7c470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_CXX_STANDARD 14) include_directories("." "Console" "McZapkie") file(GLOB HEADERS "*.h" "Console/*.h" "McZapkie/*.h") +option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" OFF) +option(WITH_UART "Compile with libserialport" OFF) + set(SOURCES "Texture.cpp" "Timer.cpp" @@ -66,7 +69,6 @@ set(SOURCES "material.cpp" "lua.cpp" "stdafx.cpp" -"uart.cpp" "messaging.cpp" "scene.cpp" "scenenode.cpp" @@ -105,8 +107,6 @@ set(SOURCES "imgui/imgui_impl_glfw.cpp" ) -option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" OFF) - if (USE_IMGUI_GL3) set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp") else() @@ -114,6 +114,10 @@ else() set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl2.cpp") endif() +if (WITH_UART) + set(SOURCES ${SOURCES} "uart.cpp") +endif() + set (PREFIX "") if (WIN32) @@ -146,7 +150,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() @@ -202,9 +206,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) @@ -224,9 +226,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() if (WIN32) target_link_libraries(${PROJECT_NAME} ws2_32) diff --git a/Globals.cpp b/Globals.cpp index d9a6ad25..f06948bf 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -647,6 +647,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 ); @@ -685,6 +686,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 54670a23..fd6f9280 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 ea205de8..10544528 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 421bf85f..056b7598 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 { @@ -75,7 +77,9 @@ private: #ifdef _WIN32 Console console; #endif +#ifdef WITH_UART std::unique_ptr uart; +#endif std::unique_ptr telemetry; bool init();