Add TXRSSI and TXLQI sensors to FrSky D8/D16/LBT when using MULTI (#7128)
[opentx.git] / cmake / Macros.cmake
blob06fbb244b4cf1232341451bd2c89815b9b77272f
1 macro(today RESULT)
2   if(WIN32)
3     execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
4     string(REGEX REPLACE "[^0-9]*([0-9]+)[^0-9]([0-9]+)[^0-9]([0-9]+).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}})
5   elseif(UNIX)
6     execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
7     string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}})
8   else(WIN32)
9     message(WARNING "date not implemented")
10     set(${RESULT} 00-00-0000)
11   endif(WIN32)
12 endmacro(today)
14 macro(now RESULT)
15   if(WIN32)
16     execute_process(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT})
17     string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}})
18   elseif(UNIX)
19     execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
20     string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}})
21   else(WIN32)
22     message(WARNING "time not implemented")
23     set(${RESULT} 00:00:00)
24   endif(WIN32)
25 endmacro(now)
27 find_package(Git)
29 macro(git_id RESULT)
30   set(${RESULT} 0)
31   if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
32     execute_process(COMMAND "${GIT_EXECUTABLE}" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "--short=8" "HEAD" OUTPUT_VARIABLE proc_out ERROR_VARIABLE proc_err)
33     if(proc_err)
34       message(WARNING "Git failed with error: ${proc_err}")
35     else()
36       string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${proc_out})
37     endif()
38   elseif(NOT GIT_FOUND)
39     message(WARNING "Git executable not found, revision number not available.")
40   else()
41     message(STATUS "Git repository not found, revision number not available.")
42   endif()
43 endmacro(git_id)
45 macro(use_cxx11)
46   if (CMAKE_VERSION VERSION_LESS "3.1" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
47     set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
48   endif ()
49 endmacro(use_cxx11)
51 macro(PrintTargetReport targetName)
52   if(CMAKE_CXX_COMPILER MATCHES "/(clang-)?cl\\.exe$")
53     set(cpp_version ${CMAKE_CXX_COMPILER_VERSION})
54   else()
55     execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE cpp_version)
56   endif()
57   if(cpp_version)
58     string(STRIP "v${cpp_version}" cpp_version)
59   else()
60     set(cpp_version "WARNING: COMPILER NOT FOUND!")
61   endif()
62   message("TARGET ${targetName}: cpp compiler ${CMAKE_CXX_COMPILER} ${cpp_version}")
64   if(VERBOSE_CMAKELISTS)
65     get_directory_property(DirOpts COMPILE_OPTIONS)
66     get_directory_property(DirDefs COMPILE_DEFINITIONS)
67     string(REPLACE ";" " " DirOpts "${DirOpts}")
68     string(REPLACE ";" "; " DirDefs "${DirDefs}")
69     string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
70     message("\twith cpp flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}} ${DirOpts}")
71     message("\twith link flags: ${CMAKE_EXE_LINKER_FLAGS}")
72     message("\twith defs: ${DirDefs}")
73     message("--------------")
74   endif()
75 endmacro(PrintTargetReport)