llvm's cmake integration

戏子无情 提交于 2019-12-13 02:28:54

问题


I'm currently building a compiler/interpreter in C/C++. When I noticed LLVM I thought it would fit greatly to what I needed and so I'm trying to integrate LLVM in my existing build system (I use CMake).

I read this bout integration of LLVM in CMake. I copy and pasted the example CMakeLists.txt, changed the LLVM_ROOT to ~/.llvm/ (that's where I downloaded and build LLVM and clang) and it says it isn't a valid LLVM-install. Best result I could achieve was the error message "Can't find LLVMConfig" by changing LLVM_ROOT to ~/.llvm/llvm.

My ~/.llvm/ folder looks like this:

~/.llvm/llvm         # this folder contains source files
~/.llvm/build        # this folder contains object, executable and library files

I downloaded LLVM and clang via SVN. I did not build it with CMake. Is it just me or is something wrong with the CMakeLists.txt?


回答1:


This CMake documentation page got rotted, but setting up CMake for LLVM developing isn't different from any other project. If your headers/libs are installed into non-standard prefix, there is no way for CMake to guess it.

You need to set CMAKE_PREFIX_PATH to the LLVM installation prefix or CMAKE_MODULE_PATH to prefix/share/llvm/cmake to make it work.

And yes, use the second code snippet from documentation (under Alternativaly, you can utilize CMake’s find_package functionality. line).



来源:https://stackoverflow.com/questions/13923568/llvms-cmake-integration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!