CMAKE_<LANG>_COMPILER_TARGET. This detects this from the toolchain file and passes it along. This is tested & works with an internal toolchain file.libbacktracefailed to cross-compile without this change. configure_make: use CMAKE_C_COMPILER_TARGET to detect cross-compilation ...
However in practice in one test I did, it worked just fine to set it up on the command line with e.g.-DCMAKE_CXX_COMPILER_TARGETtoo, e.g. for cross compiling with Clang like-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-mingw32...
注意:必须先include(CheckCXXCompilerFlag) 例子1:在检查当前编译器是否支持c++11 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x"COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s...