Skip to content

Improve build system: --disable-shared support, consistent library naming, conditional examples#808

Merged
ithewei merged 3 commits intomasterfrom
copilot/improve-build-system
Mar 10, 2026
Merged

Improve build system: --disable-shared support, consistent library naming, conditional examples#808
ithewei merged 3 commits intomasterfrom
copilot/improve-build-system

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

The configure/makefile build system was missing --disable-shared/--disable-static support, producing differently-named static libraries than CMake (libhv.a vs libhv_static.a), and unconditionally building all examples regardless of module settings.

--disable-shared / --disable-static support

  • Added BUILD_SHARED and BUILD_STATIC options to config.ini/config.mk
  • Added specific cases in configure before the generic --enable-*/--disable-* handlers
  • Makefile libhv target now conditionally sets TARGET_TYPE based on these flags
./configure --disable-shared   # static only
./configure --disable-static   # shared only

Consistent static library naming

  • Added set_target_properties(hv_static PROPERTIES OUTPUT_NAME hv) in CMakeLists.txt, guarded by if(NOT (WIN32 AND BUILD_SHARED)) to avoid .lib naming conflict on Windows MSVC when both shared and static libraries are built
  • On non-Windows platforms, both build systems now produce libhv.a / libhv.so
  • On Windows with both shared and static enabled, the static library remains hv_static.lib to avoid overwriting the shared import library hv.lib

Conditional examples in Makefile

  • examples target now gates on WITH_EVPP, WITH_HTTP, WITH_HTTP_SERVER, WITH_HTTP_CLIENT, WITH_MQTT — matching the existing examples/CMakeLists.txt conditionals
  • Added missing multi-thread examples (multi-acceptor-processes, multi-acceptor-threads, one-acceptor-multi-workers) to examples/CMakeLists.txt
Original prompt

This section details on the original issue you should resolve

<issue_title>build system need improve</issue_title>
<issue_description>Improvements to the build system:

  1. The configure/makefile does not support the --disable-shared option.
  2. The names of the static libraries generated by configure/makefile and CMake are inconsistent.
  3. Some examples cannot be built with configure/makefile.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…g, conditional examples

1. Add --disable-shared and --disable-static options to configure/makefile
2. Make CMake static library output name consistent with Makefile (libhv.a)
3. Make Makefile examples target conditional based on module settings
4. Add multi-thread examples to CMakeLists.txt

Co-authored-by: ithewei <26049660+ithewei@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve build system for better configuration Improve build system: --disable-shared support, consistent library naming, conditional examples Mar 9, 2026
@ithewei ithewei marked this pull request as ready for review March 10, 2026 12:25
Copilot AI review requested due to automatic review settings March 10, 2026 12:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the configure/Makefile build system for the libhv library to address three issues: lack of --disable-shared/--disable-static support, inconsistent static library naming between CMake and Makefile builds, and unconditional example building regardless of module settings.

Changes:

  • Added BUILD_SHARED/BUILD_STATIC options to config.ini, config.mk, configure, and Makefile to support selectively building shared/static libraries
  • Set OUTPUT_NAME hv on the CMake hv_static target so both build systems produce libhv.a instead of libhv_static.a
  • Made example targets conditional on module flags (WITH_EVPP, WITH_HTTP, etc.) in the Makefile, and added missing multi-thread examples to examples/CMakeLists.txt

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config.ini Added BUILD_SHARED=yes and BUILD_STATIC=yes defaults
config.mk Replaced with full commented template matching config.ini; added BUILD_SHARED/BUILD_STATIC; removed hardcoded CONFIG_DATE
configure Added --enable/disable-shared and --enable/disable-static cases before generic handlers; added help text
Makefile Made libhv target conditionally build shared/static based on flags; made examples target conditional on module flags
CMakeLists.txt Added set_target_properties(hv_static PROPERTIES OUTPUT_NAME hv) for consistent naming
examples/CMakeLists.txt Added missing multi-thread examples (multi-acceptor-processes, multi-acceptor-threads, one-acceptor-multi-workers)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config.mk Outdated
Comment on lines +1 to +2
# Don't modify this file, you should modify config.mk or
# run ./configure --with-MODULE --enable-FEATURE
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "Don't modify this file, you should modify config.mk" is self-referential when placed in config.mk itself. This comment was originally intended for config.ini (the template). In config.mk, the comment should either be removed or changed to something like "# This file is generated by ./configure. Edit config.ini or run ./configure to change settings."

Copilot uses AI. Check for mistakes.
Comment thread CMakeLists.txt Outdated
target_include_directories(hv_static PRIVATE ${LIBHV_SRCDIRS}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_link_libraries(hv_static ${LIBS})
set_target_properties(hv_static PROPERTIES OUTPUT_NAME hv)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows with MSVC, setting OUTPUT_NAME hv on the static target will cause a naming conflict when both BUILD_SHARED and BUILD_STATIC are enabled (the default). The shared library hv already produces an import library hv.lib, and now the static library hv_static will also produce hv.lib in the same output directory, causing one to overwrite the other.

A common solution is to also set ARCHIVE_OUTPUT_NAME to a different name (e.g., hv_static) on the static target only when BUILD_SHARED is also enabled, or alternatively to use the CMAKE_STATIC_LIBRARY_SUFFIX workaround. Another approach is to guard this property with a condition like if(NOT BUILD_SHARED OR NOT WIN32).

Copilot uses AI. Check for mistakes.
@ithewei
Copy link
Copy Markdown
Owner

ithewei commented Mar 10, 2026

@copilot apply changes based on the comments in this thread

…ming conflict

1. Remove self-referential comment from config.mk (comment was for config.ini)
2. Guard OUTPUT_NAME hv on static target to avoid .lib conflict on Windows
   when both BUILD_SHARED and BUILD_STATIC are enabled

Co-authored-by: ithewei <26049660+ithewei@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot apply changes based on the comments in this thread

Applied both review changes in 9f9eaf5:

  1. Removed the self-referential comment from config.mk (the "Don't modify this file, you should modify config.mk" comment was only appropriate in config.ini).
  2. Guarded set_target_properties(hv_static PROPERTIES OUTPUT_NAME hv) with if(NOT (WIN32 AND BUILD_SHARED)) to prevent the .lib naming conflict on Windows MSVC when both shared and static libraries are built. On Windows with both enabled, the static library remains hv_static.lib to avoid overwriting the shared import library hv.lib.

@ithewei ithewei merged commit be92325 into master Mar 10, 2026
12 checks passed
@ithewei ithewei deleted the copilot/improve-build-system branch March 17, 2026 09:22
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.

build system need improve

3 participants