代码拉取完成,页面将自动刷新
cmake_minimum_required(VERSION 3.29)
project(sqlGen)
set(CMAKE_CXX_STANDARD 17)
set(FLEXCXX_EXECUTABLE flexc++)
set(BISONCPP_EXECUTABLE bisonc++)
set(FLEXCPP_INPUT ${CMAKE_SOURCE_DIR}/sqlG.l) # Update this with the correct path if necessary
set(FLEXCPP_OUTPUTDIR ${CMAKE_CURRENT_SOURCE_DIR})
set(FLEXCPP_LEX_SOURCE ${FLEXCPP_OUTPUTDIR}/lex.cc)
# Copy SQL resources to the build directory
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/resources/*.sql)
# Specify the destination directory for SQL files in the build directory
set(DEST_DIR ${CMAKE_BINARY_DIR}/resources)
# Create a custom target to copy the SQL files
add_custom_target(copy_sql_files ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources ${DEST_DIR}
COMMENT "Copying SQL files to build directory"
)
# 手动生成 C++ 源文件
add_custom_command(
OUTPUT ${FLEXCPP_LEX_SOURCE}
#COMMAND ${FLEXCXX_EXECUTABLE} ${FLEXCPP_INPUT} --baseclass-header=FlexCppScannerBase.hpp --class-header=FlexCppScanner.hpp --class-name=FlexCppScanner --lex-source=flexcpplex.cpp --target-directory ${FLEXCPP_OUTPUTDIR}
COMMAND ${FLEXCXX_EXECUTABLE} ${FLEXCPP_INPUT} --target-directory ${FLEXCPP_OUTPUTDIR}
DEPENDS ${FLEXCPP_INPUT}
COMMENT "Generating lexer.cpp from lexer.l"
)
# Custom command to generate parser.cpp and parser.h from BisonC++
# add_custom_command(
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp ${CMAKE_CURRENT_BINARY_DIR}/parser.h
# COMMAND ${BISONCXX_EXECUTABLE} ${BISONCPP_INPUT} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
# DEPENDS ${BISONCPP_INPUT}
# COMMENT "Generating parser.cpp and parser.h from sqlG.ypp"
# )
# 添加生成的源文件到项目中
add_executable(${PROJECT_NAME} # 可执行文件名称
${FLEXCPP_LEX_SOURCE}
main.cpp
create_tablt_sql_define.hpp
enum_classes.hpp
create_table_sql_define.cpp # 你的其他源文件
)
add_dependencies(${PROJECT_NAME} copy_sql_files)
# 连接 FlexC++ 生成的代码到你的可执行文件
target_link_libraries(${PROJECT_NAME} stdc++fs)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。