@@ -17,6 +17,17 @@ if(EXISTS "${HPX_DIR}")
1717
1818 if (HPX_WITH_CXX_MODULES)
1919 set (CMAKE_CXX_SCAN_FOR_MODULES ON )
20+
21+ # CMake only propagates imported C++ module metadata from targets that are
22+ # linked directly by the consumer. The exported HPXInternal module targets
23+ # are therefore linked explicitly for the external build tests.
24+ set (hpx_cxx_module_targets)
25+ if (TARGET HPXInternal::hpx_core_module)
26+ list (APPEND hpx_cxx_module_targets HPXInternal::hpx_core_module)
27+ endif ()
28+ if (TARGET HPXInternal::hpx_full_module)
29+ list (APPEND hpx_cxx_module_targets HPXInternal::hpx_full_module)
30+ endif ()
2031 endif ()
2132
2233 add_executable (hello_world_client hello_world_client.cpp )
@@ -26,11 +37,15 @@ if(EXISTS "${HPX_DIR}")
2637 if (HPX_WITH_DISTRIBUTED_RUNTIME)
2738 target_link_libraries (
2839 hello_world_component PUBLIC HPX::hpx HPX::iostreams_component
40+ ${hpx_cxx_module_targets}
2941 )
3042 target_link_libraries (hello_world_component PRIVATE HPX::component )
3143 target_link_libraries (hello_world_client PRIVATE hello_world_component )
3244 endif ()
33- target_link_libraries (hello_world_client PRIVATE HPX::hpx HPX::wrap_main )
45+ target_link_libraries (
46+ hello_world_client PRIVATE HPX::hpx HPX::wrap_main
47+ ${hpx_cxx_module_targets}
48+ )
3449
3550 # We still support not linking to HPX::wrap_main when
3651 # HPX_WITH_DYNAMIC_HPX_MAIN=OFF for legacy use. This can only be done using
@@ -44,6 +59,7 @@ if(EXISTS "${HPX_DIR}")
4459
4560 target_link_libraries (
4661 hello_world_client_only_hpx_init PRIVATE hello_world_component
62+ ${hpx_cxx_module_targets}
4763 )
4864 endif ()
4965 elseif ("${SETUP_TYPE} " STREQUAL "MACROS" )
0 commit comments