Skip to content
Open
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
2 changes: 2 additions & 0 deletions Sofa/framework/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ target_link_options(${PROJECT_NAME} PUBLIC "$<${is_c_cxx_release}:${SOFACONFIG_L
target_link_options(${PROJECT_NAME} PUBLIC "$<${is_c_cxx_debug}:${SOFACONFIG_LINK_OPTIONS_DEBUG}>")
target_link_options(${PROJECT_NAME} PUBLIC "$<${is_c_cxx}:${SOFACONFIG_LINK_OPTIONS}>")

sofa_enable_clang_tidy(${PROJECT_NAME})

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Sofa.Framework) # IDE folder

# Attach Sofa Version into properties
Expand Down
26 changes: 26 additions & 0 deletions Sofa/framework/Config/cmake/SofaMacrosConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,29 @@ macro(sofa_set_targets_release_only)
endmacro()



function(sofa_enable_clang_tidy TARGET_NAME)
cmake_parse_arguments(CT "" "CHECKS" "" ${ARGN})

if(NOT TARGET "${TARGET_NAME}")
message(FATAL_ERROR "enable_clang_tidy: '${TARGET_NAME}' is not a target")
endif()

find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if(NOT CLANG_TIDY_EXE)
message(STATUS "clang-tidy not found; skipping for target '${TARGET_NAME}. Install clang-tidy and add it to your PATH environment variable.'")
return()
endif()

set(cmd "${CLANG_TIDY_EXE}")
if(CT_CHECKS)
list(APPEND cmd "-checks=${CT_CHECKS}")
endif()

# Enable clang-tidy only for this target
set_target_properties("${TARGET_NAME}" PROPERTIES
C_CLANG_TIDY "${cmd}"
CXX_CLANG_TIDY "${cmd}"
)
endfunction()

1 change: 1 addition & 0 deletions Sofa/framework/Type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ if(mimalloc_FOUND)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Sofa.Framework) # IDE folder
sofa_enable_clang_tidy(${PROJECT_NAME})

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
Expand Down
Loading