0
这cmake的相关的问题 试图建立项目,并且有一些问题,默认铛 - 3.5构建机器上,所以安装铛-3.7那里。不幸的是,它没有铛符号链接,所以我不得不去找它。cmake的CMAKE_C_COMPILER“不是现有的编译器工具的完整路径”
有内部的CMakeLists.txt文件这些线路检测铛,并设置它(我知道这是不太好找查找代码)
# Complilers, NOTE: this section should be before the Project section
find_program(CLANG_PATH clang)
find_program(CLANGCXX_PATH clang++)
if(NOT CLANG_PATH AND NOT CLANGCXX_PATH)
set (CLANG_SEARCH_PATH "/usr/bin/")
execute_process(COMMAND bash "-c" "ls ${CLANG_SEARCH_PATH} | grep -v clang++ | grep clang | head -1"
OUTPUT_VARIABLE CLANG_FILE)
execute_process(COMMAND bash "-c" "ls ${CLANG_SEARCH_PATH} | grep clang++ | head -1"
OUTPUT_VARIABLE CLANGCXX_FILE)
if(CLANG_FILE AND CLANGCXX_FILE)
set(CLANG_PATH "${CLANG_SEARCH_PATH}${CLANG_FILE}")
set(CLANGCXX_PATH "${CLANG_SEARCH_PATH}${CLANGCXX_FILE}")
set(CMAKE_C_COMPILER "${CLANG_PATH}")
message(STATUS "The clang compiler discovered... ${CLANG_PATH}")
set(CMAKE_CXX_COMPILER "${CLANGCXX_PATH}")
message(STATUS "The clang++ compiler discovered... ${CLANGCXX_PATH}")
else()
message(FATAL_ERROR "clang and clang++ were not found! Aborting...")
endif()
endif()
构建结果是(对于铛相同++)
-- The clang compiler discovered... /usr/bin/clang-3.7
-- The clang++ compiler discovered... /usr/bin/clang++-3.7
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:24 (project):
The CMAKE_C_COMPILER:
/usr/bin/clang-3.7
is not a full path to an existing compiler tool.
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.
但路径似乎是正确的。 如果我将它只是代替一个虚拟的方式,像
set(CMAKE_C_COMPILER "/usr/bin/clang-3.7")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-3.7")
它的工作原理
-- The C compiler identification is Clang 3.7.0
-- The CXX compiler identification is Clang 3.7.0
-- Check for working C compiler: /usr/bin/clang-3.7
-- Check for working C compiler: /usr/bin/clang-3.7 -- works
PS:我看到这一个CMAKE_C_COMPILER is not a full path to an existing compiler tool但它是不是非常有帮助。尽管留下了相同的主题名称。
UPD:
$cmake --version
cmake version 3.6.2
编译器路径末尾是否超出字符,如空格或换行符?尝试将结果变量与期望值进行比较,如'if(CMAKE_C_COMPILER STREQUAL“/usr/bin/clang-3.7”)'。 – Tsyvarev
@Tsyvarev对我的耻辱(。良好的捕获,这种行为的原因是**新行**。发生是我的execute_process命令的人工制品 只使用了'字符串(STRIP $ {CLANG_FILE} CLANG_FILE)'。 cmake自己做。 如果你要写答案,我很乐意接受它是正确的。谢谢 –