* [TravisCI] Build using avr-gcc 4.9.2 (up from 4.8.2). Relies on https://github.com/opentx/opentx/pull/4169 . Fixes all linker warnings, makes clean build. * [build] Add ARM/AVR compiler version check/display and a workaround for avr-gcc linker warnings when using WARNINGS_AS_ERRORS=true. * [TravisCI] Enable -Werror on all build targets (WARNINGS_AS_ERRORS=true). * [build] CMake script updates: Enable WARNINGS_AS_ERRORS option for all targets (not just firmware); Consolidate some C/CXX flag settings for firmware target, avoid duplication/redundancy; All warning flags are now passed to linker (GCC only); Add a "build report" for each main target showing compiler, flags, and defines, with verbosity controlled by new VERBOSE_CMAKELISTS option; Added properties to PCB, TRANSLATIONS, and a few other options (makes option selector lists in cmake-gui); Add macro for conditionally adding C++11 flag; Silence CMake >3.0 warnings about CMP0054 policy not being set; Reverts AVR linker -Werror workaround; Misc. cleanup/consolidation. * [build] More CMakeLists updates: Silence superfluous "CRT_SECURE" series MSVC warnings; Formalize finding pthread lib/dll on MSVC builds and fix some issues with install target script; Add property string lists to more options; Quotes some paths with possible spaces, & other minor cosmetics. * [build] firmware/bootloader: Remove remaining CMake default compiler flags and add FIRMWARE_C[XX}_FLAGS[_DEBUG] options for user to specify additional flags. Also move ASM language call to silence CMake warning w/MSVC. * [build] Workaround bogus "uninitialized" warnings from AVR linker. * [tests] Add custom printer for less verbose gtest output (use --verbose option to revert to gtest default). * [build] Use less verbose CMake output for TravisCI builds. Formalize search for gtest code and enable gtests target on WIN32-GCC. Minor language fix.
116 lines
4.1 KiB
CMake
116 lines
4.1 KiB
CMake
project(OpenTX)
|
|
|
|
set(VERSION_MAJOR "2")
|
|
set(VERSION_MINOR "2")
|
|
set(VERSION_REVISION "0")
|
|
set(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX})
|
|
set(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR})
|
|
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX})
|
|
message(STATUS "OpenTX ${VERSION}")
|
|
|
|
set(SDCARD_REVISION "0004")
|
|
set(SDCARD_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}V${SDCARD_REVISION})
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
cmake_policy(SET CMP0020 NEW)
|
|
cmake_policy(SET CMP0023 OLD)
|
|
if(POLICY CMP0042)
|
|
cmake_policy(SET CMP0042 NEW)
|
|
endif()
|
|
if(POLICY CMP0043)
|
|
cmake_policy(SET CMP0043 NEW)
|
|
endif()
|
|
if(POLICY CMP0054)
|
|
cmake_policy(SET CMP0054 NEW)
|
|
endif()
|
|
|
|
set(CMAKE_COLOR_MAKEFILE ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
|
|
set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src)
|
|
set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)
|
|
set(SIMU_SRC_DIRECTORY ${COMPANION_SRC_DIRECTORY}/simulation)
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
|
|
|
# options shared by all targets
|
|
option(VERBOSE_CMAKELISTS "Show extra information while processing CMakeLists.txt files." OFF)
|
|
option(WARNINGS_AS_ERRORS "Treat any compiler warning as an error (adds -Werror flag)." OFF)
|
|
if(WIN32)
|
|
set(WIN_EXTRA_LIBS_PATH "C:/Programs" CACHE PATH
|
|
"Base path to extra libs/headers on Windows (SDL, dirent, pthreads, msinttypes folders should be in here).")
|
|
list(APPEND CMAKE_PREFIX_PATH "${WIN_EXTRA_LIBS_PATH}" "${WIN_EXTRA_LIBS_PATH}/SDL") # hints for FindSDL
|
|
endif()
|
|
|
|
find_package(Qt5Widgets)
|
|
find_package(Qt5Xml)
|
|
find_package(Qt5LinguistTools)
|
|
find_package(Qt5PrintSupport)
|
|
find_package(Qt5Multimedia)
|
|
|
|
if(Qt5Widgets_FOUND)
|
|
message(STATUS "Qt Version: ${Qt5Widgets_VERSION}")
|
|
else()
|
|
message(WARNING "Qt not found! Companion and Simulator builds disabled.")
|
|
endif()
|
|
|
|
if(NOT WIN32)
|
|
find_package(Fox QUIET) # QUIET not working on WIN32?
|
|
if (FOX_FOUND)
|
|
message(STATUS "Foxlib found at ${FOX_LIBRARY}")
|
|
else() # if(NOT WIN32)
|
|
message("Libfox not found, simu target will not be available")
|
|
endif()
|
|
endif()
|
|
|
|
if(Qt5Widgets_FOUND OR FOX_FOUND)
|
|
set(SDL_BUILDING_LIBRARY YES) # this prevents FindSDL from appending SDLmain lib to the results, which we don't want
|
|
find_package("SDL")
|
|
if(SDL_FOUND)
|
|
message(STATUS "SDL Lib: ${SDL_LIBRARY}; Headers: ${SDL_INCLUDE_DIR}; Version: ${SDL_VERSION_STRING}")
|
|
else()
|
|
message(STATUS "SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
|
|
endif()
|
|
endif()
|
|
|
|
# Check for a file that is typically left from a OpenTX 2.1 build and abort if found
|
|
if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h)
|
|
message(FATAL_ERROR "Source directory contains files leftover from a OpenTX 2.1 build. Please run `git clean -f` in source directory (Careful: Will remove any extra files) or do a new clean git checkout")
|
|
endif()
|
|
|
|
# Windows-specific includes and libs shared by sub-projects
|
|
if(WIN32)
|
|
list(APPEND WIN_INCLUDE_DIRS "${WIN_EXTRA_LIBS_PATH}/dirent/include")
|
|
if(MSVC)
|
|
set(WIN_PTHREAD_BASE_PATH "${WIN_EXTRA_LIBS_PATH}/pthreads/Pre-built.2")
|
|
list(APPEND WIN_INCLUDE_DIRS "${WIN_PTHREAD_BASE_PATH}/include" "${WIN_EXTRA_LIBS_PATH}/msinttypes")
|
|
find_file(WIN_PTHREAD_LIB pthreadVC2.lib PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib NO_DEFAULT_PATH)
|
|
find_file(WIN_PTHREAD_DLL pthreadVC2.dll PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib dll/x86 dll NO_DEFAULT_PATH)
|
|
if(WIN_PTHREAD_LIB)
|
|
list(APPEND WIN_LINK_LIBRARIES "${WIN_PTHREAD_LIB}")
|
|
else()
|
|
message(SEND_ERROR "pthreadVC2.lib not found!")
|
|
endif()
|
|
else()
|
|
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
|
|
set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
|
|
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
|
|
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
|
|
endif()
|
|
endif()
|
|
|
|
include(Macros)
|
|
today(DATE)
|
|
now(TIME)
|
|
git_id(GIT_STR)
|
|
|
|
add_subdirectory(${RADIO_SRC_DIRECTORY})
|
|
|
|
if(Qt5Widgets_FOUND)
|
|
add_subdirectory(${COMPANION_SRC_DIRECTORY})
|
|
endif()
|