Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for missing inline on functions in public headers. #2570

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions cmake/CCCLGenerateHeaderTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ function(cccl_generate_header_tests target_name project_include_path)
add_library(${target_name} OBJECT ${header_srcs})
cccl_configure_target(${target_name} ${cccl_configure_target_options})

# Check that all functions in headers are either template functions or inline:
set(link_target ${target_name}.link_check)
add_executable(${link_target} "${CCCL_SOURCE_DIR}/cmake/link_check_main.cpp")
cccl_configure_target(${link_target} ${cccl_configure_target_options})
# Linking both ${target_name} and $<TARGET_OBJECTS:${target_name}> forces CMake to
# link the same objects twice. The compiler will complain about duplicate symbols if
# any functions are missing inline markup.
target_link_libraries(${link_target} PRIVATE
${target_name}
$<TARGET_OBJECTS:${target_name}>
)

endfunction()
4 changes: 4 additions & 0 deletions cmake/link_check_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main()
{
return 0;
}
Loading