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 set(CMAKE_COLOR_MAKEFILE ON)
26 set(CMAKE_CXX_STANDARD 11)
28 set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
29 set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src)
30 set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)
32 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
33 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
34 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
37 set(WIN_EXTRA_LIBS_PATH "C:/Programs" CACHE PATH
38 "Base path to extra libs/headers on Windows (SDL, dirent, pthreads, msinttypes folders should be in here).")
39 list(APPEND CMAKE_PREFIX_PATH "${WIN_EXTRA_LIBS_PATH}" "${WIN_EXTRA_LIBS_PATH}/SDL") # hints for FindSDL
42 find_package(Qt5Widgets)
44 find_package(Qt5LinguistTools)
45 find_package(Qt5PrintSupport)
46 find_package(Qt5Multimedia)
49 message(STATUS "Qt Version: ${Qt5Widgets_VERSION}")
51 message(WARNING "Qt not found! Companion and Simulator builds disabled.")
55 find_package(Fox QUIET) # QUIET not working on WIN32?
57 message(STATUS "Foxlib found at ${FOX_LIBRARY}")
58 else() # if(NOT WIN32)
59 message("Libfox not found, simu target will not be available")
63 if(Qt5Widgets_FOUND OR FOX_FOUND)
64 set(SDL_BUILDING_LIBRARY YES) # this prevents FindSDL from appending SDLmain lib to the results, which we don't want
67 message(STATUS "SDL Lib: ${SDL_LIBRARY}; Headers: ${SDL_INCLUDE_DIR}; Version: ${SDL_VERSION_STRING}")
69 message(STATUS "SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
73 # Check for a file that is typically left from a OpenTX 2.1 build and abort if found
74 if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h)
75 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")
78 # Windows-specific includes and libs shared by sub-projects
80 list(APPEND WIN_INCLUDE_DIRS "${WIN_EXTRA_LIBS_PATH}/dirent/include")
82 set(WIN_PTHREAD_BASE_PATH "${WIN_EXTRA_LIBS_PATH}/pthreads/Pre-built.2")
83 list(APPEND WIN_INCLUDE_DIRS "${WIN_PTHREAD_BASE_PATH}/include" "${WIN_EXTRA_LIBS_PATH}/msinttypes")
84 list(APPEND WIN_LINK_LIBRARIES "${WIN_PTHREAD_BASE_PATH}/lib/pthreadVC2.lib")
93 add_subdirectory(${RADIO_SRC_DIRECTORY})
96 add_subdirectory(${COMPANION_SRC_DIRECTORY})