Enable Windows build with Qt5.5+ & MinGW-w64 (#4150)

* [Windows][MinGW] Update some WIN32 macro checks in source code to be MSVC-specific (not needed for GCC-based builds).

* [build] CMakeLists updates:
  Adjust for Windows MinGW builds: now fully compatible with Qt5.5+ and MinGW-w64 toolchain (included in Qt installs);
  Add option to specify path to required libraries/includes (instead of hard-coding `c:\programs`);
  Add package check for Python and use found executable name;
  Remove custom FindSdl package handler in favor of stock (and improved) CMake one (still works with Windows);
  Do not force SIMU_AUDIO and LUA_COMPILER in SIMU builds (leave it up to user);
  Add SIMU_LUA_COMPILER option specifically for SIMU builds (default = ON);

* [build][Windows] Rewrite/Fix Windows Companion `install` target, with two options:
    a) just copy supporting Qt and c++ DLLs to build folder so programs can be quickly be run from there (this is default and similar to the old behavior);
    b) full installation to CMAKE_INSTALL_PREFIX path, including all binaries, supporting DLLs, language files, and OTx utilities.
  Option b) can be selected with new WIN_DO_FULL_INSTALL parameter;
  Also cleans up the Linux install a bit and consolidates the OS X parts;

* [simulator][Windows] Add option to build Windows simulator with system console/terminal enabled (both standalone and when launched from Companion). Mostly useful for debug as it gives output messages much sooner in the startup process than the current debug console. Also helpful because you don't have to open it manually on every launch, and it remembers last window position and size. Possible candidate for a user-selectable runtime option in the future.

* [Windows] Fix MSVC build issues.

* [build] More build fixes:
  Use a customized FindSDL.cmake script again due to bugs and deficiencies in the official version (based on script from CMake v3.7);
  Fixes missing SDL DLL error in NSIS installer);
  Use string for Timers option (checkbox in GUI is confusing);
  Remove an unused variable.

