hi, i am wondering if this link is still updated? http://www.llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source i follow the instruction from the link, and create in my ~/test/ directory the CMakeLists.txt with following content: $cat test/CMakeLists.txt find_package(LLVM) # Define add_llvm_* macro's. include(AddLLVM) add_definitions(${LLVM_DEFINITIONS}) include_directories(${LLVM_INCLUDE_DIRS}) link_directories(${LLVM_LIBRARY_DIRS}) add_subdirectory(Hello) ===== inside test/, i put Hello/ directory, copied from llvm-3.1.src/lib/Transforms/Hello. then inside test/, i tried to compile: test$ cmake . -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done CMake Warning at CMakeLists.txt:1 (find_package): Could not find module FindLLVM.cmake or a configuration file for package LLVM. Adjust CMAKE_MODULE_PATH to find FindLLVM.cmake or set LLVM_DIR to the directory containing a CMake configuration file for LLVM. The file will have one of the following names: LLVMConfig.cmake llvm-config.cmake CMake Error at CMakeLists.txt:4 (include): include could not find load file: AddLLVM CMake Error at Hello/CMakeLists.txt:1 (add_llvm_loadable_module): Unknown CMake command "add_llvm_loadable_module". CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 2.8) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring incomplete, errors occurred! ====== any idea on how to fix the problem? thanks, Jun
On 5 Oct 2012, at 08:34, Jun Koi wrote:> any idea on how to fix the problem?The correct solution is to fix the LLVM build to install the .cmake files in a location that CMake knows about. The hacky solution that I've used is just to copy them into the correct place manually. David
On Fri, Oct 5, 2012 at 3:39 PM, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> On 5 Oct 2012, at 08:34, Jun Koi wrote: > >> any idea on how to fix the problem? > > The correct solution is to fix the LLVM build to install the .cmake files in a location that CMake knows about.could you please elaborate?> The hacky solution that I've used is just to copy them into the correct place manually.could you please elaborate? what do i need to copy, and where? if that matters, i compiled and installed llvm 3.1 from source in normal way: ./configure; make; make install thanks, Jun
On Fri, 5 Oct 2012 13:04:46 +0530 Jun Koi <junkoi2004 at gmail.com> wrote:> i am wondering if this link is still updated? > > http://www.llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source > > i follow the instruction from the link, and create in my ~/test/ > directory the CMakeLists.txt with following content: ><snip>> CMake Warning at CMakeLists.txt:1 (find_package): > Could not find module FindLLVM.cmake or a configuration file for > package LLVM.This error occurs when llvm-config is not in the path. I tried the same thing by copying the CMake snippets from the above page into a new file: $ cd test $ cat CMakeLists.txt find_package(LLVM) # Define add_llvm_* macro's. include(AddLLVM) add_definitions(${LLVM_DEFINITIONS}) include_directories(${LLVM_INCLUDE_DIRS}) link_directories(${LLVM_LIBRARY_DIRS}) add_subdirectory(<pass name>) add_llvm_loadable_module(LLVMPassname Pass.cpp ) $ cmake . Everything worked at this stage. But if I removed llvm-config from my PATH, I get the following error instead: $ cmake . .... CMake Warning at CMakeLists.txt:1 (find_package): Could not find module FindLLVM.cmake or a configuration file for package LLVM. Adjust CMAKE_MODULE_PATH to find FindLLVM.cmake or set LLVM_DIR to the directory containing a CMake configuration file for LLVM. The file will have one of the following names: LLVMConfig.cmake llvm-config.cmake So I tried what cmake says: $ cmake -DLLVM_DIR=/usr/share/llvm/cmake . This worked with both 2.8.3 and 2.8.9 Hope that helps! Sameer.
On Thu, Oct 18, 2012 at 7:22 PM, Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com> wrote:> On Fri, 5 Oct 2012 13:04:46 +0530 > Jun Koi <junkoi2004 at gmail.com> wrote: > >> i am wondering if this link is still updated? >> >> http://www.llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source >> >> i follow the instruction from the link, and create in my ~/test/ >> directory the CMakeLists.txt with following content: >> > > <snip> > >> CMake Warning at CMakeLists.txt:1 (find_package): >> Could not find module FindLLVM.cmake or a configuration file for >> package LLVM. > > This error occurs when llvm-config is not in the path. I tried the same > thing by copying the CMake snippets from the above page into a new file: >no, this is not true on my case. on my machine, llvm-config is in the path, and can be called from anywhere.> $ cd test > $ cat CMakeLists.txt > find_package(LLVM) > > # Define add_llvm_* macro's. > include(AddLLVM) > > add_definitions(${LLVM_DEFINITIONS}) > include_directories(${LLVM_INCLUDE_DIRS}) > link_directories(${LLVM_LIBRARY_DIRS}) > > add_subdirectory(<pass name>) > > add_llvm_loadable_module(LLVMPassname > Pass.cpp > ) > > $ cmake . > > Everything worked at this stage. > > But if I removed llvm-config from my PATH, I get the following error > instead: > > $ cmake . > .... > CMake Warning at CMakeLists.txt:1 (find_package): > Could not find module FindLLVM.cmake or a configuration file for > package LLVM. > > Adjust CMAKE_MODULE_PATH to find FindLLVM.cmake or set LLVM_DIR to the > directory containing a CMake configuration file for LLVM. The file > will have one of the following names: > > LLVMConfig.cmake > llvm-config.cmake > > So I tried what cmake says: > > $ cmake -DLLVM_DIR=/usr/share/llvm/cmake . > > This worked with both 2.8.3 and 2.8.9 >perhaps that works for older LLVM, but not for 3.1. there is no such a thing as /usr/share/llvm/cmake and the suggestion from cmake above is not true, either: on 3.1, i cannot find LLVMConfig.cmake and llvm-config.cmake thanks, Jun