Skip to content
Permalink
Browse files

cmake: Improve the error message when the compiler is not executable

When the SDK/toolchain has been incorrectly installed such that the
user does not have permissions to execute it an incomprehensible
errror message occurs.

This patch tests that executing 'gcc --version' does not give an error
code and errors out with an appropriate error message if it does.

This fixes #8977

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
  • Loading branch information...
SebastianBoe authored and nashif committed Jul 31, 2018
1 parent 0b76567 commit c1bf7350b19c9e40aad9e2e5c1edc45d93efad15
Showing with 14 additions and 1 deletion.
  1. +14 −1 cmake/compiler/gcc.cmake
@@ -24,6 +24,19 @@ TOOLCHAIN_HOME: ${TOOLCHAIN_HOME}
")
endif()

execute_process(
COMMAND ${CMAKE_C_COMPILER} --version
RESULT_VARIABLE ret
OUTPUT_QUIET
ERROR_QUIET
)
if(ret)
message(FATAL_ERROR "Executing the below command failed. Are permissions set correctly?
'${CMAKE_C_COMPILER} --version'
"
)
endif()

if(CONFIG_CPLUSPLUS)
set(cplusplus_compiler ${CROSS_COMPILE}${C++})
else()
@@ -45,7 +58,7 @@ foreach(file_name include include-fixed)
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
OUTPUT_VARIABLE _OUTPUT
)
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")

if(MSYS)
# TODO: Remove this when

0 comments on commit c1bf735

Please sign in to comment.
You can’t perform that action at this time.