lua: added EVT_MENU_LONG on Taranis (#3991)
[opentx.git] / CMakeLists.txt
blob865d38e5ae572c3e47e0a820974034779b1f77d2
1 project(OpenTX)
3 set(VERSION_MAJOR "2")
4 set(VERSION_MINOR "2")
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)
17 if(POLICY CMP0042)
18   cmake_policy(SET CMP0042 NEW)
19 endif()
20 if(POLICY CMP0043)
21   cmake_policy(SET CMP0043 NEW)
22 endif()
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)
36 if(WIN32)
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
40 endif()
42 find_package(Qt5Widgets)
43 find_package(Qt5Xml)
44 find_package(Qt5LinguistTools)
45 find_package(Qt5PrintSupport)
46 find_package(Qt5Multimedia)
48 if(Qt5Widgets_FOUND)
49   message(STATUS "Qt Version: ${Qt5Widgets_VERSION}")
50 else()
51   message(WARNING "Qt not found! Companion and Simulator builds disabled.")
52 endif()
54 if(NOT WIN32)
55   find_package(Fox QUIET)  # QUIET not working on WIN32?
56   if (FOX_FOUND)
57     message(STATUS "Foxlib found at ${FOX_LIBRARY}")
58   else() # if(NOT WIN32)
59     message("Libfox not found, simu target will not be available")
60   endif()
61 endif()
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
65   find_package("SDL")
66   if(SDL_FOUND)
67     message(STATUS "SDL Lib: ${SDL_LIBRARY}; Headers: ${SDL_INCLUDE_DIR}; Version: ${SDL_VERSION_STRING}")
68   else()
69     message(STATUS "SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
70   endif()
71 endif()
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")
76 endif()
78 # Windows-specific includes and libs shared by sub-projects
79 if(WIN32)
80   list(APPEND WIN_INCLUDE_DIRS "${WIN_EXTRA_LIBS_PATH}/dirent/include")
81   if(MSVC)
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")
85   endif(MSVC)
86 endif()
88 include(Macros)
89 today(DATE)
90 now(TIME)
91 git_id(GIT_STR)
93 add_subdirectory(${RADIO_SRC_DIRECTORY})
95 if(Qt5Widgets_FOUND)
96   add_subdirectory(${COMPANION_SRC_DIRECTORY})
97 endif()