I am trying to compile my CLang
standalone app using cmake
on my Ubuntu machine, but no luck yet. Here is my CMakeLists.txt
:-
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})
Here is the output when I am running cmake ..
from build directory inside project directory:-
-- 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
Now when I am running make inside build directory, its giving me:-
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
I don't know why c++ is saying no input files
. If anybody have a clue whats going on?
Thanks
I suggest you use a FindClang.cmake which you can find eg here: https://github.com/woboq/woboq_codebrowser/blob/master/cmake/modules/FindClang.cmake (Or just google for FindClang.cmake). You'll also need the corresponding FindLLVM.cmake ( https://github.com/woboq/woboq_codebrowser/blob/master/cmake/modules/FindLLVM.cmake )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.