Fix C++ modules BMI installation and re-enable external build tests#7206
Fix C++ modules BMI installation and re-enable external build tests#7206arpittkhandelwal wants to merge 2 commits intoTheHPXProject:masterfrom
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 2 high |
🟢 Metrics 0 complexity · 0 duplication
Metric Results Complexity 0 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s CMake module support to rely on CMake’s native C++20 modules/BMI handling (requiring CMake ≥ 3.29) and re-enables the external dependent-project build tests when HPX_WITH_CXX_MODULES=ON.
Changes:
- Removed manual compiler flag injection for module BMI output (
-fmodule-output=...) and prebuilt module search paths (-fprebuilt-module-path=...) inHPX_CXXModules.cmake. - Re-enabled
tests/unit/buildexternal build tests for module-enabled builds by removing the earlyreturn()guard.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/unit/build/CMakeLists.txt |
Re-enables external build tests when modules are enabled. |
cmake/HPX_CXXModules.cmake |
Drops manual module BMI flag management to let modern CMake manage BMI generation/consumption. |
549eca4 to
70290e8
Compare
| @@ -110,28 +89,6 @@ function(hpx_configure_module_producer producer) | |||
| return() | |||
| endif() | |||
There was a problem hiding this comment.
Can this be removed as well?
There was a problem hiding this comment.
Yes, absolutely! Since the manual compiler flags that were below it have been removed, that return() check became a dangling zombie.
I've just pushed a commit that completely removes the redundant if(MSVC) checks from both the producer and consumer blocks.
70290e8 to
c27ae7d
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s CMake C++20 modules support to rely on CMake’s native module/BMI handling (CMake ≥ 3.29) and re-enables downstream external-build CI coverage when HPX_WITH_CXX_MODULES=ON.
Changes:
- Re-enabled external build tests by removing the
HPX_WITH_CXX_MODULESearly-return intests/unit/build/CMakeLists.txt. - Simplified module producer configuration to stop overriding CMake’s BMI/output handling, leaning on native
FILE_SET ... TYPE CXX_MODULES/CXX_MODULES_BMI. - Updated cmake-format command metadata to match the updated
hpx_configure_module_producersignature.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/unit/build/CMakeLists.txt | Removes the guard that skipped external build tests when modules are enabled. |
| libs/CMakeLists.txt | Updates module producer invocation to match the simplified macro API. |
| cmake/HPX_CXXModules.cmake | Removes manual module output/prebuilt-path flags and relies on CMake-native scanning/export behavior. |
| .cmake-format.py | Adjusts formatting metadata for the updated CMake function signature. |
c27ae7d to
3738eb9
Compare
3738eb9 to
7a3c5a2
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s CMake support for C++20 modules to rely on CMake’s native FILE_SET CXX_MODULES/BMI handling (now that HPX_WITH_CXX_MODULES requires newer CMake), and re-enables external build tests that were previously disabled for modules-enabled builds.
Changes:
- Remove manual compiler flag injection for module BMI output/consumption from
HPX_CXXModules.cmakeand simplify the producer macro API. - Re-enable
tests/unit/buildexternal build tests when C++ modules are enabled, with a pkg-config build tweak to force header fallback where needed. - Make module-consumer setup more robust across build-tree vs installed-target naming by checking for
HPXInternal::targets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit/build/CMakeLists.txt |
Re-enables external build tests with modules enabled; adjusts pkg-config build flags to disable module imports for that test path. |
libs/CMakeLists.txt |
Updates module producer setup to match the simplified hpx_configure_module_producer API. |
cmake/HPX_SetupTarget.cmake |
Adds support for consuming either build-tree or HPXInternal::-namespaced module interface targets when configuring module scanning. |
cmake/HPX_CXXModules.cmake |
Removes manual -fmodule-output/-fprebuilt-module-path flag management, relying on native CMake module handling. |
.cmake-format.py |
Updates cmake-format parser config for the updated hpx_configure_module_producer signature. |
Comments suppressed due to low confidence (1)
cmake/HPX_CXXModules.cmake:91
- The doc comment for
hpx_configure_module_consumersays it "sets necessary consumer compiler flags for clang and gcc", but the function now only propagatesCXX_SCAN_FOR_MODULESand adds Clang linker flags (-fuse-ld=lld,--error-limit=0). Please update the comment to reflect the current behavior (or reintroduce the described compiler-flag propagation if still required).
# hpx_configure_module_consumer(<consumer> <producer>])
#
# * propagates module-related properties from producer interface target
# * sets necessary consumer compiler flags for clang and gcc
function(hpx_configure_module_consumer consumer producer)
| hpx_configure_module_consumer(${target} HPXInternal::hpx_core_module_if) | ||
| endif() | ||
|
|
||
| if(TARGET hpx_full_module_if) | ||
| hpx_configure_module_consumer(${target} hpx_full_module_if) | ||
| elseif(TARGET HPXInternal::hpx_full_module_if) | ||
| hpx_configure_module_consumer(${target} HPXInternal::hpx_full_module_if) |
| if(TARGET hpx_full_module_if) | ||
| hpx_configure_module_consumer(${target} hpx_full_module_if) | ||
| elseif(TARGET HPXInternal::hpx_full_module_if) | ||
| hpx_configure_module_consumer(${target} HPXInternal::hpx_full_module_if) |
|
@arpittkhandelwal The changes to the build system seem not to have broken anything - good. However, they have notfixed anything either :/ Also, I think the copilot comments bear some truths with them. |
7a3c5a2 to
7b8741f
Compare
7b8741f to
7e8f2a6
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s CMake infrastructure for C++20 modules to rely on CMake’s native BMI/module handling, and re-enables external build tests when HPX_WITH_CXX_MODULES=ON so downstream find_package(HPX) consumers are exercised again.
Changes:
- Remove manual compiler flag injection for module BMI output/consumption and rely on CMake’s native module scanning/FILE_SET behavior.
- Re-enable external build tests for module-enabled builds and adjust pkg-config external test flags.
- Improve module-consumer setup logic to handle both in-tree and exported
HPXInternal::module interface targets.
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 |
|---|---|
tests/unit/build/CMakeLists.txt |
Re-enables external build tests with modules and adjusts pkg-config CXX flags. |
libs/CMakeLists.txt |
Updates module producer configuration call to match the simplified producer macro. |
examples/hello_world_component/CMakeLists.txt |
Adds module-aware linking/scanning for the external hello-world example. |
cmake/HPX_SetupTarget.cmake |
Makes module consumer configuration robust to HPXInternal:: exported target names. |
cmake/HPX_CXXModules.cmake |
Removes manual BMI path flags and simplifies producer/consumer module configuration. |
.cmake-format.py |
Updates formatting metadata for the changed CMake macro signature. |
|
@arpittkhandelwal I like your solution to the issue a lot. Thanks. However, while some of the external target now build, some others do not build yet. Please have a look at #7202, which applies other changes that may be helpful in resolving the issue. Could you please tend to the cmake-format issue reported? Also, please either accept the copilot changes or mark them as being irrelevant. |
7e8f2a6 to
cf503da
Compare
cf503da to
d252c42
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s CMake support for C++20 modules to rely on CMake’s native module/BMI handling (CMake ≥ 3.29) and re-enables the previously disabled external build tests when HPX_WITH_CXX_MODULES=ON.
Changes:
- Remove manual BMI output/prebuilt-module-path flag injection and simplify module producer/consumer wiring.
- Re-enable
tests/unit/buildexternal build tests with modules enabled, with adjustments for pkg-config based builds. - Improve robustness of module consumer setup by supporting both build-tree and installed (
HPXInternal::) module interface targets.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/build/CMakeLists.txt | Re-enables external build tests with modules; adjusts pkg-config compile flags to disable module imports for that test path. |
| libs/CMakeLists.txt | Updates module producer configuration call site to match simplified signature. |
| examples/hello_world_component/CMakeLists.txt | Adds module interface target linking and enables module scanning via hpx_setup_target(... SCAN_FOR_MODULES ON) in macro setup. |
| cmake/HPX_SetupTarget.cmake | Makes module consumer setup work with both non-namespaced and HPXInternal:: imported module interface targets; errors if missing. |
| cmake/HPX_CXXModules.cmake | Simplifies module producer/consumer macros to rely on CMake-native module scanning/installation behavior (removes manual flag injection). |
| .cmake-format.py | Updates formatting config for the changed hpx_configure_module_producer signature. |
| "${PROJECT_SOURCE_DIR}/examples/hello_world_component/Makefile" | ||
| SRC_DIR=${PROJECT_SOURCE_DIR}/examples/hello_world_component | ||
| HPX_DIR=${hpx_dir} CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} | ||
| CXX_FLAGS=${CMAKE_CXX_FLAGS_SAFE} PKG_CONFIG=${PKG_CONFIG_EXECUTABLE} | ||
| CXX_FLAGS=${PKGCONFIG_CXX_FLAGS} PKG_CONFIG=${PKG_CONFIG_EXECUTABLE} | ||
| BUILD_TYPE=$<CONFIGURATION> |
| if(HPX_WITH_CXX_MODULES) | ||
| if(TARGET hpx_core_module_if) | ||
| if(TARGET hello_world_component) | ||
| target_link_libraries( | ||
| hello_world_component PRIVATE hpx_core_module_if | ||
| ) |
Summary
This PR standardizes the export of C++ module BMI files to external projects and officially re-enables the external build tests when
HPX_WITH_CXX_MODULES=ON.Fixes #7197
Closes #7202
Problem
Previously, external build tests were disabled (#7190) because HPX lacked the CMake infrastructure to correctly export and install the Binary Module Interface (BMI) generation paths downstream. Without these paths, any external project trying to
importHPX modules structurally failed.Root Cause
CMake 3.28 natively supports C++20 module dependency tracking via the
FILE_SET CXX_MODULESfeature, generating proper module interfaces. However, the custom macroshpx_configure_module_producerandhpx_configure_module_consumerwere overriding this by manually injecting-fmodule-output=and-fprebuilt-module-path=compiler flags. This hardcoded manipulation fundamentally conflicts with modern CMake's internal module tracking and installation processes, corrupting the exported target configuration (HPXTargets.cmake).What changed
Since
HPX_WITH_CXX_MODULESnow enforcesCMAKE_VERSION >= 3.29, we can entirely rely on native functionality:-fmodule-output=flags fromHPX_CXXModules.cmake.-fprebuilt-module-path=flags fromHPX_CXXModules.cmake(safely retainedfuse-ld=lldspecifically for Clang).return()check block fromtests/unit/build/CMakeLists.txtthat bypassed downstream tests.Why this fixes the issue
The native CMake target definitions now assume full control over BMI file sets, successfully resolving paths dynamically. When an external project consumes HPX via
find_package(HPX)through the CI pipeline, CMake inherently handles the BMI dependencies.