Add custom vcpkg ports (#23456)

### Description
Add custom vcpkg ports for the following packages:
1. cpuinfo
2. onnx 
3. pthreadpool  
4. xnnpack

Because:

- The cpuinfo/pthreadpool/xnnpack packages in the official vcpkg repo
are too old.
   - XNNPack's version is updated from 2022-12-22 to 2025-01-17
   - CPUINFO's version is updated from 2022-07-19 to 2024-12-09
- Pthreadpool's version is updated from 2020-04-10 to 2024-12-17, and
the source code location is changed from
https://github.com/Maratyszcza/pthreadpool to
https://github.com/google/pthreadpool
- The onnx package in the official repo requires building python from
source, which then requires a lot of additional dependencies to be
installed. This PR removes them.
- Added a disable_gcc_warning.patch file for xnnpack for addressing the
issue reported in https://github.com/google/XNNPACK/issues/7650. I will
remove this patch when the issue is fully addressed.
- Added " -DONNX_DISABLE_STATIC_REGISTRATION=ON" to ONNX's config
options.
-
This commit is contained in:
Changming Sun 2025-01-22 11:49:16 -08:00 committed by GitHub
parent 3dcc90119b
commit 77adf4b040
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 552 additions and 0 deletions

View file

@ -0,0 +1,63 @@
# On Windows, we can get a cpuinfo.dll, but it exports no symbols.
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pytorch/cpuinfo
REF 8a1772a0c5c447df2d18edf33ec4603a8c9c04a6
SHA512 b94ccbfa886221d6bb16513d074675af0a72928a9dd9485dcacdc1124a8a60aacbbe91913a1579e766dfb024f0be1d52eeead40342004ff0238a8b94a095ed08
HEAD_REF master
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools CPUINFO_BUILD_TOOLS
)
set(LINK_OPTIONS "")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_LIBRARY_TYPE=static)
endif()
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=shared)
else()
list(APPEND LINK_OPTIONS -DCPUINFO_RUNTIME_TYPE=static)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
${LINK_OPTIONS}
-DCPUINFO_BUILD_UNIT_TESTS=OFF
-DCPUINFO_BUILD_MOCK_TESTS=OFF
-DCPUINFO_BUILD_BENCHMARKS=OFF
OPTIONS_DEBUG
-DCPUINFO_LOG_LEVEL=debug
OPTIONS_RELEASE
-DCPUINFO_LOG_LEVEL=default
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig() # pkg_check_modules(libcpuinfo)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if("tools" IN_LIST FEATURES)
set(additional_tools "")
if(EXISTS "${CURRENT_PACKAGES_DIR}/bin/cpuid-dump${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
list(APPEND additional_tools "cpuid-dump")
endif()
vcpkg_copy_tools(
TOOL_NAMES cache-info cpu-info isa-info ${additional_tools}
AUTO_CLEAN
)
endif()
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View file

@ -0,0 +1,25 @@
{
"name": "cpuinfo",
"version-date": "2024-12-09",
"port-version": 3,
"description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)",
"homepage": "https://github.com/pytorch/cpuinfo",
"license": "BSD-2-Clause",
"supports": "!(uwp & arm32)",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"tools": {
"description": "Build cpuinfo command-line tools",
"supports": "!uwp"
}
}
}

View file