* [simu][Windows] Fix f_getcwd() cutting off too many characters (fixes SD browser interactions).
This commit is contained in:
Max Paperno
2016-12-24 00:11:07 +01:00
committed by Bertrand Songis
parent 06b0694f03
commit e90bd0fd70
24 changed files with 527 additions and 313 deletions
+129 -67
View File
@@ -1,4 +1,4 @@
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR})
set(COMPANION_NAME "companion${C9X_NAME_SUFFIX}")
set(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}")
@@ -38,28 +38,47 @@ if(TABLE_LAYOUT)
message(STATUS "Using QTableWidget")
endif()
if(WIN32)
option(WIN_DO_FULL_INSTALL "'install' target will perform a full installation into CMAKE_INSTALL_PREFIX path, otherwise only supporting DLLs are copied to binaries folder (default)" OFF)
option(WIN_USE_CONSOLE "Open a Windows command console for Simulator debug output." OFF)
if(WIN_USE_CONSOLE)
add_definitions(-DWIN_USE_CONSOLE_STDIO)
endif()
endif()
if(SDL_FOUND)
include_directories(${SDL_INCLUDE_DIR})
add_definitions(-DSIMU_AUDIO)
add_definitions(-DJOYSTICKS)
else()
remove_definitions(-DSIMU_AUDIO)
endif()
message(STATUS "Looking for QT lupdate ")
find_package(Lupdate)
if(LUPDATE_FOUND)
message("QT lupdate: " ${LUPDATE_EXECUTABLE})
message("Qt lupdate: " ${LUPDATE_EXECUTABLE})
else()
message("QT lupdate not found!")
message("Qt lupdate not found, 'translations' target will not be availabe.")
endif()
add_definitions(-DSIMU)
add_definitions(-DQXT_STATIC)
if(MSVC)
set(CMAKE_CXX_FLAGS "/EHsc /LD /MP")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")
include_directories(${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes C:/Programs/dirent/include)
link_directories(C:/Programs/pthreads/Pre-built.2/lib/)
set(PTHREAD_LIBRARY pthreadVC2.lib)
if (NOT MSVC AND ${CMAKE_VERSION} VERSION_LESS 3.1.0})
message("companion: adding -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if(WIN32)
include_directories(SYSTEM ${WIN_INCLUDE_DIRS})
if(MSVC)
set(CMAKE_CXX_FLAGS "/EHsc /LD /MP")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")
message("companion: using MSVC with ${CMAKE_CXX_FLAGS}")
elseif(MINGW)
# struct packing breaks on MinGW w/out -mno-ms-bitfields: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 & http://stackoverflow.com/questions/24015852/struct-packing-and-alignment-with-mingw
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields -mwindows")
message("companion: using MinGW with ${CMAKE_CXX_FLAGS}")
endif()
else()
set(PTHREAD_LIBRARY pthread)
add_definitions(-Wall)
@@ -229,7 +248,8 @@ add_executable(${COMPANION_NAME} MACOSX_BUNDLE WIN32 ${companion_SRCS} ${compani
add_dependencies(${COMPANION_NAME} gen_qrc)
qt5_use_modules(${COMPANION_NAME} Core Widgets Network)
target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit simulation common qcustomplot shared storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY})
target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit simulation common qcustomplot shared storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
############# Standalone simu ###############
@@ -249,60 +269,113 @@ if(WIN32)
set(simu_SRCS ${simu_SRCS} icon.rc)
endif()
add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE WIN32 ${simu_SRCS} ${companion_RCC})
add_dependencies(${SIMULATOR_NAME} gen_qrc)
# TODO not the same link command than companion?
target_link_libraries(${SIMULATOR_NAME} PRIVATE simulation common storage qxtcommandoptions ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${OPENTX_SIMULATOR_LIBS})
############# Packaging ####################
message(STATUS ${CMAKE_BINARY_DIR} ${CMAKE_INSTALL_PREFIX}/bin)
# TODO not the same link command than companion?
target_link_libraries(${SIMULATOR_NAME} PRIVATE simulation common storage qxtcommandoptions ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${OPENTX_SIMULATOR_LIBS} ${WIN_LINK_LIBRARIES})
############# Install ####################
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "install " ${CMAKE_BINARY_DIR} " to " ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(DIRECTORY ${CMAKE_BINARY_DIR}/ DESTINATION ${SIMULATOR_LIB_PATH} USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN "libopentx-*${CMAKE_SHARED_LIBRARY_SUFFIX}"
PATTERN "CMakeFiles" EXCLUDE
PATTERN "_CPack_Packages" EXCLUDE
PATTERN "companion" EXCLUDE
PATTERN "radio" EXCLUDE
)
file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/libopentx-*${CMAKE_SHARED_LIBRARY_SUFFIX}")
install(FILES ${simulator_plugins} DESTINATION "${SIMULATOR_LIB_PATH}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop)
if(${CMAKE_INSTALL_PREFIX} MATCHES "/usr/local")
install(FILES images/linuxicons/16x16/companion.png DESTINATION /usr/share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/22x22/companion.png DESTINATION /usr/share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/24x24/companion.png DESTINATION /usr/share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/32x32/companion.png DESTINATION /usr/share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/48x48/companion.png DESTINATION /usr/share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/128x128/companion.png DESTINATION /usr/share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/256x256/companion.png DESTINATION /usr/share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/512x512/companion.png DESTINATION /usr/share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/scalable/companion.svg DESTINATION /usr/share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg)
install(FILES ../targets/linux/45-companion-taranis.rules DESTINATION /lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-taranis.rules)
else()
install(FILES images/linuxicons/16x16/companion.png DESTINATION share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/22x22/companion.png DESTINATION share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/24x24/companion.png DESTINATION share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/32x32/companion.png DESTINATION share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/48x48/companion.png DESTINATION share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/128x128/companion.png DESTINATION share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/256x256/companion.png DESTINATION share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/512x512/companion.png DESTINATION share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/scalable/companion.svg DESTINATION share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg)
install(FILES ../targets/linux/45-companion-taranis.rules DESTINATION lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-taranis.rules)
set(INSTALL_TEMP_SHR_PFX "/usr/")
set(INSTALL_TEMP_LIB_PFX "/")
endif()
install(FILES images/linuxicons/16x16/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/22x22/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/24x24/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/32x32/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/48x48/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/128x128/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/256x256/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/512x512/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png)
install(FILES images/linuxicons/scalable/companion.svg DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg)
install(FILES ../targets/linux/45-companion-taranis.rules DESTINATION ${INSTALL_TEMP_LIB_PFX}lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-taranis.rules)
# Linux specific code
set(OperatingSystem "Linux")
elseif(WIN32)
get_target_property(QtCore_LOCATION Qt5::Core LOCATION)
get_filename_component(QT_DLL_DIR ${QtCore_LOCATION} PATH)
get_filename_component(SDL_DIR ${SDL_LIBRARY} PATH)
install(FILES ${QT_DLL_DIR}/icudt54.dll ${QT_DLL_DIR}/icuin54.dll ${QT_DLL_DIR}/icuuc54.dll ${QT_DLL_DIR}/Qt5Core.dll ${QT_DLL_DIR}/Qt5Gui.dll ${QT_DLL_DIR}/Qt5Widgets.dll ${QT_DLL_DIR}/Qt5Xml.dll ${QT_DLL_DIR}/Qt5Network.dll ${QT_DLL_DIR}/Qt5PrintSupport.dll ${QT_DLL_DIR}/Qt5Multimedia.dll ${SDL_DIR}/SDL.dll DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>)
install(FILES ${QT_DLL_DIR}/icudt54.dll ${QT_DLL_DIR}/icuin54.dll ${QT_DLL_DIR}/icuuc54.dll ${QT_DLL_DIR}/Qt5Cored.dll ${QT_DLL_DIR}/Qt5Guid.dll ${QT_DLL_DIR}/Qt5Widgetsd.dll ${QT_DLL_DIR}/Qt5Xmld.dll ${QT_DLL_DIR}/Qt5Networkd.dll ${QT_DLL_DIR}/Qt5PrintSupportd.dll ${QT_DLL_DIR}/Qt5Multimediad.dll ${SDL_DIR}/SDL.dll DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>)
endif()
set(INSTALL_TEMP_QTDLL_FILES Qt5Core Qt5Gui Qt5Widgets Qt5Xml Qt5Network Qt5PrintSupport Qt5Multimedia)
set(INSTALL_TEMP_ICUDLL_FILES icudt54.dll icuin54.dll icuuc54.dll)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(INSTALL_TEMP_QTDLL_SFX "d")
endif()
if(NOT WIN_DO_FULL_INSTALL)
# Just copy supporting DLLs to build folder
set(INSTALL_DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
message(STATUS "Partial install to " ${INSTALL_DESTINATION})
else()
# Full Windows installation with all supporting files
set(INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX})
message(STATUS "Full install to " ${INSTALL_DESTINATION})
# companion & simulator binaries
install(TARGETS ${COMPANION_NAME} DESTINATION ${INSTALL_DESTINATION})
install(TARGETS ${SIMULATOR_NAME} DESTINATION ${INSTALL_DESTINATION})
file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/*opentx-*-simulator${CMAKE_SHARED_LIBRARY_SUFFIX}")
install(FILES ${simulator_plugins} DESTINATION "${INSTALL_DESTINATION}")
# language files
file(GLOB language_files "${CMAKE_BINARY_DIR}/companion/src/companion_*.qm")
install(FILES ${language_files} DESTINATION "${INSTALL_DESTINATION}/lang")
# supporting utilities
set(INSTALL_TEMP_FILES avrdude.exe avrdude.conf dfu-util.exe libusb0.dll libusb-1.0.dll)
foreach(tmpfile ${INSTALL_TEMP_FILES})
install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/${tmpfile}" DESTINATION ${INSTALL_DESTINATION})
endforeach()
endif() # WIN_DO_FULL_INSTALL
# Qt dlls
foreach(tmpfile ${INSTALL_TEMP_QTDLL_FILES})
install(FILES ${QT_DLL_DIR}/${tmpfile}${INSTALL_TEMP_QTDLL_SFX}.dll DESTINATION ${INSTALL_DESTINATION})
endforeach()
install(FILES ${QT_DLL_DIR}/../plugins/platforms/qwindows${INSTALL_TEMP_QTDLL_SFX}.dll DESTINATION ${INSTALL_DESTINATION}/platforms)
# ICU dlls
foreach(tmpfile ${INSTALL_TEMP_ICUDLL_FILES})
# Qt5.7+ doesn't use icu dlls anymore (at least with MinGW), hence optional
install(FILES ${QT_DLL_DIR}/${tmpfile}.dll DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
endforeach()
# SDL dll
if(SDL_FOUND AND SDL_LIBRARY_PATH AND EXISTS "${SDL_LIBRARY_PATH}/SDL.dll")
set(SDL_DIR ${SDL_LIBRARY_PATH}) # this is also used by NSIS installer script
install(FILES ${SDL_DIR}/SDL.dll DESTINATION ${INSTALL_DESTINATION})
else()
message(WARNING "Installer: SDL.dll not found!")
endif()
# C++/system dlls, depends on compiler
if(MSVC)
set(WIN_SYSDIR "$ENV{windir}/SysWOW64") # This would be "system32" for a 64-bit build or on x86... but how to tell?
if(IS_DIRECTORY ${WIN_SYSDIR})
install(FILES ${WIN_SYSDIR}/msvcp140.dll ${WIN_SYSDIR}/vcruntime140.dll DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
endif()
install(FILES "${WIN_PTHREAD_BASE_PATH}/lib/pthreadVC2.dll" DESTINATION ${INSTALL_DESTINATION})
elseif(MINGW)
get_filename_component(MINGW_DIR ${CMAKE_CXX_COMPILER} PATH)
if(IS_DIRECTORY ${MINGW_DIR})
install(FILES ${MINGW_DIR}/libgcc_s_dw2-1.dll ${MINGW_DIR}/libstdc++-6.dll ${MINGW_DIR}/libwinpthread-1.dll DESTINATION ${INSTALL_DESTINATION})
set(MINGW_DIR "${MINGW_DIR}/../opt/bin")
# SSL support
install(FILES ${MINGW_DIR}/libeay32.dll ${MINGW_DIR}/ssleay32.dll DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
endif()
endif()
endif() # WIN32 install
############# Packaging ####################
# Create Windows installer with NSIS (only works for MSVC for now)
if(WIN32)
if(MSVC)
set(COMPANION_NSI_IN_FILE companion-vs.nsi.in)
@@ -359,9 +432,8 @@ string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
# very poor trace-backs from the users when they report Companion crash
set(CPACK_STRIP_FILES FALSE)
set(plugin_dest_dir bin)
set(qtconf_dest_dir bin)
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${COMPANION_NAME}")
# Qt5 + Cmake + Mac is poorly documented. A lot of this is guesswork
# and trial and error. Do not hesitate to fix it for the better
IF(APPLE)
set(plugin_dest_dir ${COMPANION_NAME}.app/Contents/Plugins)
set(qtconf_dest_dir ${COMPANION_NAME}.app/Contents/Resources)
@@ -373,21 +445,11 @@ IF(APPLE)
# Use a non standard Info.plist that adds Retina support flags
set_target_properties(${COMPANION_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
set_target_properties(${SIMULATOR_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
ENDIF(APPLE)
IF(WIN32)
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/QtTest.exe")
ENDIF(WIN32)
INSTALL(TARGETS ${COMPANION_NAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)
# Qt5 + Cmake + Mac is poorly documented. A lot of this is guesswork
# and trial and error. Do not hesitate to fix it for the better
if(APPLE)
set(APPS "\${CMAKE_INSTALL_PREFIX}/${COMPANION_NAME}.app")
INSTALL(TARGETS ${COMPANION_NAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)
file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/libopentx-*${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(companion_res_dir ${COMPANION_NAME}.app/Contents/Resources)
@@ -396,7 +458,7 @@ if(APPLE)
# Write qt.conf to tell qt where to find it plugins
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
"[Paths]\nPlugins = Plugins\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
DESTINATION "${companion_res_dir}"
COMPONENT Runtime)
+1 -1
View File
@@ -26,7 +26,7 @@
#include "progressdialog.h"
#include "process_flash.h"
#if !defined WIN32 && defined __GNUC__
#if !defined _MSC_VER && defined __GNUC__
#include <unistd.h>
#endif
+1 -1
View File
@@ -36,7 +36,7 @@
#include "eeprominterface.h"
#include "appdata.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x*1000)
#else
-4
View File
@@ -24,10 +24,6 @@
#include <QPrinter>
#include <QPrintDialog>
// #if !defined WIN32 && defined __GNUC__
// #include <unistd.h>
// #endif
class DragDropHeader {
public:
DragDropHeader():
+1 -1
View File
@@ -32,7 +32,7 @@
#include "progresswidget.h"
#include "splashlibrarydialog.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x*1000)
#else
+15 -3
View File
@@ -19,13 +19,16 @@
*/
#include <QtGui>
#if defined WIN32
#if defined _MSC_VER
#include <io.h>
#include <stdio.h>
#endif
#if !defined WIN32 && defined __GNUC__
#elif defined __GNUC__
#include <unistd.h>
#endif
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
#include "windows.h"
#endif
#include "appdata.h"
#include "helpers.h"
#include "simulatordialog.h"
@@ -809,6 +812,12 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
Firmware * firmware = GetCurrentFirmware();
SimulatorInterface * simulator = GetCurrentFirmwareSimulator();
if (simulator) {
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
#endif
RadioData * simuData = new RadioData(radioData);
unsigned int flags = 0;
if (modelIdx >= 0) {
@@ -854,6 +863,9 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
}
dialog->exec();
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
FreeConsole();
#endif
delete dialog;
delete simuData;
}
+1 -1
View File
@@ -23,7 +23,7 @@
#include "appdata.h"
#include "ui_logsdialog.h"
#include "helpers.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#else
#include <unistd.h>
+5 -2
View File
@@ -61,12 +61,15 @@
#define COMPANION_INSTALLER "companion-windows-%1.exe"
#endif
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x*1000)
#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/nightly/companion/windows"
#else
#include <unistd.h>
#endif
#ifdef WIN32
#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/nightly/companion/windows"
#else
#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/nightly/companion/linux"
#endif
+1 -1
View File
@@ -34,7 +34,7 @@
#include "flashfirmwaredialog.h"
#include "storage_eeprom.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x*1000)
#else
-4
View File
@@ -24,10 +24,6 @@
#include <QPrinter>
#include <QPrintDialog>
// #if !defined WIN32 && defined __GNUC__
// #include <unistd.h>
// #endif
PrintDialog::PrintDialog(QWidget *parent, Firmware * firmware, GeneralSettings & generalSettings, ModelData & model, const QString & filename) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
firmware(firmware),
+1 -1
View File
@@ -26,7 +26,7 @@
#include "eeprominterface.h"
//#include "firmwareinterface.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <Windows.h>
#include <WinBase.h>
#include <tlhelp32.h>
@@ -26,7 +26,7 @@
#include <QMap>
#include <QMessageBox>
#include "version.h"
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
#endif
@@ -59,7 +59,7 @@ void registerSimulators()
QStringList filters;
#if defined(__APPLE__)
filters << "*-simulator.dylib";
#elif (!defined __GNUC__) || (defined __CYGWIN__)
#elif defined(WIN32) || defined(__CYGWIN__)
filters << "*-simulator.dll";
#else
filters << "*-simulator.so";
+16 -5
View File
@@ -37,10 +37,13 @@
#include "appdata.h"
#include "qxtcommandoptions.h"
#if defined WIN32 || !defined __GNUC__
#include <windows.h>
#define sleep(x) Sleep(x*1000)
#else
#ifdef WIN32
#include <windows.h>
#ifdef _MSC_VER
#define sleep(x) Sleep(x*1000)
#endif
#endif
#if !defined(_MSC_VER) || defined(__GNUC__)
#include <unistd.h>
#endif
@@ -59,7 +62,6 @@ class MyProxyStyle : public QProxyStyle
};
#endif
void showMessage(const QString & message, enum QMessageBox::Icon icon = QMessageBox::NoIcon) {
QMessageBox msgBox;
msgBox.setText(message);
@@ -73,6 +75,12 @@ int main(int argc, char *argv[])
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
#endif
QApplication app(argc, argv);
app.setApplicationName("OpenTX Simulator");
@@ -229,6 +237,9 @@ int main(int argc, char *argv[])
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
SDL_Quit();
#endif
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
FreeConsole();
#endif
return result;
}