forked from iNavFlight/inav
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gcc.cmake
34 lines (30 loc) · 801 Bytes
/
gcc.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function(gcc_get_version var)
cmake_parse_arguments(args
""
"TRIPLET;PROGRAM_NAME;PROGRAM_PATH"
""
${ARGN}
)
set(prog "gcc")
if(args_TRIPLET)
set(prog "${args_TRIPLET}-${prog}")
endif()
if(args_PROGRAM_NAME)
set(${args_PROGRAM_NAME} ${prog} PARENT_SCOPE)
endif()
find_program(gcc ${prog})
if (NOT gcc)
set(${var} OFF PARENT_SCOPE)
endif()
if(args_PROGRAM_PATH)
set(${args_PROGRAM_PATH} ${gcc} PARENT_SCOPE)
endif()
execute_process(COMMAND "${gcc}" -dumpversion
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE version)
if("" STREQUAL version)
set(${var} OFF PARENT_SCOPE)
else()
set(${var} ${version} PARENT_SCOPE)
endif()
endfunction()