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 1 commit intoTheHPXProject:masterfrom
Conversation
Up to standards ✅🟢 Issues
|
| 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
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)
|
@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
There was a problem hiding this comment.
Pull request overview
This PR updates HPX’s external-build test infrastructure and example consumer project to work again when HPX_WITH_CXX_MODULES=ON, aiming to standardize downstream module/BMI consumption and re-enable CI coverage for external builds.
Changes:
- Re-enabled
tests/unit/buildexternal build tests with C++ modules enabled, adding module-target build ordering where needed. - Updated the
hello_world_componentexternal example to enable module scanning and link to module interface targets when modules are enabled. - Adjusted cmake-format parsing config for
hpx_configure_module_producer.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit/build/CMakeLists.txt | Removes the modules early-exit and adds module-related dependencies/flags for external build and pkg-config tests. |
| examples/hello_world_component/CMakeLists.txt | Enables module scanning and links module interface targets in the external example when modules are enabled. |
| cmake/HPX_SetupTarget.cmake | Makes module-consumer configuration robust to both in-tree and HPXInternal:: imported target names. |
| .cmake-format.py | Updates cmake-format’s custom command parsing for hpx_configure_module_producer. |
yes sir I will raise the new pr for that changes |
|
@arpittkhandelwal thanks for refining this PR. Unfortunately, the original issue has not been solved yet. Any ideas what is missing? Does it work for you locally? |
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 dependency tracking (CMake 3.29+), ensuring BMIs are properly exported/installed for downstream consumers, and re-enables external build tests when HPX_WITH_CXX_MODULES=ON.
Changes:
- Simplifies module producer/consumer helpers to avoid manually injecting module output/prebuilt paths and instead rely on
FILE_SET CXX_MODULES+ scan propagation. - Re-enables and adjusts external build tests (including pkg-config-based build checks) for module-enabled builds.
- Updates downstream example setup to propagate module scanning through
hpx_setup_target, and refreshes cmake-format command metadata.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/unit/build/CMakeLists.txt |
Re-enables external build tests with modules and adjusts pkg-config test flags. |
libs/CMakeLists.txt |
Stops passing a custom module output directory to module producer helper. |
examples/hello_world_component/CMakeLists.txt |
Ensures module scanning is enabled at the right point and passed through hpx_setup_target. |
cmake/HPX_SetupTarget.cmake |
Improves robustness by supporting both build-tree and exported HPXInternal:: module interface targets. |
cmake/HPX_CXXModules.cmake |
Removes manual BMI path flagging and relies on CMake-native module scanning propagation. |
.cmake-format.py |
Updates formatter metadata for the changed module producer function signature. |
I tracked down the HPX.Core CI failures it was a mismatch between our manual module flags and CMake’s built-in module handling. We were forcing Clang to write BMIs to a different path than where CMake expected them, which broke imports. I’ve removed the manual -fmodule-output and -fprebuilt-module-path flags and switched fully to CMake’s native FILE_SET CXX_MODULES with INTERFACE_CXX_SCAN_FOR_MODULES ON. This should fix the path issues now let’s wait for CI |
9dccae0 to
e194bd0
Compare
a1cc7b7 to
b1e91ae
Compare
0f6b9d8 to
86e1a3d
Compare
86e1a3d to
203151f
Compare
203151f to
0da2cf7
Compare
- Resolved Linux configuration mismatches (GNU extensions) by propagating CMAKE_CXX_EXTENSIONS and HPX_CXX_STANDARD to external tests. - Fixed Windows installation crashes by removing CXX_MODULES_DIRECTORY from install(EXPORT) and adding MSVC guards for Clang linker flags. - Improved module metadata propagation by explicitly linking HPXInternal module targets in external examples. - Added CXX_STANDARD support to hpx_setup_target and applied it to hello_world_component. - Skipped pkg-config tests when modules are enabled due to lack of BMI discovery support. - Fixed CMake quoting and logic bugs in standard header collection. - Applied project-wide cmake-format and resolved CI linting failures.
0da2cf7 to
2977701
Compare
| # CXX_MODULES_DIRECTORY was added in CMake 3.28 | ||
| set(_cxx_modules_directory_arg) | ||
| if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.28") | ||
| set(_cxx_modules_directory_arg CXX_MODULES_DIRECTORY cxx-modules) | ||
| endif() |
There was a problem hiding this comment.
_cxx_modules_directory_arg is applied to the build-tree export() calls, but the corresponding install(EXPORT ...) blocks for HPXInternalTargets and HPXTargets do not pass CXX_MODULES_DIRECTORY. If install(EXPORT) is missing this argument, the installed package may not install/generate the per-target C++ module metadata directory, breaking downstream find_package(HPX) consumption of modules from an install tree. Consider forwarding the same ${_cxx_modules_directory_arg} (guarded by the same CMake version check) to both install(EXPORT ...) calls as well.
| # Capture standard library headers (with or without extensions, e.g. | ||
| # <vector>, <link.h>, <dlfcn.h>). |
There was a problem hiding this comment.
The comment mentions capturing headers like <link.h>/<dlfcn.h>, but those are not present in STANDARD_LIBRARY_HEADERS above. As written, they will never be captured by the IN_LIST STANDARD_LIBRARY_HEADERS check. Either add the intended headers to STANDARD_LIBRARY_HEADERS (if you want them treated as “standard” for this purpose), or adjust the comment to match the actual list being checked.
| # Capture standard library headers (with or without extensions, e.g. | |
| # <vector>, <link.h>, <dlfcn.h>). | |
| # Capture only headers explicitly listed in STANDARD_LIBRARY_HEADERS | |
| # (for example, <vector>). |
|
@hkaiser sir I found the root cause of the HPX.Core not found CI failures. We had a conflict between our manual compiler flags and CMake 3.28+'s native module tracking. CMake automatically generates BMIs to CMakeFiles/.dir/ via FILE_SET CXX_MODULES, but our manual -fmodule-output flags were forcing Clang to write to a completely different directory. This caused a path mismatch when consumers tried to import HPX.Core. Fix: I completely removed the manual -fmodule-output and -fprebuilt-module-path flags from HPX_CXXModules.cmake. We now rely 100% on CMake's native FILE_SET CXX_MODULES and INTERFACE_CXX_SCAN_FOR_MODULES ON to automatically map dependencies and paths for both internal and external builds. |
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.