5 set(VERSION_REVISION "0")
6 set(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX})
7 set(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR})
8 set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX})
9 message(STATUS "OpenTX ${VERSION}")
11 set(SDCARD_REVISION "0004")
12 set(SDCARD_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}V${SDCARD_REVISION})
14 cmake_minimum_required(VERSION 2.8)
15 cmake_policy(SET CMP0020 NEW)
16 cmake_policy(SET CMP0023 OLD)
18 cmake_policy(SET CMP0042 NEW)
21 cmake_policy(SET CMP0043 NEW)
24 cmake_policy(SET CMP0054 NEW)
27 set(CMAKE_COLOR_MAKEFILE ON)
29 set(CMAKE_CXX_STANDARD 11)
31 set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
32 set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src)
33 set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)
34 set(SIMU_SRC_DIRECTORY ${COMPANION_SRC_DIRECTORY}/simulation)
36 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
37 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
38 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
40 # options shared by all targets
41 option(VERBOSE_CMAKELISTS "Show extra information while processing CMakeLists.txt files." OFF)
42 option(WARNINGS_AS_ERRORS "Treat any compiler warning as an error (adds -Werror flag)." OFF)
44 set(WIN_EXTRA_LIBS_PATH "C:/Programs" CACHE PATH
45 "Base path to extra libs/headers on Windows (SDL, dirent, pthreads, msinttypes folders should be in here).")
46 list(APPEND CMAKE_PREFIX_PATH "${WIN_EXTRA_LIBS_PATH}" "${WIN_EXTRA_LIBS_PATH}/SDL") # hints for FindSDL
49 find_package(Qt5Widgets)
51 find_package(Qt5LinguistTools)
52 find_package(Qt5PrintSupport)
53 find_package(Qt5Multimedia)
56 message(STATUS "Qt Version: ${Qt5Widgets_VERSION}")
58 message(WARNING "Qt not found! Companion and Simulator builds disabled.")
62 find_package(Fox QUIET) # QUIET not working on WIN32?
64 message(STATUS "Foxlib found at ${FOX_LIBRARY}")
65 else() # if(NOT WIN32)
66 message("Libfox not found, simu target will not be available")
70 if(Qt5Widgets_FOUND OR FOX_FOUND)
71 set(SDL_BUILDING_LIBRARY YES) # this prevents FindSDL from appending SDLmain lib to the results, which we don't want
74 message(STATUS "SDL Lib: ${SDL_LIBRARY}; Headers: ${SDL_INCLUDE_DIR}; Version: ${SDL_VERSION_STRING}")
76 message(STATUS "SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
80 # Check for a file that is typically left from a OpenTX 2.1 build and abort if found
81 if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h)
82 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")
85 # Windows-specific includes and libs shared by sub-projects
87 list(APPEND WIN_INCLUDE_DIRS "${WIN_EXTRA_LIBS_PATH}/dirent/include")
89 set(WIN_PTHREAD_BASE_PATH "${WIN_EXTRA_LIBS_PATH}/pthreads/Pre-built.2")
90 list(APPEND WIN_INCLUDE_DIRS "${WIN_PTHREAD_BASE_PATH}/include" "${WIN_EXTRA_LIBS_PATH}/msinttypes")
91 find_file(WIN_PTHREAD_LIB pthreadVC2.lib PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib NO_DEFAULT_PATH)
92 find_file(WIN_PTHREAD_DLL pthreadVC2.dll PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib dll/x86 dll NO_DEFAULT_PATH)
94 list(APPEND WIN_LINK_LIBRARIES "${WIN_PTHREAD_LIB}")
96 message(SEND_ERROR "pthreadVC2.lib not found!")
99 set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
100 set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
101 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
102 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
111 add_subdirectory(${RADIO_SRC_DIRECTORY})
114 add_subdirectory(${COMPANION_SRC_DIRECTORY})