onnxruntime/cmake/vcpkg-ports/pthreadpool/fix-cmakelists.patch
Changming Sun 77adf4b040
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.
-
2025-01-22 11:49:16 -08:00

82 lines
3.6 KiB
Diff

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