Added NCC support for source files (#9630)

This commit is contained in:
Ilya Lavrenov 2022-01-14 07:50:30 +03:00 committed by GitHub
parent 1f241277f4
commit 5affdc3284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 21 deletions

View File

@ -165,7 +165,7 @@ macro(ov_add_frontend)
# frontend's CMakeLists.txt must define its own custom 'ov_ncc_naming_style' step # frontend's CMakeLists.txt must define its own custom 'ov_ncc_naming_style' step
else() else()
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include" SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
ADDITIONAL_INCLUDE_DIRECTORIES ADDITIONAL_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:frontend_common::static,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:frontend_common::static,INTERFACE_INCLUDE_DIRECTORIES>)
endif() endif()

View File

@ -75,12 +75,12 @@ endif()
# #
# ov_ncc_naming_style(FOR_TARGET target_name # ov_ncc_naming_style(FOR_TARGET target_name
# INCLUDE_DIRECTORY dir # SOURCE_DIRECTORY dir
# [ADDITIONAL_INCLUDE_DIRECTORIES dir1 dir2 ..] # [ADDITIONAL_INCLUDE_DIRECTORIES dir1 dir2 ..]
# [DEFINITIONS def1 def2 ..]) # [DEFINITIONS def1 def2 ..])
# #
# FOR_TARGET - name of the target # FOR_TARGET - name of the target
# INCLUDE_DIRECTORY - directory to check headers from # SOURCE_DIRECTORY - directory to check sources from
# ADDITIONAL_INCLUDE_DIRECTORIES - additional include directories used in checked headers # ADDITIONAL_INCLUDE_DIRECTORIES - additional include directories used in checked headers
# DEFINITIONS - additional definitions passed to preprocessor stage # DEFINITIONS - additional definitions passed to preprocessor stage
# #
@ -90,23 +90,24 @@ function(ov_ncc_naming_style)
endif() endif()
cmake_parse_arguments(NCC_STYLE "FAIL" cmake_parse_arguments(NCC_STYLE "FAIL"
"FOR_TARGET;INCLUDE_DIRECTORY" "ADDITIONAL_INCLUDE_DIRECTORIES;DEFINITIONS" ${ARGN}) "FOR_TARGET;SOURCE_DIRECTORY" "ADDITIONAL_INCLUDE_DIRECTORIES;DEFINITIONS" ${ARGN})
foreach(var FOR_TARGET INCLUDE_DIRECTORY) foreach(var FOR_TARGET SOURCE_DIRECTORY)
if(NOT DEFINED NCC_STYLE_${var}) if(NOT DEFINED NCC_STYLE_${var})
message(FATAL_ERROR "${var} is not defined in ov_ncc_naming_style function") message(FATAL_ERROR "${var} is not defined in ov_ncc_naming_style function")
endif() endif()
endforeach() endforeach()
file(GLOB_RECURSE headers file(GLOB_RECURSE sources
RELATIVE "${NCC_STYLE_INCLUDE_DIRECTORY}" RELATIVE "${NCC_STYLE_SOURCE_DIRECTORY}"
"${NCC_STYLE_INCLUDE_DIRECTORY}/*.hpp") "${NCC_STYLE_SOURCE_DIRECTORY}/*.hpp"
"${NCC_STYLE_SOURCE_DIRECTORY}/*.cpp")
list(APPEND NCC_STYLE_ADDITIONAL_INCLUDE_DIRECTORIES "${NCC_STYLE_INCLUDE_DIRECTORY}") list(APPEND NCC_STYLE_ADDITIONAL_INCLUDE_DIRECTORIES "${NCC_STYLE_SOURCE_DIRECTORY}")
foreach(header IN LISTS headers) foreach(source IN LISTS sources)
set(output_file "${ncc_style_bin_dir}/${header}.ncc_style") set(output_file "${ncc_style_bin_dir}/${source}.ncc_style")
set(full_header_path "${NCC_STYLE_INCLUDE_DIRECTORY}/${header}") set(full_source_path "${NCC_STYLE_SOURCE_DIRECTORY}/${source}")
add_custom_command( add_custom_command(
OUTPUT OUTPUT
@ -115,7 +116,7 @@ function(ov_ncc_naming_style)
"${CMAKE_COMMAND}" "${CMAKE_COMMAND}"
-D "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}" -D "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
-D "NCC_PY_SCRIPT=${ncc_script_py}" -D "NCC_PY_SCRIPT=${ncc_script_py}"
-D "INPUT_FILE=${full_header_path}" -D "INPUT_FILE=${full_source_path}"
-D "OUTPUT_FILE=${output_file}" -D "OUTPUT_FILE=${output_file}"
-D "DEFINITIONS=${NCC_STYLE_DEFINITIONS}" -D "DEFINITIONS=${NCC_STYLE_DEFINITIONS}"
-D "CLANG_LIB_PATH=${libclang_location}" -D "CLANG_LIB_PATH=${libclang_location}"
@ -124,12 +125,12 @@ function(ov_ncc_naming_style)
-D "EXPECTED_FAIL=${NCC_STYLE_FAIL}" -D "EXPECTED_FAIL=${NCC_STYLE_FAIL}"
-P "${ncc_style_dir}/ncc_run.cmake" -P "${ncc_style_dir}/ncc_run.cmake"
DEPENDS DEPENDS
"${full_header_path}" "${full_source_path}"
"${ncc_style_dir}/openvino.style" "${ncc_style_dir}/openvino.style"
"${ncc_script_py}" "${ncc_script_py}"
"${ncc_style_dir}/ncc_run.cmake" "${ncc_style_dir}/ncc_run.cmake"
COMMENT COMMENT
"[ncc naming style] ${header}" "[ncc naming style] ${source}"
VERBATIM) VERBATIM)
list(APPEND output_files ${output_file}) list(APPEND output_files ${output_file})
endforeach() endforeach()
@ -145,6 +146,6 @@ endfunction()
if(TARGET ncc_all) if(TARGET ncc_all)
ov_ncc_naming_style(FOR_TARGET ncc_all ov_ncc_naming_style(FOR_TARGET ncc_all
INCLUDE_DIRECTORY "${ncc_style_dir}/self_check" SOURCE_DIRECTORY "${ncc_style_dir}/self_check"
FAIL) FAIL)
endif() endif()

