Skip to content

Build cpuinfo as ExternalProject #12513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: gh/swolchok/509/head
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,39 +176,49 @@ endif()

if(EXECUTORCH_BUILD_CPUINFO)
# --- cpuinfo
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
${CMAKE_POSITION_INDEPENDENT_CODE}
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CPUINFO_SOURCE_DIR "backends/xnnpack/third-party/cpuinfo")
set(CPUINFO_BUILD_TOOLS
OFF
CACHE BOOL ""
)
set(CPUINFO_BUILD_UNIT_TESTS
OFF
CACHE BOOL ""
)
set(CPUINFO_BUILD_MOCK_TESTS
OFF
CACHE BOOL ""
)
set(CPUINFO_BUILD_BENCHMARKS
OFF
CACHE BOOL ""
set(CPUINFO_SOURCE_DIR
"${CMAKE_CURRENT_LIST_DIR}/backends/xnnpack/third-party/cpuinfo"
)
set(CPUINFO_LIBRARY_TYPE
"static"
CACHE STRING ""
set(CPUINFO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/cpuinfo")
set(CPUINFO_INSTALL_DIR "${CPUINFO_BINARY_DIR}/install")
set(CPUINFO_LIBRARY
"${CPUINFO_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libcpuinfo.a"
)
set(CPUINFO_LOG_LEVEL
"error"
CACHE STRING ""

get_extra_cmake_args_for_external_project(CPUINFO_EXTRA_CMAKE_ARGS)
ExternalProject_Add(
cpuinfoExternalProject
SOURCE_DIR "${CPUINFO_SOURCE_DIR}"
BINARY_DIR "${CPUINFO_BINARY_DIR}"
INSTALL_DIR "${CPUINFO_INSTALL_DIR}"
BUILD_BYPRODUCTS "${CPUINFO_LIBRARY}"
CMAKE_ARGS "${CPUINFO_EXTRA_CMAKE_ARGS}"
-D
CMAKE_POSITION_INDEPENDENT_CODE=ON
-D
CPUINFO_BUILD_TOOLS=OFF
-D
CPUINFO_BUILD_UNIT_TESTS=OFF
-D
CPUINFO_BUILD_MOCK_TESTS=OFF
-D
CPUINFO_BUILD_BENCHMARKS=OFF
-D
CPUINFO_LIBRARY_TYPE=static
-D
CPUINFO_LOG_LEVEL=error
-D
CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-D
CLOG_SOURCE_DIR="${CPUINFO_SOURCE_DIR}/deps/clog"
)
set(CLOG_SOURCE_DIR "${CPUINFO_SOURCE_DIR}/deps/clog")
add_subdirectory("${CPUINFO_SOURCE_DIR}")
set(CMAKE_POSITION_INDEPENDENT_CODE
${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG}
add_library(cpuinfo STATIC IMPORTED)
set_property(TARGET cpuinfo PROPERTY IMPORTED_LOCATION "${CPUINFO_LIBRARY}")
add_dependencies(cpuinfo cpuinfoExternalProject)
# Trailing slash matters here! "Move everything from the temporary pthreadpool
# install directory to the proper install directory."
install(DIRECTORY "${CPUINFO_INSTALL_DIR}/"
DESTINATION "${CMAKE_INSTALL_PREFIX}"
)
endif()

Expand Down
Loading