Skip to content

编译生成的库区分Debug和Release #686

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

Closed
XXOO9 opened this issue Feb 20, 2025 · 1 comment
Closed

编译生成的库区分Debug和Release #686

XXOO9 opened this issue Feb 20, 2025 · 1 comment

Comments

@XXOO9
Copy link

XXOO9 commented Feb 20, 2025

大佬,我用cmake编译出来的库,不管是debug模式还是release模式下,生成的文件名都是hv.lib, 怎么把debug模式编译出来的库名变成libhvd.lib。

@xs-411
Copy link

xs-411 commented Feb 20, 2025

# 定义库名称的基础部分
set(LIB_NAME "hv")

# 根据构建类型设置库名称的后缀
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(LIB_NAME_SUFFIX "-debug")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
    set(LIB_NAME_SUFFIX "-release")
endif()

# 组合库名称
set(FULL_LIB_NAME "${LIB_NAME}${LIB_NAME_SUFFIX}")

# 添加库
add_library(${FULL_LIB_NAME} SHARED ${LIBHV_SRCS})

我使用的是这种方式.

@ithewei ithewei closed this as completed May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants