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:
committed by
Bertrand Songis
parent
06b0694f03
commit
e90bd0fd70
@@ -21,12 +21,22 @@ option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
|
||||
option(WATCHDOG_DISABLED "Disable hardware Watchdog" OFF)
|
||||
option(SIMU_AUDIO "Enable simulator audio" OFF)
|
||||
option(SIMU_DISKIO "Enable disk IO simulation in simulator. Simulator will use FatFs module and simulated IO layer that uses \"./sdcard.image\" file as image of SD card. This file must contain whole SD card from first to last sector" OFF)
|
||||
option(SIMU_LUA_COMPILER "Pre-compile and save Lua scripts in simulator." ON)
|
||||
option(FAS_PROTOTYPE "Support of old FAS prototypes (different resistors)" OFF)
|
||||
option(TEMPLATES "Model templates menu" OFF)
|
||||
option(WARNINGS_AS_ERRORS "Treat all compiler warnings as error" OFF)
|
||||
option(TRACE_SIMPGMSPACE "Turn on traces in simpgmspace.cpp" ON)
|
||||
set(DEFAULT_MODE "" CACHE STRING "Default sticks mode")
|
||||
|
||||
# Python check
|
||||
find_package("PythonInterp")
|
||||
if(PYTHONINTERP_FOUND)
|
||||
message(STATUS "Python found, version: ${PYTHON_VERSION_STRING}")
|
||||
else()
|
||||
message(WARNING "Python not found! Most firmware and simu flavors not buildable.")
|
||||
set(LUA OFF)
|
||||
endif()
|
||||
|
||||
enable_language(ASM)
|
||||
set(OPT s)
|
||||
|
||||
@@ -336,7 +346,7 @@ endforeach()
|
||||
|
||||
add_definitions(-DCORRECT_NEGATIVE_SHIFTS)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT MSVC)
|
||||
add_definitions(-Wall -Wno-strict-aliasing -Wformat -Wreturn-type -Wunused -Wuninitialized -Wunknown-pragmas -Wno-switch -Wtype-limits)
|
||||
if(WARNINGS_AS_ERRORS)
|
||||
set(WARNING_FLAGS -Werror)
|
||||
|
||||
@@ -73,10 +73,4 @@ typedef __int24 int24_t;
|
||||
#define CONVERT_UINT_PTR(x) ((uint32_t *)(x))
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#define round(x) floor(x+0.5)
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _tcsnicmp
|
||||
#endif
|
||||
|
||||
#endif // _DEFINITIONS_H_
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
if(MSVC)
|
||||
set(INTTYPES_INCLUDE_OPTION -IC:/Programs/msinttypes)
|
||||
endif()
|
||||
|
||||
macro(add_lua_export_target target)
|
||||
add_custom_command(
|
||||
OUTPUT lua_exports_${target}.inc
|
||||
COMMAND ${CMAKE_C_COMPILER} -E ${ARGN} -DEXPORT ${INTTYPES_INCLUDE_OPTION} ${RADIO_SRC_DIRECTORY}/dataconstants.h > lua_exports_${target}.tmp
|
||||
COMMAND grep LEXP lua_exports_${target}.tmp > lua_exports_${target}.txt
|
||||
COMMAND rm lua_exports_${target}.tmp
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/luaexport.py ${VERSION} lua_exports_${target}.txt lua_exports_${target}.inc lua_fields_${target}.txt
|
||||
)
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT lua_exports_${target}.inc
|
||||
COMMAND ${CMAKE_C_COMPILER} -E ${ARGN} -DEXPORT ${RADIO_SRC_DIRECTORY}/dataconstants.h > lua_exports_${target}.tmp
|
||||
COMMAND grep LEXP lua_exports_${target}.tmp > lua_exports_${target}.txt
|
||||
COMMAND rm lua_exports_${target}.tmp
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/luaexport.py ${VERSION} lua_exports_${target}.txt lua_exports_${target}.inc lua_fields_${target}.txt
|
||||
)
|
||||
endif()
|
||||
add_custom_target(lua_export_${target} DEPENDS lua_exports_${target}.inc)
|
||||
endmacro(add_lua_export_target)
|
||||
|
||||
@@ -26,6 +25,12 @@ set(LUA_INCLUDES
|
||||
-I${RADIO_SRC_DIRECTORY}/${STM32USB_DIR}/STM32_USB_Device_Library/Class/hid/inc
|
||||
)
|
||||
|
||||
if(WIN32 AND WIN_INCLUDE_DIRS)
|
||||
foreach(include ${WIN_INCLUDE_DIRS})
|
||||
set(LUA_INCLUDES "${LUA_INCLUDES} -I${include}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(LUA_INCLUDES_STM32F2
|
||||
${LUA_INCLUDES}
|
||||
-DSTM32F2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
option(TIMERS "Timers count" 3)
|
||||
set(TIMERS 3 CACHE STRING "Timers count (2 or 3)")
|
||||
option(CLI "Command Line Interface" OFF)
|
||||
option(DEBUG "Debug mode" OFF)
|
||||
option(LOG_TELEMETRY "Telemetry Logs on SD card" OFF)
|
||||
|
||||
@@ -9,27 +9,23 @@ set(SIMU_SRC
|
||||
)
|
||||
|
||||
add_definitions(-DSIMU)
|
||||
add_definitions(-DLUA_COMPILER)
|
||||
remove_definitions(-DCLI)
|
||||
|
||||
if(SDL_FOUND)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
add_definitions(-DSIMU_AUDIO)
|
||||
add_definitions(-DJOYSTICKS)
|
||||
else()
|
||||
remove_definitions(-DSIMU_AUDIO)
|
||||
endif()
|
||||
|
||||
if(SIMU_LUA_COMPILER)
|
||||
add_definitions(-DLUA_COMPILER)
|
||||
endif()
|
||||
|
||||
if(Qt5Widgets_FOUND)
|
||||
set(SIMULATOR_FLAVOUR opentx-${FLAVOUR})
|
||||
set(SIMULATOR_TARGET ${SIMULATOR_FLAVOUR}-simulator)
|
||||
add_definitions(-DSIMULATOR_FLAVOUR="${SIMULATOR_FLAVOUR}")
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_LESS 3.1.0})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=gnu++11")
|
||||
endif()
|
||||
|
||||
include_directories(${COMPANION_SRC_DIRECTORY} ${COMPANION_SRC_DIRECTORY}/simulation)
|
||||
add_library(${SIMULATOR_TARGET} SHARED ${SIMU_SRC} opentxsimulator.cpp)
|
||||
add_dependencies(${SIMULATOR_TARGET} ${FIRMWARE_DEPENDENCIES})
|
||||
@@ -38,19 +34,26 @@ if(Qt5Widgets_FOUND)
|
||||
add_custom_target(libsimulator DEPENDS ${SIMULATOR_TARGET})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
include_directories(SYSTEM ${WIN_INCLUDE_DIRS})
|
||||
target_link_libraries(${SIMULATOR_TARGET} PRIVATE ${WIN_LINK_LIBRARIES})
|
||||
endif(WIN32)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/EHsc /LD /MP")
|
||||
include_directories(${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes C:/Programs/dirent/include)
|
||||
target_link_libraries(${SIMULATOR_TARGET} PRIVATE C:/Programs/pthreads/Pre-built.2/lib/pthreadVC2.lib)
|
||||
message("simu: using MSVC with ${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
if (${CMAKE_VERSION} VERSION_LESS 3.1.0})
|
||||
set(COMMON_CPP_FLAGS "${COMMON_FLAGS} -std=gnu++11")
|
||||
message("USING -std=gnu++11")
|
||||
else()
|
||||
set(COMMON_CPP_FLAGS ${COMMON_FLAGS})
|
||||
message("simu: adding -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_DEBUG "${COMMON_FLAGS} -g -O0")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CPP_FLAGS} -g -O0")
|
||||
if(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("simu: using MinGW with ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
|
||||
endif()
|
||||
|
||||
if((NOT WIN32) AND FOX_FOUND)
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#if defined(SIMU_AUDIO) && defined(CPUARM)
|
||||
#include <SDL.h>
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
#if defined(TRACE_SIMPGMSPACE)
|
||||
@@ -939,11 +938,7 @@ FRESULT f_getcwd (TCHAR *path, UINT sz_path)
|
||||
}
|
||||
|
||||
// remove simuSdDirectory from the cwd
|
||||
#ifdef _MSC_VER
|
||||
strcpy(path, cwd + sdlen + 2); // account for drive name
|
||||
#else
|
||||
strcpy(path, cwd + sdlen);
|
||||
#endif
|
||||
|
||||
if (path[0] == '\0') {
|
||||
strcpy(path, "/"); // fix for the root directory
|
||||
|
||||
@@ -69,9 +69,10 @@ set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC
|
||||
add_executable(bootloader ${BOOTLOADER_SRC})
|
||||
add_dependencies(bootloader ${BITMAPS_TARGET} firmware_translations)
|
||||
|
||||
add_custom_command(
|
||||
TARGET bootloader POST_BUILD
|
||||
COMMAND arm-none-eabi-objcopy -O binary bootloader.elf bootloader.bin
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/bin2lbm.py bootloader.bin bootloader.lbm
|
||||
)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
TARGET bootloader POST_BUILD
|
||||
COMMAND arm-none-eabi-objcopy -O binary bootloader.elf bootloader.bin
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/bin2lbm.py bootloader.bin bootloader.lbm
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -6,11 +6,13 @@ foreach(translation ${translations})
|
||||
if(NOT(PCB STREQUAL HORUS) AND language STREQUAL "cz")
|
||||
set(language cz_reduced)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${target}
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/translate.py ${translation} ${target} ${language}
|
||||
DEPENDS ${translation}
|
||||
)
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT ${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/translate.py ${translation} ${target} ${language}
|
||||
DEPENDS ${translation}
|
||||
)
|
||||
endif()
|
||||
list(APPEND translations_files ${target})
|
||||
endforeach()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user