Skip to content

Instantly share code, notes, and snippets.

@sheredom
Created May 23, 2019 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheredom/5121d1d34449a83fdc91bbba9ecb9f06 to your computer and use it in GitHub Desktop.
Save sheredom/5121d1d34449a83fdc91bbba9ecb9f06 to your computer and use it in GitHub Desktop.
LLVM plugin CMake
# LLVM requires C++11.
set(CMAKE_CXX_STANDARD 11)
# Find LLVM (this looks for LLVMConfig.cmake somewhere in the PATH or LLVM_DIR).
find_package(LLVM REQUIRED CONFIG)
# Enable us to use the LLVM CMake modules.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_CMAKE_DIR}")
# Enable us to use add_llvm_library.
include(AddLLVM)
# Bring in the LLVM include directories.
include_directories(${LLVM_INCLUDE_DIRS})
# Bring in any definitions LLVM requires.
add_definitions(${LLVM_DEFINITIONS})
# Add a module library that we can plugin to opt.
add_llvm_library(my_plugin MODULE plugin.cpp PLUGIN_TOOL opt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment