50 lines
1.3 KiB
CMake
50 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
|
|
find_package(nlohmann_json REQUIRED)
|
|
find_package(Clang REQUIRED)
|
|
find_package(LLVM REQUIRED COMPONENTS Support Option Core)
|
|
|
|
# LLVM is typically compiled without RTTI. Weird linker errors ensue if
|
|
# you keep RTTI on and try to link.
|
|
if (NOT LLVM_ENABLE_RTTI)
|
|
if (MSVC)
|
|
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
|
else ()
|
|
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|
endif ()
|
|
endif ()
|
|
|
|
llvm_map_components_to_libnames(llvm_libs support option core)
|
|
|
|
add_library(op-finder-lib STATIC
|
|
src/OperationFinder.cpp
|
|
src/OperationStorage.cpp
|
|
src/OperationAstMatcher.cpp
|
|
src/OperationFinderAstVisitor.cpp
|
|
src/OperationFinderAstConsumer.cpp
|
|
src/OperationFinderAstAction.cpp
|
|
src/OperationLog.cpp)
|
|
|
|
target_include_directories(op-finder-lib
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
${LLVM_INCLUDE_DIRS}
|
|
)
|
|
|
|
target_compile_definitions(op-finder-lib
|
|
PUBLIC
|
|
${LLVM_DEFINITIONS}
|
|
)
|
|
|
|
target_link_libraries(op-finder-lib
|
|
PUBLIC
|
|
nlohmann_json::nlohmann_json
|
|
PRIVATE
|
|
${llvm_libs}
|
|
clangTooling
|
|
clangBasic
|
|
clangASTMatchers
|
|
)
|