-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't assume
CMAKE_INSTALL_*DIR
variables are relative (#305)
* Don't assume CMAKE_INSTALL_*DIR variables are relative The CMAKE_INSTALL_*DIR variables are allowed to be absolute paths, so they cannot be simply appended to CMAKE_INSTALL_PREFIX. When an absolute path is needed, CMAKE_INSTALL_FULL_*DIR must be used. Additionally, pkgconfig files should use ${prefix} relative paths if CMAKE_INSTALL_*DIR are relative, but otherwise use absolute paths. This is handled by the custom join_paths() function. Note that CMake 3.20 provides cmake_path(APPEND) which implements the same functionality as join_paths(), but this CMake version is not available in all supported distros yet (notably Ubuntu older than 22.04). Signed-off-by: Ben Wolsieffer <[email protected]> Co-authored-by: Jose Luis Rivero <[email protected]>
- Loading branch information
1 parent
106fd41
commit 4283fc6
Showing
6 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This module provides function for joining paths | ||
# known from most languages | ||
# | ||
# SPDX-License-Identifier: (MIT OR CC0-1.0) | ||
# Copyright 2020 Jan Tojnar | ||
# https://github.com/jtojnar/cmake-snips | ||
# | ||
# Modelled after Python’s os.path.join | ||
# https://docs.python.org/3.7/library/os.path.html#os.path.join | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters