Exploring a glossary of LLVM's important CMake directives
LLVM has switched to CMake from GNU autoconf due to higher flexibility in terms of choosing underlying build systems. Ever since, LLVM has come up with many custom CMake functions, macros, and rules to optimize its own usage. This section will give you an overview of the most important and frequently used ones among them. We will learn how and when to use them.
Using the CMake function to add new libraries
Libraries are the building blocks of the LLVM framework. However, when writing CMakeLists.txt
for a new library, you shouldn't use the normal add_library
directive that appears in normal CMakeLists.txt
files, as follows:
# In an in-tree CMakeLists.txt file… add_library(MyLLVMPass SHARED   MyPass.cpp) # Do NOT do this to add a new LLVM library
There are several drawbacks of using the vanilla add_library
here, as follows:
- As shown in Chapter 1, Saving Resources When Building LLVM...