[CMAKE][NCC] Enable custom ncc style file and Improve ncc usage for windows. (#15031)
* add possibility to set custom ncc style file * add possibility to run NCC on Windows in case Clang is installed and available in PATH
This commit is contained in:
parent
34853c8ae9
commit
745ef24e19
@ -56,7 +56,13 @@ endif()
|
||||
# Since we were able to find_package(Clang) in a separate process
|
||||
# let's try to find in current process
|
||||
if(ENABLE_NCC_STYLE)
|
||||
if(APPLE)
|
||||
if(WIN32)
|
||||
set(CLANG_LIB_NAME libclang.dll)
|
||||
find_host_program(CLANG NAMES ${CLANG_LIB_NAME} PATHS ENV PATH)
|
||||
if(CLANG)
|
||||
set(libclang_location ${CLANG})
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
find_host_library(libclang_location NAMES clang
|
||||
PATHS /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
|
||||
DOC "Path to clang library")
|
||||
@ -107,11 +113,13 @@ endif()
|
||||
#
|
||||
# ov_ncc_naming_style(FOR_TARGET target_name
|
||||
# SOURCE_DIRECTORY dir
|
||||
# [STYLE_FILE style_file.style]
|
||||
# [ADDITIONAL_INCLUDE_DIRECTORIES dir1 dir2 ..]
|
||||
# [DEFINITIONS def1 def2 ..])
|
||||
#
|
||||
# FOR_TARGET - name of the target
|
||||
# SOURCE_DIRECTORY - directory to check sources from
|
||||
# STYLE_FILE - path to the specific style file
|
||||
# ADDITIONAL_INCLUDE_DIRECTORIES - additional include directories used in checked headers
|
||||
# DEFINITIONS - additional definitions passed to preprocessor stage
|
||||
#
|
||||
@ -121,7 +129,7 @@ function(ov_ncc_naming_style)
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(NCC_STYLE "FAIL"
|
||||
"FOR_TARGET;SOURCE_DIRECTORY" "ADDITIONAL_INCLUDE_DIRECTORIES;DEFINITIONS" ${ARGN})
|
||||
"FOR_TARGET;SOURCE_DIRECTORY;STYLE_FILE" "ADDITIONAL_INCLUDE_DIRECTORIES;DEFINITIONS" ${ARGN})
|
||||
|
||||
foreach(var FOR_TARGET SOURCE_DIRECTORY)
|
||||
if(NOT DEFINED NCC_STYLE_${var})
|
||||
@ -129,6 +137,10 @@ function(ov_ncc_naming_style)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT DEFINED NCC_STYLE_STYLE_FILE)
|
||||
set(NCC_STYLE_STYLE_FILE ${ncc_style_dir}/openvino.style)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
RELATIVE "${NCC_STYLE_SOURCE_DIRECTORY}"
|
||||
"${NCC_STYLE_SOURCE_DIRECTORY}/*.hpp"
|
||||
@ -153,7 +165,7 @@ function(ov_ncc_naming_style)
|
||||
-D "OUTPUT_FILE=${output_file}"
|
||||
-D "DEFINITIONS=${NCC_STYLE_DEFINITIONS}"
|
||||
-D "CLANG_LIB_PATH=${libclang_location}"
|
||||
-D "STYLE_FILE=${ncc_style_dir}/openvino.style"
|
||||
-D "STYLE_FILE=${NCC_STYLE_STYLE_FILE}"
|
||||
-D "ADDITIONAL_INCLUDE_DIRECTORIES=${NCC_STYLE_ADDITIONAL_INCLUDE_DIRECTORIES}"
|
||||
-D "EXPECTED_FAIL=${NCC_STYLE_FAIL}"
|
||||
-P "${ncc_style_dir}/ncc_run.cmake"
|
||||
|
Loading…
Reference in New Issue
Block a user