Skip to content

Commit

Permalink
Moved cmake functions, variables to API 2.0 naming style (openvinotoo…
Browse files Browse the repository at this point in the history
…lkit#20281)

* Merge Linux CC + static build + clang compiler

* Improvements

* Removed ie prefixes from cmake scripts

* Fixes for NPU
  • Loading branch information
ilya-lavrenov authored Oct 9, 2023
1 parent cba4721 commit ead4b8a
Show file tree
Hide file tree
Showing 104 changed files with 509 additions and 468 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ jobs:
run: cmake -B build

- name: Shellcheck cmake target
run: cmake --build build --target ie_shellcheck -j8
run: cmake --build build --target ov_shellcheck -j8

# always provide suggestions even for skipped scripts in ie_shellcheck tagret
# always provide suggestions even for skipped scripts in ov_shellcheck tagret
- name: ShellCheck action
if: always()
uses: reviewdog/action-shellcheck@v1
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()

project(OpenVINO DESCRIPTION "OpenVINO toolkit")

find_package(IEDevScripts REQUIRED
find_package(OpenVINODeveloperScripts REQUIRED
PATHS "${OpenVINO_SOURCE_DIR}/cmake/developer_package"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
Expand Down Expand Up @@ -162,4 +162,4 @@ endif()
# provides a callback function to describe each component in repo
include(cmake/packaging/packaging.cmake)

ie_cpack(${IE_CPACK_COMPONENTS_ALL})
ov_cpack(${OV_CPACK_COMPONENTS_ALL})
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

cmake_minimum_required(VERSION 3.13)

if(NOT DEFINED IEDevScripts_DIR)
message(FATAL_ERROR "IEDevScripts_DIR is not defined")
if(NOT DEFINED OpenVINODeveloperScripts_DIR )
message(FATAL_ERROR "OpenVINODeveloperScripts_DIR is not defined")
endif()

set(IEDevScripts_DIR "${OpenVINODeveloperScripts_DIR}") # for BW compatibility

# disable FindPkgConfig.cmake for Android
if(ANDROID)
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
Expand All @@ -23,7 +25,7 @@ macro(ov_set_if_not_defined var value)
endmacro()

set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${IEDevScripts_DIR}")
set(CMAKE_MODULE_PATH "${OpenVINODeveloperScripts_DIR}")

function(set_ci_build_number)
set(repo_root "${CMAKE_SOURCE_DIR}")
Expand Down Expand Up @@ -67,7 +69,7 @@ endif()
# Prepare temporary folder
#

function(set_temp_directory temp_variable source_tree_dir)
function(ov_set_temp_directory temp_variable source_tree_dir)
if(DEFINED OV_TEMP)
message(STATUS "OV_TEMP cmake variable is set : ${OV_TEMP}")
file(TO_CMAKE_PATH ${OV_TEMP} temp)
Expand All @@ -84,6 +86,11 @@ function(set_temp_directory temp_variable source_tree_dir)
endif()
endfunction()

macro(set_temp_directory)
message(WARNING "'set_temp_directory' is deprecated. Please, use 'ov_set_temp_directory'")
ov_set_temp_directory(${ARGV})
endmacro()

#
# For cross-compilation
#
Expand Down Expand Up @@ -139,37 +146,41 @@ if(NOT DEFINED OUTPUT_ROOT)
endif()

# Enable postfixes for Debug/Release builds
set(IE_DEBUG_POSTFIX_WIN "d")
set(IE_RELEASE_POSTFIX_WIN "")
set(IE_DEBUG_POSTFIX_LIN "")
set(IE_RELEASE_POSTFIX_LIN "")
set(IE_DEBUG_POSTFIX_MAC "d")
set(IE_RELEASE_POSTFIX_MAC "")
set(OV_DEBUG_POSTFIX_WIN "d")
set(OV_RELEASE_POSTFIX_WIN "")
set(OV_DEBUG_POSTFIX_LIN "")
set(OV_RELEASE_POSTFIX_LIN "")
set(OV_DEBUG_POSTFIX_MAC "d")
set(OV_RELEASE_POSTFIX_MAC "")

if(WIN32)
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_WIN})
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_WIN})
set(OV_DEBUG_POSTFIX ${OV_DEBUG_POSTFIX_WIN})
set(OV_RELEASE_POSTFIX ${OV_RELEASE_POSTFIX_WIN})
elseif(APPLE)
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_MAC})
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_MAC})
set(OV_DEBUG_POSTFIX ${OV_DEBUG_POSTFIX_MAC})
set(OV_RELEASE_POSTFIX ${OV_RELEASE_POSTFIX_MAC})
else()
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_LIN})
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_LIN})
set(OV_DEBUG_POSTFIX ${OV_DEBUG_POSTFIX_LIN})
set(OV_RELEASE_POSTFIX ${OV_RELEASE_POSTFIX_LIN})
endif()

