Dear all,<br><br>I want to build an LLVM pass by using CMake.<br><br>After reading the ralevant part of the documentation (<a href="http://llvm.org/releases/3.1/docs/CMake.html#passdev">http://llvm.org/releases/3.1/docs/CMake.html#passdev</a>), <br>
I copied the files in the llvm/lib/Transforms/Hello to another folder in order to give a try. <br>Then I renamed the folder as Hello2.<br clear="all">Then I have changed CMakeLists.txt as following:<br><br>cmake_minimum_required(VERSION 2.8)<br>
<br># A convenience variable:<br>set(LLVM_ROOT "../llvm_cmake_build" CACHE PATH "Root of LLVM install.")<br><br># A bit of a sanity check:<br>if( NOT EXISTS ${LLVM_ROOT}/include/llvm )<br>message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")<br>
endif()<br><br># We incorporate the CMake features provided by LLVM:<br>set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")<br>include(LLVMConfig)<br><br>find_package(LLVM)<br><br>if( NOT LLVM_FOUND )<br>
message(FATAL_ERROR "LLVM package can't be found. Set CMAKE_PREFIX_PATH variable to LLVM's installation prefix.")<br>endif()<br><br># Define add_llvm_* macro's.<br>include(AddLLVM)<br><br>add_definitions(${LLVM_DEFINITIONS})<br>
include_directories(${LLVM_INCLUDE_DIRS})<br>link_directories(${LLVM_LIBRARY_DIRS})<br><br><br>add_llvm_loadable_module( LLVMHello<br> Hello.cpp<br> )<br><br>Furthermore, I created a separate build and install directories in order to build and install my pass.<br>
cd Hello2_build<br>cmake ../Hello2 -DCMAKE_INSTALL_PREFIX=../Hello2_install/<br><br>-- The C compiler identification is GNU<br>-- The CXX compiler identification is GNU<br>-- Check for working C compiler: /usr/bin/gcc<br>
-- Check for working C compiler: /usr/bin/gcc -- works<br>-- Detecting C compiler ABI info<br>-- Detecting C compiler ABI info - done<br>-- Check for working CXX compiler: /usr/bin/c++<br>-- Check for working CXX compiler: /usr/bin/c++ -- works<br>
-- Detecting CXX compiler ABI info<br>-- Detecting CXX compiler ABI info - done<br>-- Configuring done<br>-- Generating done<br><br>It seems that cmake is ok. When I run make install, it gives errors (see below) and i think the reason is that it can not find the directory to llvm header files.<br>
I could not figure it out which variable to set and how to use it in order to point the required directory ? <br>( as in the make pass build which requires LLVM_SRC_ROOT LLVM_OBJ_ROOT variables to be set)<br><br>Hello2/Hello.cpp:17:23: error: llvm/Pass.h: No such file or directory<br>
Hello2/Hello.cpp:18:27: error: llvm/Function.h: No such file or directory<br>Hello2/Hello.cpp:19:38: error: llvm/Support/raw_ostream.h: No such file or directory<br>Hello2/Hello.cpp:20:32: error: llvm/ADT/Statistic.h: No such file or directory<br>
Hello2/Hello.cpp:21: error: ‘llvm’ is not a namespace-name<br>...<br><br>Your feedback is very welcome.<br>Thanks.<br><br>-- <br>Best Regards,<br>Erkan<br>------------------<br><br>