I would like to use the build system of llvm to build my tool that is based on clang.
I made a new directory under clang/tools with the name of the tool “polyextract”. I copied the CMakelist.txt and Makefile from the clang-cc and modified them
I then configure from llvm trunk and make, but unfortunately I only get the object file generated and no executable is generated in the Debug/bin
I would appreciate your help. Sorry I am not familiar with the build systems.
Attached are the files I modified
Thanks
Moataz
CMakeLists.txt (354 Bytes)
Makefile (1.05 KB)
I have managed to get it the executable generated by adding my directory to the Makefile in clang/tools directory.
So in general here is what I had to t do
- make a new directory with for the app
- copy and modify the makefile and CMakelists.txt
- add the subdirectory in the CMakelists.txt in clang/tools
- add the directory to the DIRS variable in clang/tools/Makefile
So the LLVM and Clang uses a mix of cmake and Makefiles? Can you give an abstract view of how the build process works?
Thanks,
Moataz
Hi Moataz,
I have managed to get it the executable generated by adding my directory
to the Makefile in clang/tools directory.
This is also what we do for our tool. Which reminds me that it would be
nice to have tools/Makefile and CMakeLists.txt automatically detect and
build additional tools. I'll suggest a patch.
So the LLVM and Clang uses a mix of cmake and Makefiles? Can you give an
abstract view of how the build process works?
LLVM can be built with either CMake or "../src/configure; make". They
are mostly equivalent.
Cheers, Axel.
The simple way is to use llvm/clang as static/shared libraries. You
can put your source files wherever you want, and write a Makefile
manually, like this:
INCLUDE = -I$(HOME)/llvm/include -I$(HOME)/llvm/tools/clang/include
CXXFLAGS = -g -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS \
-fno-exceptions -fno-rtti \
$(INCLUDE)
LIBS = -L$(HOME)/llvm/Debug/lib \
-lclangFrontend \
-lclangCodeGen \
-lclangAnalysis \
-lclangRewrite \
-lclangSema \
-lclangAST \
-lclangParse \
-lclangLex \
-lclangBasic \
-lclangIndex \
-lLLVMBitWriter \
-lLLVMAsmParser \
-lLLVMArchive \
-lLLVMBitReader \
-lLLVMCore \
-lLLVMSupport \
-lLLVMSystem \
-lLLVMCodeGen \
-lLLVMAnalysis \
-lLLVMTarget \
-ldl -lpthread
HEADERS =
OBJS = foobar.o
foobar: $(OBJS) $(HEADERS)
g++ -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -fno-exceptions -fno-rtti \
-o $@ -g $(OBJS) $(LIBS)