ysyx-workbench/npc/utils/sdb/CMakeLists.txt
2024-07-09 20:42:01 +08:00

34 lines
1,021 B
CMake

find_package(Readline REQUIRED)
find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)
find_package(LLVM CONFIG REQUIRED)
set(PARSER_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(LEXER_OUT "${PARSER_DIR}/lexer.c")
set(PARSER_OUT "${PARSER_DIR}/parser.c")
flex_target(LEXER addrexp.l "${LEXER_OUT}"
DEFINES_FILE "${PARSER_DIR}/addrexp_lex.h")
bison_target(PARSER addrexp.y "${PARSER_OUT}"
DEFINES_FILE "${PARSER_DIR}/addrexp.h")
add_flex_bison_dependency(LEXER PARSER)
add_library(sdb OBJECT sdb.cpp console.cpp disasm.cpp "${LEXER_OUT}"
"${PARSER_OUT}")
llvm_map_components_to_libnames(
LLVM_LIBS
core
target
asmparser
riscvasmparser
riscvdesc
riscvdisassembler
riscvinfo
riscvtargetmca)
target_link_libraries(sdb PUBLIC ${LLVM_LIBS})
target_link_libraries(sdb PRIVATE ${Readline_LIBRARY})
target_include_directories(
sdb
PRIVATE ${PARSER_DIR} ${Readline_INCLUDE_DIR}
PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(sdb PUBLIC include)