Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
797854d
Re-enable external build tests with C++ modules
LSUDOKO Apr 19, 2026
cdff10b
build: fix C++ modules BMI export and re-enable external build tests
LSUDOKO Apr 25, 2026
a7c5c53
chore: resolve modify/delete conflict by removing deleted file
LSUDOKO Apr 25, 2026
af1fe47
style: apply clang-format to modified files
LSUDOKO Apr 25, 2026
6ec642a
style: apply clang-format to all library, example, and test files
LSUDOKO Apr 25, 2026
e286bfd
fix: restore extern C++ and fix POSIX header collection for modules
LSUDOKO Apr 25, 2026
45d182a
fix:disable pkg-config test for modules and cleanup header whitespace…
LSUDOKO Apr 25, 2026
a5cd735
apply CI-requested formatting for clang-format and cmake-format
LSUDOKO Apr 25, 2026
03ae3b5
trigger ci: verify all builds pass with restored extern C++ and macro…
LSUDOKO Apr 25, 2026
f879162
fix: restore standard build stability by fixing macro definitions and…
LSUDOKO Apr 25, 2026
13c5e03
fix: restore standard build stability by fixing macro definitions and…
LSUDOKO Apr 27, 2026
8b3984b
build: fix C++ modules BMI export and re-enable external build tests
LSUDOKO Apr 27, 2026
489d884
build: fix C++ modules BMI export and re-enable external build tests
LSUDOKO Apr 27, 2026
fd1e4eb
fix: correctly register pseudo-targets for build tests
LSUDOKO Apr 27, 2026
62a85b6
fix: correctly restore build tests and fix cmake formatting
LSUDOKO Apr 27, 2026
2f9325d
fix: unconditionally include POSIX headers for modules on Linux
LSUDOKO Apr 27, 2026
ccbec5a
Fix external C++ modules package consumers
LSUDOKO Apr 29, 2026
d5609b6
build: fix C++ modules BMI export and re-enable external build tests
LSUDOKO Apr 29, 2026
fb671ac
build: fix external C++ modules package tests
LSUDOKO Apr 29, 2026
3fdd927
build: fix wrapper module generation in CI
LSUDOKO Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions cmake/HPX_CXXModules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ endif()
# hpx_configure_module_producer(<producer> [MODULE_OUT_DIR <dir>])
#
# * Ensures a stable module output dir for producer target
# * Adds compiler flags to write module cache there (Clang/GCC)
# * Creates an interface target '<producer>_if' for consumers to link to
function(hpx_configure_module_producer producer)
if(NOT TARGET ${producer})
Expand Down Expand Up @@ -103,35 +102,6 @@ function(hpx_configure_module_producer producer)

# Make sure consumers scan for the BMI
set_target_properties(${_iface} PROPERTIES INTERFACE_CXX_SCAN_FOR_MODULES On)

if(MSVC)
# MSVC: CMake/MSVC handle IFCs automatically; create a target for
# convenience, consumers can link to this to get ordering and include info
return()
endif()

# Compiler-specific flags to instruct where to write module cache
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES
"AppleClang"
)
# Clang common flags
target_compile_options(${producer} PRIVATE "-fmodule-output=${_moddir}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC: modern flags
hpx_add_target_compile_option_if_available(
${producer} PRIVATE "-fmodule-output=${_moddir}" RESULT ok
)
if(NOT ok)
hpx_error(
"hpx_configure_module_producer: the used version of gcc does not support '-fmodule-output'"
)
endif()
else()
hpx_warn(
"hpx_configure_module_producer: unknown compiler '${CMAKE_CXX_COMPILER_ID}'; "
"exposing EXPORT_MODULE_DIR='${_moddir}' for manual handling"
)
endif()
endfunction()

# hpx_configure_module_consumer(<consumer> <producer>])
Expand Down Expand Up @@ -159,28 +129,11 @@ function(hpx_configure_module_consumer consumer producer)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID
MATCHES "AppleClang"
)
target_compile_options(
${consumer} PRIVATE "-fprebuilt-module-path=${_module_dir}"
)
get_target_property(_type ${consumer} TYPE)
if((_type STREQUAL "SHARED_LIBRARY") OR (_type STREQUAL "EXECUTABLE"))
target_link_options(${consumer} PRIVATE "-fuse-ld=lld")
target_link_options(${consumer} PRIVATE "-Wl,--error-limit=0")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
hpx_add_target_compile_option_if_available(
${consumer} PRIVATE "-fprebuilt-module-path=${_module_dir}" RESULT ok
)
if(NOT ok)
hpx_error(
"hpx_configure_module_consumer: the used version of gcc does not "
"support '-fprebuilt-module-path='"
)
endif()
else()
hpx_warn(
"hpx_configure_module_consumer: unknown compiler '${CMAKE_CXX_COMPILER_ID}'"
)
endif()
endif()
endfunction()
5 changes: 4 additions & 1 deletion cmake/HPX_CollectStdHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ function(hpx_extract_includes_from_file module)
if(NOT filename MATCHES "\\.|/")
# Check if the include is a standard library header
if(${filename} IN_LIST STANDARD_LIBRARY_HEADERS)
list(APPEND found_includes ${filename})
list(APPEND found_includes "${filename}")
endif()
elseif(filename STREQUAL "link.h" OR filename STREQUAL "dlfcn.h")
# Also collect these POSIX headers as they must be in the Global Module Fragment
list(APPEND found_includes "<${filename}>")
Comment thread
LSUDOKO marked this conversation as resolved.
Outdated
endif()
endforeach()

