Separate op-finder into library and executable

This commit is contained in:
Erki 2021-03-07 13:51:29 +02:00
parent 83ca2deb0e
commit 53c24c6d5e
18 changed files with 52 additions and 31 deletions

View File

@ -5,4 +5,5 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
add_subdirectory(op-finder-lib)
add_subdirectory(op-finder) add_subdirectory(op-finder)

View File

@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.17)
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
${PROJECT_SOURCE_DIR}/dependencies
${LLVM_INCLUDE_DIRS}
)
target_compile_definitions(op-finder-lib
PUBLIC
${LLVM_DEFINITIONS}
)
target_link_libraries(op-finder-lib
PRIVATE
${llvm_libs}
clangTooling
clangBasic
clangASTMatchers
)

View File

@ -1,4 +1,4 @@
// //src
// Created by erki on 02.03.21. // Created by erki on 02.03.21.
// //

View File

@ -1,8 +1,5 @@
cmake_minimum_required(VERSION 3.17) cmake_minimum_required(VERSION 3.17)
find_package(Clang REQUIRED)
find_package(LLVM REQUIRED COMPONENTS Support Option Core)
# LLVM is typically compiled without RTTI. Weird linker errors ensue if # LLVM is typically compiled without RTTI. Weird linker errors ensue if
# you keep RTTI on and try to link. # you keep RTTI on and try to link.
if (NOT LLVM_ENABLE_RTTI) if (NOT LLVM_ENABLE_RTTI)
@ -15,33 +12,9 @@ if (NOT LLVM_ENABLE_RTTI)
endif () endif ()
endif () endif ()
llvm_map_components_to_libnames(llvm_libs support option core)
add_executable(op-finder add_executable(op-finder
main.cpp main.cpp)
OperationFinder.cpp
OperationStorage.cpp
OperationAstMatcher.cpp
OperationFinderAstVisitor.cpp
OperationFinderAstConsumer.cpp
OperationFinderAstAction.cpp
OperationLog.cpp)
target_include_directories(op-finder
PRIVATE
${LLVM_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/dependencies
)
target_compile_definitions(op-finder
PRIVATE
${LLVM_DEFINITIONS}
)
target_link_libraries(op-finder target_link_libraries(op-finder
PRIVATE PUBLIC
${llvm_libs} op-finder-lib)
clangTooling
clangBasic
clangASTMatchers
)