diff --git a/toolchain-gcc.cmake b/toolchain-gcc.cmake index a7cc3bc82aa..1462e47b354 100644 --- a/toolchain-gcc.cmake +++ b/toolchain-gcc.cmake @@ -1,4 +1,11 @@ +macro(require_program varname execname) + find_program(${varname} ${execname}) + if(NOT ${varname}) + message(FATAL_ERROR "${execname} not found") + endif() +endmacro() + # pass variables necessary for the toolchain (needed for try_compile) set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH) @@ -28,15 +35,15 @@ set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR i686) # Which tools to use -set(CMAKE_C_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The C Compiler") -set(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The C++ Compiler") -set(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The ASM Compiler") +require_program(CMAKE_C_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX}) +require_program(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX}) +require_program(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX}) set(CMAKE_ASM_COMPILER_ID "GNU") -set(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc) -set(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres) -set(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool) +require_program(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc) +require_program(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres) +require_program(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool) #set(CMAKE_AR ${MINGW_TOOLCHAIN_PREFIX}gcc-ar${MINGW_TOOLCHAIN_SUFFIX}) -set(CMAKE_OBJCOPY ${MINGW_TOOLCHAIN_PREFIX}objcopy) +require_program(CMAKE_OBJCOPY ${MINGW_TOOLCHAIN_PREFIX}objcopy) set(CMAKE_C_CREATE_STATIC_LIBRARY " crT ") set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})