View File

@ -40,6 +40,6 @@ ov_install_static_lib(${TARGET_NAME} core)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
INCLUDE_DIRECTORY ${UTIL_INCLUDE_DIR}) SOURCE_DIRECTORY ${UTIL_INCLUDE_DIR})
openvino_developer_export_targets(COMPONENT core TARGETS ${TARGET_NAME}) openvino_developer_export_targets(COMPONENT core TARGETS ${TARGET_NAME})

View File

@ -66,7 +66,7 @@ target_link_libraries(ngraph_obj PRIVATE ngraph::builder ngraph::reference openv
ie_mark_target_as_cc(ngraph_obj) ie_mark_target_as_cc(ngraph_obj)
ov_ncc_naming_style(FOR_TARGET ngraph_obj ov_ncc_naming_style(FOR_TARGET ngraph_obj
INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include") SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_clang_format_target(ngraph_clang FOR_TARGETS ngraph_obj) add_clang_format_target(ngraph_clang FOR_TARGETS ngraph_obj)

View File

@ -49,7 +49,7 @@ set_property(SOURCE
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}_obj) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}_obj)
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj
INCLUDE_DIRECTORY "${FRONTEND_INCLUDE_DIR}" SOURCE_DIRECTORY "${FRONTEND_INCLUDE_DIR}"
ADDITIONAL_INCLUDE_DIRECTORIES ADDITIONAL_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>)

View File

@ -14,7 +14,7 @@ set(ONNX_OPSET_VERSION 15 CACHE INTERNAL "Supported version of ONNX operator set
target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION}) target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
INCLUDE_DIRECTORY "${${TARGET_NAME}_INCLUDE_DIR}" SOURCE_DIRECTORY "${${TARGET_NAME}_INCLUDE_DIR}"
DEFINITIONS DEFINITIONS
$<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS> $<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS>
ADDITIONAL_INCLUDE_DIRECTORIES ADDITIONAL_INCLUDE_DIRECTORIES

View File

@ -157,7 +157,7 @@ target_include_directories(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PUBLIC_H
add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${IE_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${IE_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS})
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj
INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/openvino" SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/openvino"
ADDITIONAL_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>) ADDITIONAL_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>)
# Static library used for unit tests which are always built # Static library used for unit tests which are always built