Skip to content
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

build: 🛠️ Remove hconfig.h from Git index #682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tayne3
Copy link
Contributor

@tayne3 tayne3 commented Feb 13, 2025

变更内容:

  1. hconfig.h 取消跟踪: 之前 hconfig.h 文件被跟踪在 Git 索引中。 这导致每次构建后,都会触发 GIT 中出现不必要的误报。
  2. 输出目录可外部指定: CMAKE_LIBRARY_OUTPUT_DIRECTORY、CMAKE_ARCHIVE_OUTPUT_DIRECTORY 和 CMAKE_RUNTIME_OUTPUT_DIRECTORY 变量应可在外部配置。

通过本次更改,CMake 项目可以更好地将 libhv 作为子模块进行管理,以及使用 FetchContent_Declare 或 CPM(基于 FetchContent_Declare 的 CMake 包管理器)将 libhv 作为依赖项进行导入。

示例:

  • 使用 FetchContent_Declare:
include(FetchContent)
FetchContent_Declare(
  libhv
  GIT_REPOSITORY https://github.com/ithewei/libhv.git
  GIT_TAG v1.3.3)
FetchContent_MakeAvailable(libhv)
include_directories(${libhv_SOURCE_DIR}/include)
  • 使用 CPM:
include(cmake/CPM.cmake)
CPMAddPackage(
    NAME libhv
    GIT_REPOSITORY "https://github.com/ithewei/libhv.git"
    GIT_TAG v1.3.3
    OPTIONS "BUILD_INSTALL OFF" "BUILD_SHARED ON" "BUILD_STATIC OFF" "WITH_EVPP ON" "WITH_HTTP ON" "WITH_HTTP_SERVER ON" "WITH_HTTP_CLIENT ON"
)
include_directories(${libhv_SOURCE_DIR}/include)

建议:

库对象直接添加 PUBLI 的头文件搜索路径, 在将 libhv 作为子模块时不需要手动制定头文件搜索路径。

target_include_directories(hv PUBLIC ${INCDIR}
target_include_directories(hv_static PUBLIC ${INCDIR}

- Remove hconfig.h from Git index
- Add policy handling for CMP0077 with a default setting
- Conditionally set library, archive, and runtime output directories
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

Successfully merging this pull request may close these issues.

1 participant