Skip to content

Commit 14e46a8

Browse files
Make the clangd helper target optional and tolerate a missing source
include/._clangd_helper_file.cpp only exists for clangd, but it was compiled on every top-level configure, and a tree that went through tar on macOS can lose the file because the "._" prefix reads as AppleDouble metadata. Add STDEXEC_BUILD_CLANGD_HELPER (default ON) and skip the target with a status message when the file is missing. Closes #2345. Signed-off-by: Max Freedom Pollard <[email protected]>
1 parent dfc8c95 commit 14e46a8

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,30 @@ endif()
655655
if(STDEXEC_IS_TOP_LEVEL)
656656
# Integrate with LLVM/clang tooling
657657
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/clangd_compile_info.cmake)
658-
add_executable(_clangd_helper_file include/._clangd_helper_file.cpp)
659-
target_link_libraries(
660-
_clangd_helper_file
661-
PRIVATE STDEXEC::stdexec
662-
$<TARGET_NAME_IF_EXISTS:STDEXEC::asioexec>
663-
$<TARGET_NAME_IF_EXISTS:STDEXEC::tbbexec>
664-
$<TARGET_NAME_IF_EXISTS:STDEXEC::taskflowexec>
665-
$<TARGET_NAME_IF_EXISTS:STDEXEC::nvexec>)
658+
659+
# The helper translation unit only exists to give clangd a compile command
660+
# for the headers (see the comment at the top of the file). It is not needed
661+
# when stdexec is configured for packaging, and a source tree that went
662+
# through an archive step may not even have it: the leading "._" looks like
663+
# AppleDouble metadata, which macOS tar and friends can strip.
664+
option(STDEXEC_BUILD_CLANGD_HELPER
665+
"Build the helper translation unit that gives clangd compile commands"
666+
ON)
667+
set(stdexec_clangd_helper_file
668+
"${CMAKE_CURRENT_SOURCE_DIR}/include/._clangd_helper_file.cpp")
669+
if(STDEXEC_BUILD_CLANGD_HELPER AND EXISTS "${stdexec_clangd_helper_file}")
670+
add_executable(_clangd_helper_file "${stdexec_clangd_helper_file}")
671+
target_link_libraries(
672+
_clangd_helper_file
673+
PRIVATE STDEXEC::stdexec
674+
$<TARGET_NAME_IF_EXISTS:STDEXEC::asioexec>
675+
$<TARGET_NAME_IF_EXISTS:STDEXEC::tbbexec>
676+
$<TARGET_NAME_IF_EXISTS:STDEXEC::taskflowexec>
677+
$<TARGET_NAME_IF_EXISTS:STDEXEC::nvexec>)
678+
elseif(STDEXEC_BUILD_CLANGD_HELPER)
679+
message(STATUS "stdexec: ${stdexec_clangd_helper_file} is missing, "
680+
"skipping the clangd helper target")
681+
endif()
666682
endif()
667683

668684
# ##############################################################################

0 commit comments

Comments
 (0)