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 set(SDCARD_REVISION "0006")
10 set(SDCARD_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}V${SDCARD_REVISION})
12 cmake_minimum_required(VERSION 2.8)
13 cmake_policy(SET CMP0020 NEW)
14 cmake_policy(SET CMP0023 OLD)
16 cmake_policy(SET CMP0042 NEW)
19 cmake_policy(SET CMP0043 NEW)
22 cmake_policy(SET CMP0054 NEW)
25 set(CMAKE_COLOR_MAKEFILE ON)
27 set(CMAKE_CXX_STANDARD 11)
29 set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
30 set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src)
31 set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)
32 set(SIMU_SRC_DIRECTORY ${COMPANION_SRC_DIRECTORY}/simulation)
34 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
35 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
36 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
43 message(STATUS "OpenTX ${VERSION} @${GIT_STR}")
45 # options shared by all targets
46 option(VERBOSE_CMAKELISTS "Show extra information while processing CMakeLists.txt files." OFF)
47 option(WARNINGS_AS_ERRORS "Treat any compiler warning as an error (adds -Werror flag)." OFF)
49 set(WIN_EXTRA_LIBS_PATH "C:/Programs" CACHE PATH
50 "Base path to extra libs/headers on Windows (SDL & pthreads folders should be in here).")
51 list(APPEND CMAKE_PREFIX_PATH "${WIN_EXTRA_LIBS_PATH}" "${WIN_EXTRA_LIBS_PATH}/SDL") # hints for FindSDL
54 find_package(Qt5Widgets)
56 find_package(Qt5LinguistTools)
57 find_package(Qt5PrintSupport)
58 find_package(Qt5Multimedia)
62 message(STATUS "Qt Version: ${Qt5Widgets_VERSION}")
64 message(WARNING "Qt not found! Companion and Simulator builds disabled.")
68 find_package(Fox QUIET) # QUIET not working on WIN32?
70 message(STATUS "Foxlib found at ${FOX_LIBRARY}")
71 else() # if(NOT WIN32)
72 message("Libfox not found, simu target will not be available")
76 if(Qt5Widgets_FOUND OR FOX_FOUND)
77 set(SDL_BUILDING_LIBRARY YES) # this prevents FindSDL from appending SDLmain lib to the results, which we don't want
80 message(STATUS "SDL Lib: ${SDL_LIBRARY}; Headers: ${SDL_INCLUDE_DIR}; Version: ${SDL_VERSION_STRING}")
82 message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.")
86 # Check for a file that is typically left from a OpenTX 2.1 build and abort if found
87 if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h)
88 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")
91 # Windows-specific includes and libs shared by sub-projects
93 list(APPEND WIN_INCLUDE_DIRS "${RADIO_SRC_DIRECTORY}/thirdparty/windows/dirent")
95 list(APPEND WIN_INCLUDE_DIRS "${RADIO_SRC_DIRECTORY}/thirdparty/windows/msinttypes")
96 set(WIN_PTHREAD_BASE_PATH "${WIN_EXTRA_LIBS_PATH}/pthreads/Pre-built.2" CACHE PATH "Where to find pthreads include and lib folders.")
97 list(APPEND WIN_INCLUDE_DIRS "${WIN_PTHREAD_BASE_PATH}/include")
98 find_file(WIN_PTHREAD_LIB pthreadVC2.lib PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib NO_DEFAULT_PATH)
99 find_file(WIN_PTHREAD_DLL pthreadVC2.dll PATHS "${WIN_PTHREAD_BASE_PATH}" PATH_SUFFIXES lib/x86 lib dll/x86 dll NO_DEFAULT_PATH)
101 list(APPEND WIN_LINK_LIBRARIES "${WIN_PTHREAD_LIB}")
103 message(SEND_ERROR "pthreadVC2.lib not found!")
106 set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
107 set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
108 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
109 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
113 add_subdirectory(${RADIO_SRC_DIRECTORY})
116 add_subdirectory(${COMPANION_SRC_DIRECTORY})