@ -0,0 +1,67 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dd56b6..2ff3e29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,27 @@ endif()
include(GNUInstallDirs)
+# install protobuf files
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-data.proto
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-data.proto3
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-ml.proto
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-ml.proto3
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto3
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx
+)
+# install python files
+if(BUILD_ONNX_PYTHON)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_ml_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_ml_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_pb.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_pb.py
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx
+ )
+endif()
+
set(ONNX_ROOT ${PROJECT_SOURCE_DIR})
# Read ONNX version
@@ -116,7 +137,8 @@ endif()
# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11
# find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
-find_package(PythonInterp ${PY_VERSION} REQUIRED)
+find_package(Python3 ${PY_VERSION} COMPONENTS Interpreter REQUIRED)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
if(BUILD_ONNX_PYTHON)
find_package(PythonLibs ${PY_VERSION})
endif()
@@ -434,6 +456,7 @@ target_link_libraries(onnx PUBLIC onnx_proto)
add_onnx_global_defines(onnx)
if(BUILD_ONNX_PYTHON)
+ find_package(Python3 ${PY_VERSION} COMPONENTS Development REQUIRED)
if("${PY_EXT_SUFFIX}" STREQUAL "")
if(MSVC)
set(PY_EXT_SUFFIX ".pyd")
@@ -452,10 +475,14 @@ if(BUILD_ONNX_PYTHON)
target_include_directories(onnx_cpp2py_export PRIVATE
$<BUILD_INTERFACE:${ONNX_ROOT}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
- $<INSTALL_INTERFACE:include>)
+ ${Python3_INCLUDE_DIRS})
+ target_link_directories(onnx_cpp2py_export PRIVATE
+ ${Python3_LIBRARY_DIRS})
+ target_link_libraries(onnx_cpp2py_export PRIVATE
+ ${Python3_LIBRARIES})
# pybind11 is a header only lib
- find_package(pybind11 2.2 CONFIG)
+ find_package(pybind11 2.2 CONFIG REQUIRED)
if(NOT pybind11_FOUND)
if(EXISTS "${ONNX_ROOT}/third_party/pybind11/include/pybind11/pybind11.h")
add_subdirectory("${ONNX_ROOT}/third_party/pybind11")

View file

@ -0,0 +1,28 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d81ac1d..9f97998 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,6 +149,7 @@ if(ONNX_BUILD_TESTS)
set(googletest_STATIC_LIBRARIES GTest::gtest)
endif()
+find_package(protobuf CONFIG REQUIRED)
if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf))
# Sometimes we need to use protoc compiled for host architecture while linking
# libprotobuf against target architecture. See https://github.com/caffe2/caffe
diff --git a/cmake/ONNXConfig.cmake.in b/cmake/ONNXConfig.cmake.in
index d588f8a..dbd4398 100644
--- a/cmake/ONNXConfig.cmake.in
+++ b/cmake/ONNXConfig.cmake.in
@@ -6,9 +6,8 @@
# library version information
set(ONNX_VERSION "@ONNX_VERSION@")
-list(APPEND CMAKE_PREFIX_PATH "@PROTOBUF_DIR@")
-set(Protobuf_INCLUDE_DIR "@PROTOBUF_INCLUDE_DIR@")
-find_package(Protobuf REQUIRED)
+include(CMakeFindDependencyMacro)
+find_dependency(protobuf CONFIG)
# import targets
include ("${CMAKE_CURRENT_LIST_DIR}/ONNXTargets.cmake")

View file

@ -0,0 +1,83 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO onnx/onnx
REF "v${VERSION}"
SHA512 5a18e2b19ec9c18c8b115fb7e12ed98eddaa581c95f15c4dd420cd6c86e7caa04f9a393da589e76b89cf9b3544abd3749a8c77c2446782f37502eb74e9b1f661
PATCHES
fix-cmakelists.patch
fix-dependency-protobuf.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)
# ONNX_USE_PROTOBUF_SHARED_LIBS: find the library and check its file extension
find_library(PROTOBUF_LIBPATH NAMES protobuf PATHS "${CURRENT_INSTALLED_DIR}/bin" "${CURRENT_INSTALLED_DIR}/lib" REQUIRED)
get_filename_component(PROTOBUF_LIBNAME "${PROTOBUF_LIBPATH}" NAME)
set(USE_PROTOBUF_SHARED OFF)
# Like protoc, python is required for codegen.
vcpkg_find_acquire_program(PYTHON3)
# PATH for .bat scripts so it can find 'python'
get_filename_component(PYTHON_DIR "${PYTHON3}" PATH)
vcpkg_add_to_path(PREPEND "${PYTHON_DIR}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DPython3_EXECUTABLE=${PYTHON3}
-DONNX_ML=ON
-DONNX_GEN_PB_TYPE_STUBS=ON
-DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED}
-DONNX_USE_LITE_PROTO=OFF
-DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
-DONNX_BUILD_TESTS=OFF
-DONNX_BUILD_BENCHMARKS=OFF
-DONNX_DISABLE_STATIC_REGISTRATION=ON
MAYBE_UNUSED_VARIABLES
ONNX_USE_MSVC_STATIC_RUNTIME
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
# the others are empty
"${CURRENT_PACKAGES_DIR}/include/onnx/backend"
"${CURRENT_PACKAGES_DIR}/include/onnx/bin"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/controlflow"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/generator"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/image"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/logical"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/math"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/nn"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/object_detection"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/optional"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/quantization"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/reduction"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/rnn"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/sequence"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/text"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/traditionalml"
"${CURRENT_PACKAGES_DIR}/include/onnx/defs/training"
"${CURRENT_PACKAGES_DIR}/include/onnx/examples"
"${CURRENT_PACKAGES_DIR}/include/onnx/frontend"
"${CURRENT_PACKAGES_DIR}/include/onnx/onnx_cpp2py_export"
"${CURRENT_PACKAGES_DIR}/include/onnx/test"
"${CURRENT_PACKAGES_DIR}/include/onnx/tools"
"${CURRENT_PACKAGES_DIR}/include/onnx/onnx_ml"
"${CURRENT_PACKAGES_DIR}/include/onnx/onnx_data"
"${CURRENT_PACKAGES_DIR}/include/onnx/onnx_operators_ml"
"${CURRENT_PACKAGES_DIR}/include/onnx/reference/ops"
"${CURRENT_PACKAGES_DIR}/include/onnx/reference"
)

