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自己做。 如果你要寫答案,我很樂意接受它是正確的。謝謝 –