diff options
author | Ashkan Aliabadi <ashkan.aliabadi@gmail.com> | 2021-07-14 14:52:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-14 14:52:20 -0700 |
commit | 6c89db05524d1d52a88251ef23f29c46ec873a99 (patch) | |
tree | 086e053f5a56c6f5819c2e02b14d96ce5f97754b /CMakeLists.txt | |
parent | 5916273f79a21551890fd3d56fc5375a78d1598d (diff) | |
parent | 41f97cfd347b27f041deb486e1df51b0049371ce (diff) | |
download | cpuinfo-6c89db05524d1d52a88251ef23f29c46ec873a99.tar.gz |
Merge pull request #61 from kiplingw/kip-pkg-config
Add support for pkg-config (#60)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e2d7d53..845ec28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR) -# ---[ Project and semantic versioning. -PROJECT(cpuinfo C CXX) +# ---[ Setup project +PROJECT( + cpuinfo + LANGUAGES C CXX + HOMEPAGE_URL https://github.com/pytorch/cpuinfo) # ---[ Options. SET(CPUINFO_LIBRARY_TYPE "default" CACHE STRING "Type of cpuinfo library (shared, static, or default) to build") @@ -14,6 +17,7 @@ OPTION(CPUINFO_BUILD_TOOLS "Build command-line tools" ON) OPTION(CPUINFO_BUILD_UNIT_TESTS "Build cpuinfo unit tests" ON) OPTION(CPUINFO_BUILD_MOCK_TESTS "Build cpuinfo mock tests" ON) OPTION(CPUINFO_BUILD_BENCHMARKS "Build cpuinfo micro-benchmarks" ON) +OPTION(CPUINFO_BUILD_PKG_CONFIG "Build pkg-config manifest" ON) # ---[ CMake options INCLUDE(GNUInstallDirs) @@ -821,3 +825,34 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_TOOLS) INSTALL(TARGETS cpuid-dump RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ENDIF() ENDIF() + +# ---[ pkg-config manifest. This is mostly from JsonCpp... +IF(CPUINFO_BUILD_PKG_CONFIG) + + FUNCTION(JOIN_PATHS joined_path first_path_segment) + SET(temp_path "${first_path_segment}") + FOREACH(current_segment IN LISTS ARGN) + IF(NOT ("${current_segment}" STREQUAL "")) + IF(IS_ABSOLUTE "${current_segment}") + SET(temp_path "${current_segment}") + ELSE() + SET(temp_path "${temp_path}/${current_segment}") + ENDIF() + ENDIF() + ENDFOREACH() + SET(${joined_path} "${temp_path}" PARENT_SCOPE) + ENDFUNCTION() + + JOIN_PATHS(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") + JOIN_PATHS(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") + + CONFIGURE_FILE( + "libcpuinfo.pc.in" + "libcpuinfo.pc" + @ONLY) + + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libcpuinfo.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +ENDIF() + |