-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【腾讯犀牛鸟开源课题实战】对接mysql sdk #188
base: main
Are you sure you want to change the base?
Changes from 44 commits
887e380
6f15be1
58f7c5b
64d8cbb
02c4d79
744f1fd
785e45e
06c39e4
639acee
a885815
51b1bef
ba8251b
f9d96c3
f0aa64a
baa85fe
2540aeb
8b87544
4fe5018
ee72e7c
78545cf
3cbd818
7fdea4a
930e792
e3ed65f
8d5123c
6a099eb
9a2d419
7b87fc5
a973d7b
cf1adb5
0eb8542
ac3f174
e4cb88d
65ee445
2f00d59
c7ead55
4469b8e
db50c5d
af5c541
24dd9db
f6256d7
a6c6f86
ece0672
2592d90
c907db1
81e9d81
9bfdae2
ac7febf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# mysqlclient.cmake | ||
|
||
include(FetchContent) | ||
|
||
|
||
if(NOT DEFINED MYSQLCLIENT_VERSION_TAG) | ||
set(MYSQLCLIENT_VERSION_TAG 8.0.39) | ||
endif() | ||
|
||
# ================================ | ||
# Construct Download URL | ||
# ================================ | ||
string(REGEX REPLACE "^([0-9]+\\.[0-9]+)\\..*" "\\1" MYSQLCLIENT_MAJOR_VER "${MYSQLCLIENT_VERSION_TAG}") | ||
set(MYSQLCLIENT_URL "https://dev.mysql.com/get/Downloads/MySQL-${MYSQLCLIENT_MAJOR_VER}/mysql-${MYSQLCLIENT_VERSION_TAG}-linux-glibc2.17-x86_64-minimal.tar.xz") | ||
|
||
# ================================ | ||
# FetchContent Declaration | ||
# ================================ | ||
FetchContent_Declare( | ||
mysqlclient | ||
URL ${MYSQLCLIENT_URL} | ||
SOURCE_DIR ${TRPC_ROOT_PATH}/cmake_third_party/mysqlclient | ||
) | ||
|
||
# ================================ | ||
# Populate the Content | ||
# ================================ | ||
FetchContent_GetProperties(mysqlclient) | ||
if(NOT mysqlclient_POPULATED) | ||
FetchContent_Populate(mysqlclient) | ||
endif() | ||
|
||
set(MYSQLCLIENT_INCLUDE_DIR "${mysqlclient_SOURCE_DIR}/include") | ||
set(MYSQLCLIENT_LIB_DIR "${mysqlclient_SOURCE_DIR}/lib") | ||
|
||
|
||
# Copy MySQL header files to the desired directory | ||
file(MAKE_DIRECTORY "${MYSQLCLIENT_INCLUDE_DIR}/mysqlclient") | ||
file(GLOB MYSQL_HEADERS "${mysqlclient_SOURCE_DIR}/include/*.h") | ||
|
||
# Copy header files to the target include directory | ||
file(COPY ${MYSQL_HEADERS} DESTINATION "${MYSQLCLIENT_INCLUDE_DIR}/mysqlclient") | ||
|
||
# ================================ | ||
# Define Imported Library | ||
# ================================ | ||
add_library(mysqlclient STATIC IMPORTED) | ||
|
||
set_target_properties(mysqlclient PROPERTIES | ||
IMPORTED_LOCATION "${MYSQLCLIENT_LIB_DIR}/libmysqlclient.a" | ||
INTERFACE_INCLUDE_DIRECTORIES "${MYSQLCLIENT_INCLUDE_DIR}" | ||
) | ||
|
||
target_link_libraries(mysqlclient INTERFACE | ||
"${MYSQLCLIENT_LIB_DIR}/private/libcrypto.so" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 动态链这些库的话,服务二进制程序,是不是也要带上这些动态库? 比如,我把服务二进制程序拷贝到另一个容器里,是不是就不能运行了? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 原本的包里有libmysqlclient.a和libmysqlclient.so,但都不能单独用,都依赖一堆private目录里的一些动态库 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ldd看下libmysqlclient.a,是否全依赖了这些so库? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改,只依赖ssl和crypto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个libcrypto.so是编译产生的吗?还是mysqlclient代码仓库里带的? 能复用系统库路径里ssl和crypto动态库吗?这两个库不太好随程序二进制发布而发布 |
||
"${MYSQLCLIENT_LIB_DIR}/private/libssl.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libgssapi_krb5.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libkrb5.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libk5crypto.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libkrb5support.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/liblber.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libldap.so" | ||
"${MYSQLCLIENT_LIB_DIR}/private/libsasl2.so" | ||
) | ||
|
||
add_library(trpc_mysqlclient ALIAS mysqlclient) | ||
|
||
|
||
set(TARGET_INCLUDE_PATHS ${TARGET_INCLUDE_PATHS} ${TRPC_ROOT_PATH}/cmake_third_party/mysqlclient/include) | ||
set(TARGET_LINK_LIBS ${TARGET_LINK_LIBS} trpc_mysqlclient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libmysqlclient支持so的编译吗?如果支持,可以也加上,可以参照框架其他三方so的cmake引入方式引入