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
> -----Original Message----- > From: Jun Koi [mailto:junkoi2004 at gmail.com] > Sent: Thursday, October 18, 2012 8:23 PM > > > > $ 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.Actually I am using the tip of the trunk and not a release. But I think it does not matter ... an eyeballing of the 3.1 directory shows that the cmake scripts are all there, at least in the source.> 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.cmakeI was not entirely honest with that path. The actual path that I use is non-standard location where LLVM gets installed. And there is definitely a "share/llvm/cmake" directory in that place. Here is another possibility ... are you building LLVM itself with configure/make or with cmake? I don't have access to my build setup right now to check this possibility, but I think the configure/make version does not install the cmake scripts. At least that's what it looks like from the top-level Makefiles. Maybe everything is working for me because of the fact that I use cmake+ninja to build and install my LLVM/Clang/Polly setup? Sameer.
On Fri, Oct 19, 2012 at 12:59 AM, Sahasrabuddhe, Sameer <Sameer.Sahasrabuddhe at amd.com> wrote:>> -----Original Message----- >> From: Jun Koi [mailto:junkoi2004 at gmail.com] >> Sent: Thursday, October 18, 2012 8:23 PM >> > >> > $ 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. > > Actually I am using the tip of the trunk and not a release. But I think it does not matter ... an eyeballing of the 3.1 directory shows that the cmake scripts are all there, at least in the source. > >> 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 > > I was not entirely honest with that path. The actual path that I use is non-standard location where LLVM gets installed. And there is definitely a "share/llvm/cmake" directory in that place. > > Here is another possibility ... are you building LLVM itself with configure/make or with cmake? I don't have access to my build setup right now to check this possibility, but I think the configure/make version does not install the cmake scripts. At least that's what it looks like from the top-level Makefiles. Maybe everything is working for me because of the fact that I use cmake+ninja to build and install my LLVM/Clang/Polly setup?you are right: i compiled llvm with configure & make. then i guess that is why i miss the cmake file. thanks.