View file

@ -0,0 +1,23 @@
{
"name": "onnx",
"version-semver": "1.17.0",
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
"supports": "!uwp",
"dependencies": [
"protobuf",
{
"name": "protobuf",
"host": true
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View file

@ -0,0 +1,82 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f06aada..3c6c6e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,8 +31,6 @@ IF(CCACHE_BINARY)
ENDIF()
# ---[ Options.
-SET(PTHREADPOOL_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build")
-SET_PROPERTY(CACHE PTHREADPOOL_LIBRARY_TYPE PROPERTY STRINGS default static shared)
OPTION(PTHREADPOOL_ALLOW_DEPRECATED_API "Enable deprecated API functions" ON)
SET(PTHREADPOOL_SYNC_PRIMITIVE "default" CACHE STRING "Synchronization primitive (condvar, futex, gcd, event, or default) for worker threads")
SET_PROPERTY(CACHE PTHREADPOOL_SYNC_PRIMITIVE PROPERTY STRINGS default condvar futex gcd event)
@@ -41,7 +39,7 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$")
ELSE()
OPTION(PTHREADPOOL_ENABLE_FASTPATH "Enable fast path using atomic decrement instead of atomic compare-and-swap" OFF)
ENDIF()
-IF("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
+IF(FALSE)
OPTION(PTHREADPOOL_BUILD_TESTS "Build pthreadpool unit tests" ON)
OPTION(PTHREADPOOL_BUILD_BENCHMARKS "Build pthreadpool micro-benchmarks" ON)
ELSE()
@@ -67,7 +65,8 @@ MACRO(PTHREADPOOL_TARGET_ENABLE_CXX11 target)
ENDMACRO()
# ---[ Download deps
-IF(NOT DEFINED FXDIV_SOURCE_DIR)
+find_path(FXDIV_INCLUDE_DIRS "fxdiv.h")
+IF(FALSE)
MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -118,21 +117,13 @@ ELSE()
ENDIF()
ADD_LIBRARY(pthreadpool_interface INTERFACE)
-TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface INTERFACE include)
+TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
IF(NOT PTHREADPOOL_ALLOW_DEPRECATED_API)
TARGET_COMPILE_DEFINITIONS(pthreadpool_interface INTERFACE PTHREADPOOL_NO_DEPRECATED_API=1)
ENDIF()
INSTALL(FILES include/pthreadpool.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-IF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "default")
- ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS})
-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "shared")
- ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS})
-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "static")
- ADD_LIBRARY(pthreadpool STATIC ${PTHREADPOOL_SRCS})
-ELSE()
- MESSAGE(FATAL_ERROR "Unsupported library type ${PTHREADPOOL_LIBRARY_TYPE}")
-ENDIF()
+ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS})
IF(PTHREADPOOL_SYNC_PRIMITIVE STREQUAL "condvar")
TARGET_COMPILE_DEFINITIONS(pthreadpool PRIVATE PTHREADPOOL_USE_FUTEX=0)
@@ -181,18 +172,22 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF()
# ---[ Configure FXdiv
-IF(NOT TARGET fxdiv)
+IF(FALSE)
SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
ADD_SUBDIRECTORY(
"${FXDIV_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/FXdiv")
ENDIF()
-TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv)
+TARGET_INCLUDE_DIRECTORIES(pthreadpool PRIVATE ${FXDIV_INCLUDE_DIRS})
-INSTALL(TARGETS pthreadpool
+INSTALL(TARGETS pthreadpool pthreadpool_interface
+ EXPORT unofficial-pthreadpool-config
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(EXPORT unofficial-pthreadpool-config NAMESPACE unofficial::
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/unofficial-${PROJECT_NAME}) # share/unofficial-pthreadpool
IF(PTHREADPOOL_BUILD_TESTS)
# ---[ Build google test

View file

@ -0,0 +1,25 @@
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/pthreadpool
REF 4e80ca24521aa0fb3a746f9ea9c3eaa20e9afbb0
SHA512 776017cc5d2aa94337292f2f4fbd54d099ef29abf736ab8147f07f98f12b7654cbd2fe38d34646a479a519c261ac253bbaf19c6dcbb0ec4cc0859de70f7e6472
PATCHES
fix-cmakelists.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DPTHREADPOOL_BUILD_TESTS=OFF
-DPTHREADPOOL_BUILD_BENCHMARKS=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT})
#file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