Expand Down
5 changes: 3 additions & 2 deletions examples/transpose/transpose_smp_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::vector<hpx::shared_future<void>> transpose_futures;
transpose_futures.resize(num_blocks);

for_each(par, range, [&](std::uint64_t b) {
for (std::uint64_t b = 0; b < num_blocks; ++b)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is unrelated. Please separate into new PR, if appropriate.

{
transpose_futures[b] =
for_each(par(task), range, [&, b](std::uint64_t phase) {
std::uint64_t const block_size = block_order * block_order;
Expand All @@ -108,7 +109,7 @@ int hpx_main(hpx::program_options::variables_map& vm)
transpose(&A[from_block][A_offset], &B[b][B_offset],
block_order, tile_size);
}).share();
});
}

hpx::wait_all(transpose_futures);

Expand Down
251 changes: 44 additions & 207 deletions tests/unit/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

# If build of external build tests is disabled, exit now
# if the external build tests is disabled, exit now
if(NOT HPX_WITH_TESTS_EXTERNAL_BUILD)
return()
endif()

# If C++ modules are enabled, exit now (we don't know yet how to setup a
# dependent HPX project to use the generated BMIs).
if(HPX_WITH_CXX_MODULES)
return()
endif()

# Try building an external cmake based project ...
function(
create_cmake_test
Expand All @@ -24,231 +18,74 @@ function(
hpx_dir
setup_type
build_type
test_dir
)
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${name}")
set(ADDITIONAL_CMAKE_OPTIONS -DUSING_INSTALL_DIR=${using_install_dir})
set(ADDITIONAL_CMAKE_OPTIONS -DSETUP_TYPE=${setup_type})
if(CMAKE_TOOLCHAIN_FILE)
set(ADDITIONAL_CMAKE_OPTIONS ${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)
endif()
if(CMAKE_MAKE_COMMAND)
set(ADDITIONAL_CMAKE_OPTIONS ${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_MAKE_COMMAND=${CMAKE_MAKE_COMMAND}
)
endif()
if(CMAKE_SYSROOT)
set(ADDITIONAL_CMAKE_OPTIONS ${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_SYSROOT=${CMAKE_SYSROOT}
)
endif()
if(NOT MSVC)
set(ADDITIONAL_CMAKE_OPTIONS ${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
set(ADDITIONAL_CMAKE_OPTIONS ${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
else()
set(ADDITIONAL_CMAKE_OPTIONS
${ADDITIONAL_CMAKE_OPTIONS}
-DHPX_OUTPUT_DIRECTORY=${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin
)
endif()
set(test_dir "${PROJECT_SOURCE_DIR}/${test_dir}")
if(HPX_WITH_CLANG_CUDA)
set(cmake_cuda_compiler -DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER})
endif()
set(test_name "tests.unit.build.${name}")

set(target_dir "${HPX_SOURCE_DIR}/examples/hello_world_component")
set(source_dir "${PROJECT_BINARY_DIR}/tests/unit/build/${name}")

file(MAKE_DIRECTORY "${source_dir}")

# Check if we should use C++ modules
set(modules_option "")
if(HPX_WITH_CXX_MODULES)
set(ADDITIONAL_CMAKE_OPTIONS
${ADDITIONAL_CMAKE_OPTIONS} -DHPX_WITH_CXX_MODULES=ON
-DHPX_CMAKE_LOGLEVEL=Debug
)
set(modules_option "-DHPX_WITH_CXX_MODULES=ON")
endif()
add_custom_target(
${name}

add_test(
NAME "${test_name}.configure"
COMMAND
"${CMAKE_CTEST_COMMAND}" --build-and-test "${test_dir}" "${build_dir}"
--build-generator "${CMAKE_GENERATOR}" --build-noclean --build-options
-DHPX_DIR=${hpx_dir} -DBOOST_ROOT=${BOOST_ROOT}
${ADDITIONAL_CMAKE_OPTIONS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS_SAFE}
-DCMAKE_BUILD_TYPE=${build_type} ${cmake_cuda_compiler} --test-command
"${CMAKE_CTEST_COMMAND}" --output-on-failure --verbose
VERBATIM
"${CMAKE_COMMAND}" "-H${target_dir}" "-B${source_dir}"
"-DHPX_DIR=${hpx_dir}" "-DCMAKE_BUILD_TYPE=${build_type}"
"-DHPX_WITH_MALLOC=${HPX_WITH_MALLOC}" "-G${CMAKE_GENERATOR}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}"
"-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_STANDARD_EXTENSIONS}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DSETUP_TYPE=${setup_type}"
"${modules_option}"
)
add_dependencies(${name} hpx hpx_init hpx_wrap)
if(HPX_WITH_DISTRIBUTED_RUNTIME)
add_dependencies(${name} iostreams_component)
endif()

if(MSVC)
set_target_properties(${name} PROPERTIES FOLDER "Tests/Unit/Build")
endif()
endfunction()

function(create_pkgconfig_test name hpx_dir)
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${name}")
add_custom_target(
${name}.make_build_dir
COMMAND "${CMAKE_COMMAND}" -E make_directory "${build_dir}"
VERBATIM
add_test(
NAME "${test_name}.build"
COMMAND "${CMAKE_COMMAND}" --build "${source_dir}" --config "${build_type}"
)
add_custom_target(
${name}.make_compile
COMMAND
"${CMAKE_COMMAND}" -E chdir "${build_dir}" make -f
"${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}
BUILD_TYPE=$<CONFIGURATION>
VERBATIM

set_tests_properties(
"${test_name}.build" PROPERTIES DEPENDS "${test_name}.configure"
)
add_dependencies(${name}.make_compile ${name}.make_build_dir hpx hpx_init)
if(HPX_WITH_DISTRIBUTED_RUNTIME)
add_dependencies(${name}.make_compile iostreams_component)
endif()

add_hpx_pseudo_target(${name})
add_hpx_pseudo_dependencies(${name} ${name}.make_compile)
add_hpx_pseudo_dependencies(tests.unit.build "${test_name}.build")
endfunction()

if(MSVC)
set(build_types ${CMAKE_BUILD_TYPE})
else()
set(build_types Debug Release RelWithDebInfo)
# lld (which HIP uses) does not support the -Os flags in older versions. We do
# not attempt to detect the linker in the general case, but disable the
# MinSizeRel test here since we know that HIP only uses lld.
if(NOT HPX_WITH_HIP OR (HIP_VERSION VERSION_GREATER_EQUAL "4.0.0"))
list(APPEND build_types MinSizeRel)
endif()
endif()

set(build_types "Debug")
if(NOT MSVC)
foreach(build_type ${build_types})
string(TOLOWER "${build_type}" build_type_lc)

create_cmake_test(
cmake_${build_type_lc}_build_dir_targets_test FALSE
"${PROJECT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}" TARGETS
${build_type} "examples/hello_world_component"
)

create_cmake_test(
cmake_${build_type_lc}_build_dir_macros_test FALSE
"${PROJECT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}" MACROS
${build_type} "examples/hello_world_component"
)

create_cmake_test(
cmake_${build_type_lc}_install_dir_targets_test TRUE
"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${HPX_PACKAGE_NAME}" TARGETS
${build_type} "examples/hello_world_component"
)

create_cmake_test(
cmake_${build_type_lc}_install_dir_macros_test TRUE
"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${HPX_PACKAGE_NAME}" MACROS
${build_type} "examples/hello_world_component"
)

if(HPX_WITH_DYNAMIC_HPX_MAIN)
# Google test emulation
create_cmake_test(
cmake_${build_type_lc}_build_dir_gtest_emulation_test FALSE
"${PROJECT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}" TARGETS
${build_type} "examples/gtest_emulation"
)

create_cmake_test(
cmake_${build_type_lc}_install_dir_gtest_emulation_test TRUE
"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${HPX_PACKAGE_NAME}" TARGETS
${build_type} "examples/gtest_emulation"
)
endif()
endforeach()
set(build_types ${build_types} "Release")
endif()

set(cmake_tests build_dir_targets install_dir_targets build_dir_macros
install_dir_macros
)
if(HPX_WITH_DYNAMIC_HPX_MAIN)
list(APPEND cmake_tests build_dir_gtest_emulation install_dir_gtest_emulation)
endif()

add_hpx_pseudo_target(tests.unit.build.cmake)
foreach(build_type ${build_types})
string(TOLOWER "${build_type}" build_type_lc)
add_hpx_pseudo_target(tests.unit.build.cmake.${build_type_lc})
foreach(test ${cmake_tests})
add_hpx_pseudo_target(tests.unit.build.cmake.${build_type_lc}.${test})
add_hpx_pseudo_dependencies(
tests.unit.build.cmake.${build_type_lc}.${test}
cmake_${build_type_lc}_${test}_test
)
add_hpx_pseudo_dependencies(
tests.unit.build.cmake.${build_type_lc}
tests.unit.build.cmake.${build_type_lc}.${test}
)
endforeach()

create_cmake_test(
"cmake_dir_${build_type_lc}_test" FALSE
"${PROJECT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}" "DIR" "${build_type}"
)

add_hpx_pseudo_dependencies(
tests.unit.build.cmake tests.unit.build.cmake.${build_type_lc}
tests.unit.build tests.unit.build.cmake_dir_${build_type_lc}_test
)
endforeach()
add_hpx_pseudo_dependencies(tests.unit.build tests.unit.build.cmake)

if(HPX_WITH_PKGCONFIG AND HPX_WITH_DISTRIBUTED_RUNTIME)
if(HPX_WITH_PKGCONFIG
AND HPX_WITH_DISTRIBUTED_RUNTIME
AND NOT HPX_WITH_CXX_MODULES
)
find_package(PkgConfig)
if(PKGCONFIG_FOUND)
create_pkgconfig_test(
pkgconfig_build_dir_test "${PROJECT_BINARY_DIR}/lib/pkgconfig"
)
create_pkgconfig_test(
pkgconfig_install_dir_test "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig"
)

set(pkgconfig_tests build_dir install_dir)
add_hpx_pseudo_target(tests.unit.build.pkgconfig)
foreach(test ${pkgconfig_tests})
add_hpx_pseudo_target(tests.unit.build.pkgconfig.${test})
add_hpx_pseudo_dependencies(
tests.unit.build.pkgconfig.${test} pkgconfig_${test}_test
)
add_hpx_pseudo_dependencies(
tests.unit.build.pkgconfig tests.unit.build.pkgconfig.${test}
)
endforeach()
add_hpx_pseudo_dependencies(tests.unit.build tests.unit.build.pkgconfig)
endif()
endif()

function(create_pkgconfig_generation_test name test_dir)
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${name}")
add_custom_target(
${name}
COMMAND
"${CMAKE_CTEST_COMMAND}" --build-and-test
"${PROJECT_SOURCE_DIR}/${test_dir}" "${build_dir}" --build-generator
"${CMAKE_GENERATOR}" --build-noclean --build-options
-DHPX_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DCMAKE_BUILD_TYPE=$<CONFIGURATION>
--test-command "${CMAKE_CTEST_COMMAND}" --output-on-failure
VERBATIM
)

if(MSVC)
set_target_properties(${name} PROPERTIES FOLDER "Tests/Unit/Build")
endif()
endfunction()

if(HPX_WITH_PKGCONFIG)
create_pkgconfig_generation_test(
tests.unit.build.pkgconfig_generation
"tests/unit/build/pkgconfig_generation"
)
add_hpx_pseudo_dependencies(
tests.unit.build tests.unit.build.pkgconfig_generation
)
endif()
Loading