Skip to content

Commit 8f5b3b6

Browse files
Fix xsimd.pc paths
Accept both relative and absolute libdir and include dir Fix #748
1 parent 67d47f2 commit 8f5b3b6

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ endif()
124124
# Installation
125125
# ============
126126

127+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
128+
include(JoinPaths)
127129
include(GNUInstallDirs)
128130
include(CMakePackageConfigHelpers)
129131

@@ -159,6 +161,8 @@ install(EXPORT ${PROJECT_NAME}-targets
159161
FILE ${PROJECT_NAME}Targets.cmake
160162
DESTINATION ${XSIMD_CMAKECONFIG_INSTALL_DIR})
161163

164+
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
165+
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
162166
configure_file(${PROJECT_NAME}.pc.in
163167
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
164168
@ONLY)

cmake/JoinPaths.cmake

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This module provides function for joining paths
2+
# known from from most languages
3+
#
4+
# Original license:
5+
# SPDX-License-Identifier: (MIT OR CC0-1.0)
6+
# Explicit permission given to distribute this module under
7+
# the terms of the project as described in /LICENSE.rst.
8+
# Copyright 2020 Jan Tojnar
9+
# https://github.com/jtojnar/cmake-snips
10+
#
11+
# Modelled after Python’s os.path.join
12+
# https://docs.python.org/3.7/library/os.path.html#os.path.join
13+
# Windows not supported
14+
function(join_paths joined_path first_path_segment)
15+
set(temp_path "${first_path_segment}")
16+
foreach(current_segment IN LISTS ARGN)
17+
if(NOT ("${current_segment}" STREQUAL ""))
18+
if(IS_ABSOLUTE "${current_segment}")
19+
set(temp_path "${current_segment}")
20+
else()
21+
set(temp_path "${temp_path}/${current_segment}")
22+
endif()
23+
endif()
24+
endforeach()
25+
set(${joined_path} "${temp_path}" PARENT_SCOPE)
26+
endfunction()

xsimd.pc.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
3-
includedir=${prefix}/include
2+
ibdir=@libdir_for_pc_file@
3+
includedir=@includedir_for_pc_file@
44

55
Name: xsimd
66
Description: xsimd provides a unified means for using SIMD features for library authors..

0 commit comments

Comments
 (0)