|
|
@@ -162,3 +162,14 @@ foreach (VAR NATIVE_64BIT HAVE_MMX HAVE_3DNOW HAVE_SSE HAVE_SSE2 HAVE_ALTIVEC)
|
|
|
set (${VAR} 0)
|
|
|
endif ()
|
|
|
endforeach ()
|
|
|
+
|
|
|
+# When cross-compiling, this macro ensures that a native compiler toolchain also exists for building the host tool targets
|
|
|
+macro (check_native_compiler_exist)
|
|
|
+ file (WRITE ${CMAKE_BINARY_DIR}/generated/CMakeLists.txt "message (\"Probing native compiler toolchain...\")\n")
|
|
|
+ execute_process (COMMAND ${CMAKE_COMMAND} -E env CC=${SAVED_CC} CXX=${SAVED_CXX} ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} .
|
|
|
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/generated RESULT_VARIABLE EXIT_CODE ERROR_VARIABLE ERR_VAR OUTPUT_QUIET)
|
|
|
+ if (NOT EXIT_CODE EQUAL 0)
|
|
|
+ execute_process (COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/generated/CMakeCache.txt)
|
|
|
+ message (FATAL_ERROR "Could not find native compiler toolchain. This is usually caused by wrong PATH env-var value.\n${ERR_VAR}")
|
|
|
+ endif ()
|
|
|
+endmacro ()
|