我想在我的Ubuntu機器上使用cmake
編譯我的CLang
獨立應用程序,但沒有運氣。這裏是我的CMakeLists.txt
: -g ++編譯CLang獨立應用程序,但CMake不是
cmake_minimum_required(VERSION 2.8)
project(Demo)
execute_process(
COMMAND llvm-config --cxxflags
OUTPUT_VARIABLE LLVM_CXX_FLAGS
)
execute_process(
COMMAND llvm-config --ldflags
OUTPUT_VARIABLE LLVM_LD_FLAGS
)
execute_process(
COMMAND llvm-config --libs
OUTPUT_VARIABLE LLVM_LIB_FLAGS
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}")
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} ${LLVM_LD_FLAGS}")
add_executable(clangTestApp TestCLang.cpp)
target_link_libraries(clangTestApp ${LLVM_LIB_FLAGS})
這裏是輸出,當我運行從項目目錄中生成目錄cmake ..
: -
-- Configuring done
CMake Error at CMakeLists.txt:23 (add_executable):
Target "clangTestApp" links to item "-lLLVMAsmParser -lLLVMInstrumentation
-lLLVMLinker -lLLVMArchive -lLLVMBitReader -lLLVMDebugInfo -lLLVMJIT
-lLLVMipo -lLLVMVectorize -lLLVMBitWriter -lLLVMTableGen
-lLLVMHexagonCodeGen -lLLVMHexagonDesc -lLLVMHexagonInfo
-lLLVMHexagonAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo
-lLLVMNVPTXAsmPrinter -lLLVMMBlazeAsmParser -lLLVMMBlazeDisassembler
-lLLVMMBlazeCodeGen -lLLVMMBlazeDesc -lLLVMMBlazeInfo
-lLLVMMBlazeAsmPrinter -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo
-lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info
-lLLVMMSP430AsmPrinter -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo
-lLLVMCellSPUCodeGen -lLLVMCellSPUDesc -lLLVMCellSPUInfo
-lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc
-lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMARMDisassembler
-lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMInfo
-lLLVMARMAsmPrinter -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc
-lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMSparcCodeGen
-lLLVMSparcDesc -lLLVMSparcInfo -lLLVMX86Disassembler -lLLVMX86AsmParser
-lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter
-lLLVMX86Utils -lLLVMR600CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter
-lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMMCDisassembler
-lLLVMMCParser -lLLVMInterpreter -lLLVMCodeGen -lLLVMScalarOpts
-lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT
-lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject
-lLLVMCore -lLLVMSupport
" which has leading or trailing whitespace. This is now an error according
to policy CMP0004.
-- Generating done
-- Build files have been written to: /home/prakhar/Desktop/CLang/Demo/build
現在,當我運行做內搭目錄,它給我: -
Scanning dependencies of target clangTestApp
[100%] Building CXX object CMakeFiles/clangTestApp.dir/TestCLang.o
Linking CXX executable clangTestApp
c++: fatal error: no input files
compilation terminated.
make[2]: *** [clangTestApp] Error 4
make[1]: *** [CMakeFiles/clangTestApp.dir/all] Error 2
make: *** [all] Error 2
我不知道爲什麼C++是說no input files
。如果有人知道發生了什麼事情?
謝謝
編譯失敗,因爲創建正確的makefile失敗。由於'cmake'失敗,創建正確的makefile失敗。並且'cmake'失敗,因爲在庫列表中留有空白(注意最後一個庫和結束報價之間的那些換行符)。 –
@JoachimPileborg感謝您的快速回復。你能告訴我如何刪除那個換行符嗎?或者,也許我正在使用一些過時的方式來設置鏈接庫。 –
檢查[execute_process的文檔](http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:execute_process)。我確信有一些選擇可能會有所幫助。 ;) –