pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
992 stars 311 forks source link

Support CMake find_package #69

Closed luncliff closed 2 years ago

luncliff commented 2 years ago

Changes

CMake build generates cpuinfo-config.cmake and some other CMake scripts. These files will be installed under {prefix}/share/cpuinfo.

Folder PATH listing for volume Local Disk
Volume serial number is 58BA-9039
C:\USERS\LUNCL\SOURCE\CPUINFO\INSTALL
├───bin
│       cache-info.exe
│       cpu-info.exe
│       cpuid-dump.exe
│       isa-info.exe
│       
├───include
│       clog.h
│       cpuinfo.h
│       
├───lib
│   │   clog.lib
│   │   cpuinfo.lib
│   │   
│   └───pkgconfig
│           libcpuinfo.pc
│
└───share
    └───cpuinfo
            cpuinfo-config.cmake
            cpuinfo-targets-debug.cmake
            cpuinfo-targets.cmake

After install, CMake users can search the libraries (cpuinfo and clog) using find_package config mode.

find_package(cpuinfo CONFIG REQUIRED)
target_link_libraries(main
PRIVATE
    cpuinfo::cpuinfo cpuinfo::clog
)
petrhosek commented 2 years ago

We're planning on taking a dependency on cpuinfo from LLVM (transitively via TFLite) and this change is one of the blockers so we would really like to see it merged. Is there any way we can help? I have looked over the change and it looks good to me.