背景,主目录cmake通过add_subdirectory方式调用子目录cmake,在主目录通过
set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++)
方式设置了交叉编译工具
子目录报错:
CMake Error at xxx/CMakeLists.txt:6 (project):
The CMAKE_C_COMPILER:
gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
一种可能的解决方法是直接在调用主目录cmake的时候通过-D传入参数,比如在命令行执行:
cmake -D CMAKE_C_COMPILER=xxx-gcc -D CMAKE_CXX_COMPILER==xxx-g++ .