View file

@ -0,0 +1,17 @@
{
"name": "pthreadpool",
"version-date": "2024-12-17",
"description": "Portable (POSIX/Windows/Emscripten) thread pool for C/C++",
"homepage": "https://github.com/google/pthreadpool",
"dependencies": [
"fxdiv",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View file

@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a9fad59a..2713cded3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -334,6 +334,7 @@ ENDIF()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable "note: parameter passing for argument of type ... changed/will change in ..."
ADD_COMPILE_OPTIONS("-Wno-psabi")
+ ADD_COMPILE_OPTIONS("-Wno-incompatible-pointer-types")
ENDIF()
# ---[ Build flags

View file

@ -0,0 +1,71 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0b3410ae..ba54c3bfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1047,9 +1047,11 @@ ENDIF()
IF(XNNPACK_BUILD_ALL_MICROKERNELS)
TARGET_INCLUDE_DIRECTORIES(microkernels-all PRIVATE include src)
ENDIF()
+
TARGET_INCLUDE_DIRECTORIES(datatype PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(microkernels-prod PRIVATE include src)
-TARGET_INCLUDE_DIRECTORIES(hardware-config PRIVATE include src ${CPUINFO_SOURCE_DIR}/include)
+TARGET_INCLUDE_DIRECTORIES(hardware-config PRIVATE include src)
+
TARGET_INCLUDE_DIRECTORIES(indirection PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(microparams-init PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(normalization PRIVATE include src)
@@ -1104,14 +1106,9 @@ IF(NOT TARGET cpuinfo)
"${CPUINFO_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/cpuinfo")
ELSE()
- ADD_LIBRARY(cpuinfo SHARED IMPORTED)
- FIND_LIBRARY(CPUINFO_LIBRARY cpuinfo PATHS "${CPUINFO_SOURCE_DIR}/lib")
- IF(NOT CPUINFO_LIBRARY)
- MESSAGE(FATAL_ERROR "Cannot find cpuinfo")
- ENDIF()
- TARGET_INCLUDE_DIRECTORIES(cpuinfo INTERFACE "${CPUINFO_SOURCE_DIR}/include")
- SET_PROPERTY(TARGET cpuinfo PROPERTY IMPORTED_LOCATION "${CPUINFO_LIBRARY}")
- SET_PROPERTY(TARGET cpuinfo PROPERTY IMPORTED_IMPLIB "${CPUINFO_LIBRARY}")
+ ADD_LIBRARY(cpuinfo INTERFACE)
+ FIND_PACKAGE(cpuinfo CONFIG REQUIRED)
+ TARGET_LINK_LIBRARIES(cpuinfo INTERFACE cpuinfo::cpuinfo)
ENDIF()
ENDIF()
IF(XNNPACK_BUILD_LIBRARY)
@@ -1129,16 +1126,12 @@ IF(NOT TARGET pthreadpool)
"${PTHREADPOOL_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/pthreadpool")
ELSE()
+ find_package(unofficial-pthreadpool CONFIG REQUIRED)
ADD_LIBRARY(pthreadpool SHARED IMPORTED)
- FIND_LIBRARY(PTHREADPOOL_LIBRARY pthreadpool PATHS "${PTHREADPOOL_SOURCE_DIR}/lib")
- IF(NOT PTHREADPOOL_LIBRARY)
- MESSAGE(FATAL_ERROR "Cannot find pthreadpool")
- ENDIF()
+ FIND_LIBRARY(PTHREADPOOL_LIBRARY NAMES pthreadpool REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
- TARGET_INCLUDE_DIRECTORIES(pthreadpool INTERFACE "${PTHREADPOOL_SOURCE_DIR}/include")
- TARGET_LINK_LIBRARIES(pthreadpool INTERFACE Threads::Threads)
+ TARGET_LINK_LIBRARIES(pthreadpool INTERFACE Threads::Threads unofficial::pthreadpool unofficial::pthreadpool_interface)
SET_PROPERTY(TARGET pthreadpool PROPERTY IMPORTED_LOCATION "${PTHREADPOOL_LIBRARY}")
- SET_PROPERTY(TARGET pthreadpool PROPERTY IMPORTED_IMPLIB "${PTHREADPOOL_LIBRARY}")
ENDIF()
ENDIF()
TARGET_LINK_LIBRARIES(xnnpack-base INTERFACE pthreadpool)
@@ -1152,12 +1145,12 @@ IF(NOT TARGET fxdiv)
"${FXDIV_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/FXdiv")
ELSE()
- FIND_FILE(FXDIV_HDR fxdiv.h PATH_SUFFIXES include PATHS "${FXDIV_SOURCE_DIR}")
+ FIND_PATH(FXDIV_HDR fxdiv.h PATH_SUFFIXES include)
IF(NOT FXDIV_HDR)
MESSAGE(FATAL_ERROR "Cannot find fxdiv")
ENDIF()
- ADD_LIBRARY(fxdiv STATIC "${FXDIV_HDR}")
- TARGET_INCLUDE_DIRECTORIES(fxdiv INTERFACE "${FXDIV_SOURCE_DIR}/include")
+ ADD_LIBRARY(fxdiv INTERFACE IMPORTED)
+ target_include_directories(fxdiv INTERFACE "${FXDIV_HDR}")
SET_PROPERTY(TARGET fxdiv PROPERTY LINKER_LANGUAGE C)
ENDIF()
ENDIF()

View file

@ -0,0 +1,39 @@
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/XNNPACK
REF 854b343f9cad36bd596e4390959ca3648208e048
SHA512 f37384b43022cb74bf87bd99c2e82e51d48fe4e0e4642611fcbc10cbb86ff2468b67964027f13f82a715dc7201c490d88d5020fb565ad236187b9dd219f3f644
HEAD_REF master
PATCHES
fix-build.patch
disable_gcc_warning.patch
)
vcpkg_find_acquire_program(PYTHON3)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
WINDOWS_USE_MSBUILD
OPTIONS
"-DPython3_EXECUTABLE=${PYTHON3}"
"-DPython_EXECUTABLE=${PYTHON3}"
-DXNNPACK_USE_SYSTEM_LIBS=ON
-DXNNPACK_ENABLE_AVXVNNI=OFF
-DXNNPACK_ENABLE_ASSEMBLY=ON
-DXNNPACK_ENABLE_MEMOPT=ON
-DXNNPACK_ENABLE_SPARSE=ON
-DXNNPACK_ENABLE_KLEIDIAI=OFF
-DXNNPACK_BUILD_TESTS=OFF
-DXNNPACK_BUILD_BENCHMARKS=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/bin"
"${CURRENT_PACKAGES_DIR}/debug/share"
)

View file

@ -0,0 +1,17 @@
{
"name": "xnnpack",
"version-date": "2025-01-17",
"description": "High-efficiency floating-point neural network inference operators for mobile, server, and Web",
"homepage": "https://github.com/google/XNNPACK",
"license": "BSD-3-Clause",
"supports": "!(arm & windows) & !uwp & !arm32",
"dependencies": [
"cpuinfo",
"fxdiv",
"pthreadpool",
{
"name": "vcpkg-cmake",
"host": true
}
]
}