set(CMAKE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX})
set(CMAKE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX})
set(CMAKE_DEBUG_POSTFIX ${OV_DEBUG_POSTFIX})
set(CMAKE_RELEASE_POSTFIX ${OV_RELEASE_POSTFIX})

# Support CMake multi-configuration for Visual Studio / Ninja or Xcode build
if(OV_GENERATOR_MULTI_CONFIG)
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
set(OV_BUILD_POSTFIX $<$<CONFIG:Debug>:${OV_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${OV_RELEASE_POSTFIX}>)
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
set(OV_BUILD_POSTFIX ${OV_DEBUG_POSTFIX})
else()
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
set(OV_BUILD_POSTFIX ${OV_RELEASE_POSTFIX})
endif()
endif()
add_definitions(-DOV_BUILD_POSTFIX=\"${OV_BUILD_POSTFIX}\")

# for BW compatibility; removed before 2024.0
set(IE_BUILD_POSTFIX ${OV_BUILD_POSTFIX})
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")

ov_set_if_not_defined(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
Expand All @@ -178,11 +189,6 @@ ov_set_if_not_defined(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FO
ov_set_if_not_defined(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
ov_set_if_not_defined(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})

if(CPACK_GENERATOR MATCHES "^(DEB|RPM)$")
# to make sure that lib/<multiarch-triplet> is created on Debian
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Cmake install prefix" FORCE)
endif()

include(packaging/packaging)

if(APPLE)
Expand Down Expand Up @@ -261,7 +267,7 @@ include(api_validator/api_validator)
include(vs_version/vs_version)
include(plugins/plugins)
include(frontends/frontends)
include(add_ie_target)
include(add_target_helpers)
include(CMakePackageConfigHelpers)

if(ENABLE_FUZZING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ov_add_target(
link_dependencies
DEPENDENCIES
dependencies
ie::important_plugin
openvino::important_plugin
OBJECT_FILES
object libraries
DEFINES
Expand Down Expand Up @@ -90,8 +90,7 @@ function(ov_add_target)
source_group("include" FILES ${includes})
source_group("src" FILES ${sources})

set(all_sources)
list(APPEND all_sources ${sources} ${includes} ${ARG_OBJECT_FILES})
set(all_sources ${sources} ${includes} ${ARG_OBJECT_FILES})

# defining a target
if (ARG_TYPE STREQUAL EXECUTABLE)
Expand All @@ -102,7 +101,7 @@ function(ov_add_target)
message(SEND_ERROR "Invalid target type ${ARG_TYPE} specified for target name ${ARG_NAME}")
endif()

ieTargetLinkWholeArchive(${ARG_NAME} ${ARG_LINK_LIBRARIES_WHOLE_ARCHIVE})
ov_target_link_whole_archive(${ARG_NAME} ${ARG_LINK_LIBRARIES_WHOLE_ARCHIVE})

if (ARG_DEFINES)
target_compile_definitions(${ARG_NAME} PRIVATE ${ARG_DEFINES})
Expand Down Expand Up @@ -140,11 +139,6 @@ function(ov_add_target)
endif()
endfunction()

function(addIeTarget)
message(WARNING "'addIeTarget' is deprecated, please, use 'ov_add_target' instead")
ov_add_target(${ARGV})
endfunction()

#[[
Wrapper function over addIeTarget, that also adds a test with the same name.
You could use
Expand Down Expand Up @@ -195,6 +189,13 @@ function(ov_add_test_target)
EXCLUDE_FROM_ALL)
endfunction()

# deprecated

function(addIeTarget)
message(WARNING "'addIeTarget' is deprecated, please, use 'ov_add_target' instead")
ov_add_target(${ARGV})
endfunction()

function(addIeTargetTest)
message(WARNING "'addIeTargetTest' is deprecated, please, use 'ov_add_test_target' instead")
ov_add_test_target(${ARGV})
Expand Down
32 changes: 17 additions & 15 deletions cmake/developer_package/api_validator/api_validator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(WIN32)
endif()
endif()

function(_ie_add_api_validator_post_build_step_recursive)
function(_ov_add_api_validator_post_build_step_recursive)
cmake_parse_arguments(API_VALIDATOR "" "TARGET" "" ${ARGN})

get_target_property(LIBRARY_TYPE ${API_VALIDATOR_TARGET} TYPE)
Expand All @@ -55,9 +55,9 @@ function(_ie_add_api_validator_post_build_step_recursive)
continue()
endif()
if(TARGET "${orig_library}")
_ie_add_api_validator_post_build_step_recursive(TARGET ${orig_library})
_ov_add_api_validator_post_build_step_recursive(TARGET ${orig_library})
else()
_ie_add_api_validator_post_build_step_recursive(TARGET ${library})
_ov_add_api_validator_post_build_step_recursive(TARGET ${library})
endif()
endif()
endforeach()
Expand Down Expand Up @@ -113,10 +113,10 @@ function(_ov_add_api_validator_post_build_step)
endif()

# collect targets
_ie_add_api_validator_post_build_step_recursive(TARGET ${API_VALIDATOR_TARGET})
_ov_add_api_validator_post_build_step_recursive(TARGET ${API_VALIDATOR_TARGET})
if (API_VALIDATOR_EXTRA)
foreach(target IN LISTS API_VALIDATOR_EXTRA)
_ie_add_api_validator_post_build_step_recursive(TARGET ${target})
_ov_add_api_validator_post_build_step_recursive(TARGET ${target})
endforeach()
endif()

Expand Down Expand Up @@ -171,7 +171,7 @@ function(_ov_add_api_validator_post_build_step)
-D ONECORE_API_VALIDATOR_EXCLUSION=${ONECORE_API_VALIDATOR_EXCLUSION}
-D ONECORE_API_VALIDATOR_OUTPUT=${output_file}
-D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-P "${IEDevScripts_DIR}/api_validator/api_validator_run.cmake")
-P "${OpenVINODeveloperScripts_DIR}/api_validator/api_validator_run.cmake")
list(APPEND byproducts_files ${output_file})

unset(target_name)
Expand All @@ -191,13 +191,15 @@ function(_ov_add_api_validator_post_build_step)
endfunction()

#
# ie_add_api_validator_post_build_step(TARGET <name>)
# ov_add_api_validator_post_build_step(TARGET <name>)
#
macro(ov_add_api_validator_post_build_step)
_ov_add_api_validator_post_build_step(${ARGV})
endmacro()

macro(ie_add_api_validator_post_build_step)
message(WARNING "ie_add_api_validator_post_build_step is deprecated, use ov_add_api_validator_post_build_step instead")
_ov_add_api_validator_post_build_step(${ARGV})
endmacro()
function(ov_add_api_validator_post_build_step)
_ov_add_api_validator_post_build_step(${ARGN})
endfunction()

# deprecated

function(ie_add_api_validator_post_build_step)
message(WARNING "'ie_add_api_validator_post_build_step' is deprecated, use 'ov_add_api_validator_post_build_step' instead")
_ov_add_api_validator_post_build_step(${ARGN})
endfunction()
8 changes: 4 additions & 4 deletions cmake/developer_package/clang_format/clang_format.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ function(ov_add_clang_format_target TARGET_NAME)
-D "CLANG_FORMAT=${CLANG_FORMAT}"
-D "INPUT_FILE=${source_file}"
-D "OUTPUT_FILE=${output_file}"
-P "${IEDevScripts_DIR}/clang_format/clang_format_check.cmake"
-P "${OpenVINODeveloperScripts_DIR}/clang_format/clang_format_check.cmake"
DEPENDS
"${source_file}"
"${IEDevScripts_DIR}/clang_format/clang_format_check.cmake"
"${OpenVINODeveloperScripts_DIR}/clang_format/clang_format_check.cmake"
COMMENT
"[clang-format] ${source_file}"
VERBATIM)
Expand All @@ -110,10 +110,10 @@ function(ov_add_clang_format_target TARGET_NAME)
-D "CLANG_FORMAT=${CLANG_FORMAT}"
-D "INPUT_FILES=${all_input_sources}"
-D "EXCLUDE_PATTERNS=${CLANG_FORMAT_EXCLUDE_PATTERNS}"
-P "${IEDevScripts_DIR}/clang_format/clang_format_fix.cmake"
-P "${OpenVINODeveloperScripts_DIR}/clang_format/clang_format_fix.cmake"
DEPENDS
"${all_input_sources}"
"${IEDevScripts_DIR}/clang_format/clang_format_fix.cmake"
"${OpenVINODeveloperScripts_DIR}/clang_format/clang_format_fix.cmake"
COMMENT
"[clang-format] ${TARGET_NAME}_fix"
VERBATIM)
Expand Down
Loading

0 comments on commit ead4b8a

Please sign in to comment.