cmake: Fix paths with absolute GNUInstallDirs
It is not generally true that `CMAKE_INSTALL_<dir>` variables are relative paths: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files https://github.com/jtojnar/cmake-snips#assuming-cmake_install_dir-is-relative-path Let's join them properly as paths, not strings. On Windows, the absolute paths will likely remain unsupported as neither the CMake function, nor the C++ code is able to detect absolute paths. Signed-off-by: Jan Tojnar <jtojnar@gmail.com>
This commit is contained in:
parent
124c46379c
commit
48f2c9dbba
@ -135,6 +135,8 @@ if (EXIV2_TEAM_PACKAGING)
|
||||
include(cmake/packaging.cmake)
|
||||
endif()
|
||||
|
||||
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
configure_file(cmake/exiv2.pc.in exiv2.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/exiv2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
|
||||
24
cmake/JoinPaths.cmake
Normal file
24
cmake/JoinPaths.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
# This module provides function for joining paths
|
||||
# known from from most languages
|
||||
#
|
||||
# Original license:
|
||||
# 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
|
||||
# Windows not supported
|
||||
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()
|
||||
@ -1,7 +1,7 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
libdir=@libdir_for_pc_file@
|
||||
includedir=@includedir_for_pc_file@
|
||||
|
||||
Name: exiv2
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
|
||||
@ -5,6 +5,7 @@ include(GNUInstallDirs)
|
||||
include(CheckFunctionExists)
|
||||
include(GenerateExportHeader)
|
||||
include(CMakeDependentOption)
|
||||
include(cmake/JoinPaths.cmake)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
@ -23,7 +24,7 @@ if (UNIX)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
set(CMAKE_INSTALL_RPATH "@loader_path")
|
||||
else()
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
|
||||
join_paths(CMAKE_INSTALL_RPATH "$ORIGIN" ".." "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@ -215,7 +215,8 @@ if( EXIV2_ENABLE_NLS )
|
||||
target_include_directories(exiv2lib PRIVATE ${Intl_INCLUDE_DIRS})
|
||||
target_include_directories(exiv2lib_int PRIVATE ${Intl_INCLUDE_DIRS})
|
||||
# Definition needed for translations
|
||||
target_compile_definitions(exiv2lib PUBLIC EXV_LOCALEDIR="/../${CMAKE_INSTALL_LOCALEDIR}")
|
||||
join_paths(EXV_LOCALEDIR ".." "${CMAKE_INSTALL_LOCALEDIR}")
|
||||
target_compile_definitions(exiv2lib PUBLIC EXV_LOCALEDIR="${EXV_LOCALEDIR}")
|
||||
endif()
|
||||
|
||||
if( ICONV_FOUND )
|
||||
|
||||
@ -132,7 +132,7 @@ int main(int argc, char* const argv[])
|
||||
|
||||
#ifdef EXV_ENABLE_NLS
|
||||
setlocale(LC_ALL, "");
|
||||
const std::string localeDir = Exiv2::getProcessPath() + EXV_LOCALEDIR;
|
||||
const std::string localeDir = EXV_LOCALEDIR[0] == '/' ? EXV_LOCALEDIR : (Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR);
|
||||
bindtextdomain(EXV_PACKAGE_NAME, localeDir.c_str());
|
||||
textdomain(EXV_PACKAGE_NAME);
|
||||
#endif
|
||||
|
||||
@ -729,7 +729,7 @@ const char* _exvGettext(const char* str)
|
||||
|
||||
if (!exvGettextInitialized) {
|
||||
//bindtextdomain(EXV_PACKAGE_NAME, EXV_LOCALEDIR);
|
||||
const std::string localeDir = Exiv2::getProcessPath() + EXV_LOCALEDIR;
|
||||
const std::string localeDir = EXV_LOCALEDIR[0] == '/' ? EXV_LOCALEDIR : (Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR);
|
||||
bindtextdomain(EXV_PACKAGE_NAME, localeDir.c_str());
|
||||
# ifdef EXV_HAVE_BIND_TEXTDOMAIN_CODESET
|
||||
bind_textdomain_codeset (EXV_PACKAGE_NAME, "UTF-8");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user