Merge pull request #8747 from iNavFlight/MrD_Update-flight-mode-operand-in-programming
[inav.git] / cmake / gcc.cmake
blobcfe2ddf3dbc9c7d7c32c4bc2a51d16ec09ac1876
1 function(gcc_get_version var)
2     cmake_parse_arguments(args
3         ""
4         "TRIPLET;PROGRAM_NAME;PROGRAM_PATH"
5         ""
6         ${ARGN}
7     )
8     set(prog "gcc")
9     if(args_TRIPLET)
10         set(prog "${args_TRIPLET}-${prog}")
11     endif()
12     if(args_PROGRAM_NAME)
13         set(${args_PROGRAM_NAME} ${prog} PARENT_SCOPE)
14     endif()
16     find_program(gcc ${prog})
17     if (NOT gcc)
18         set(${var} OFF PARENT_SCOPE)
19     endif()
21     if(args_PROGRAM_PATH)
22         set(${args_PROGRAM_PATH} ${gcc} PARENT_SCOPE)
23     endif()
25     execute_process(COMMAND "${gcc}" -dumpversion
26         OUTPUT_STRIP_TRAILING_WHITESPACE
27         OUTPUT_VARIABLE version)
29     if("" STREQUAL version)
30         set(${var} OFF PARENT_SCOPE)
31     else()
32         set(${var} ${version} PARENT_SCOPE)
33     endif()
34 endfunction()