Cross-compilation of debian packages (#12919)

* Debian arm cross-compilation

* Pugixml::shared as system library

* Removed debug print of openvino.pc

* Set debian package arch for cross-compilation manually
This commit is contained in:
Ilya Lavrenov 2022-09-06 13:03:40 +04:00 committed by GitHub
parent ab1da94f1d
commit 10f2cf40eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 8 deletions

View File

@ -7,6 +7,7 @@ set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_STRIP arm-linux-gnueabihf-strip)
set(PKG_CONFIG_EXECUTABLE arm-linux-gnueabihf-pkg-config CACHE PATH "Path to ARM pkg-config")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

View File

@ -7,6 +7,7 @@ set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_STRIP aarch64-linux-gnu-strip)
set(PKG_CONFIG_EXECUTABLE aarch64-linux-gnu-pkg-config CACHE PATH "Path to ARM64 pkg-config")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

View File

@ -169,7 +169,7 @@ 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(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CPACK_GENERATOR STREQUAL "DEB")
if(CPACK_GENERATOR STREQUAL "DEB")
# to make sure that lib/<multiarch-tuple> is created on Debian
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Cmake install prefix" FORCE)
endif()

View File

@ -108,6 +108,18 @@ macro(ov_debian_specific_settings)
# set(CPACK_DEBIAN_PACKAGE_RELEASE "1")
# enable this if someday we change the version scheme
# set(CPACK_DEBIAN_PACKAGE_EPOCH "2")
# temporary WA for debian package architecture for cross-compilation
# proper solution: to force cmake auto-detect this
if(CMAKE_CROSSCOMPILING)
if(AARCH64)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64)
elseif(ARM)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)
elseif(x86)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
endif()
endif()
endmacro()
ov_debian_specific_settings()

View File

@ -50,6 +50,7 @@ if [ -f /etc/lsb-release ]; then
shellcheck \
patchelf \
lintian \
file \
gzip \
`# openvino` \
libtbb-dev \

View File

@ -239,7 +239,7 @@ if(LINUX)
endif()
# detect <multiarch-triplet>
if(CPACK_GENERATOR STREQUAL "DEB" AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(CPACK_GENERATOR STREQUAL "DEB")
# TODO: find a better way to detect <multiarch-triplet>
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# note: clang provides different output like 'x86_64-pc-linux-gnu', so it's not used
@ -272,7 +272,6 @@ if(LINUX)
add_custom_command(TARGET openvino PRE_BUILD
COMMAND "${PKG_CONFIG_EXECUTABLE}" --validate "${pkgconfig_out}"
COMMAND cat "${pkgconfig_out}"
COMMENT "[pkg-config] validating openvino.pc"
VERBATIM)
endif()

View File

@ -24,8 +24,6 @@ endif()
# Create object library
file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
${LIBRARY_SRC}
${PUBLIC_HEADERS})
@ -49,7 +47,6 @@ add_cpplint_target(${TARGET_NAME}_obj_cpplint FOR_TARGETS ${TARGET_NAME}_obj)
# Create static library
add_library(${TARGET_NAME} STATIC EXCLUDE_FROM_ALL
${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
$<TARGET_OBJECTS:${TARGET_NAME}_obj>)
target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime

View File

@ -50,7 +50,10 @@ if(ENABLE_SYSTEM_PUGIXML)
# try system pugixml first
find_package(PugiXML QUIET)
if(PugiXML_FOUND)
if(TARGET pugixml::static)
if(TARGET pugixml::shared)
# example: cross-compilation on debian
set(pugixml_target pugixml::shared)
elseif(TARGET pugixml::static)
# sometimes pugixml::static target already exists, just need to make it global
# example: building using conda environment
set(pugixml_target pugixml::static)
@ -243,7 +246,11 @@ else()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/json/nlohmann_json
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES}
REGEX .*json/nlohmann_json/test/.* EXCLUDE)
REGEX .*json/nlohmann_json/.github/.* EXCLUDE
REGEX .*json/nlohmann_json/benchmarks/.* EXCLUDE
REGEX .*json/nlohmann_json/doc/.* EXCLUDE
REGEX .*json/nlohmann_json/test/.* EXCLUDE
REGEX .*json/nlohmann_json/cpplint/.* EXCLUDE)
endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cnpy