Skip to content

Commit

Permalink
CMakeLists.txt: Generate pkg-config manifest, even for static librari…
Browse files Browse the repository at this point in the history
…es if requested...

{CMakeLists.txt,libcpuinfo.pc.in}: Remove semantic versioning, as per @Maratyszcza's request...
CMakeLists.txt: Cosmetic formatting changes, per @Maratyszcza's request...
  • Loading branch information
kiplingw committed Jul 13, 2021
1 parent c14bec0 commit 2f10af3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
41 changes: 20 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR)

# ---[ Project and semantic versioning.
# ---[ Setup project
PROJECT(
cpuinfo
LANGUAGES C CXX
HOMEPAGE_URL https://github.com/pytorch/cpuinfo
VERSION 0.1.0)
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")
Expand Down Expand Up @@ -828,24 +827,24 @@ IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_TOOLS)
ENDIF()

# ---[ pkg-config manifest. This is mostly from JsonCpp...
if(CPUINFO_BUILD_PKG_CONFIG AND (CPUINFO_LIBRARY_TYPE STREQUAL "default" OR CPUINFO_LIBRARY_TYPE STREQUAL "shared"))

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}")
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"
Expand Down
2 changes: 1 addition & 1 deletion libcpuinfo.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includedir=@includedir_for_pc_file@

Name: lib@CMAKE_PROJECT_NAME@
Description: Library to detect essential performance optimization information about host CPU.
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Version:
URL: @PROJECT_HOMEPAGE_URL@
Libs: -L${libdir} -lcpuinfo
Cflags: -I${includedir}
Expand Down

0 comments on commit 2f10af3

Please sign in to comment.