From e3692928076c420e5092ba0718c885e37f59cb01 Mon Sep 17 00:00:00 2001 From: "MARINA\\jpmug" Date: Sun, 21 May 2023 04:28:29 -0400 Subject: [PATCH] Fix issues from discussion. --- CMakeLists.txt | 13 +++++-------- cmake/DirectX-Headers.pc.in | 13 ++++++------- cmake/JoinPaths.cmake | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 cmake/JoinPaths.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 981bb08..d84a1a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,10 +10,6 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -#pkg-config values -set(DXHEADERS_URL "https://github.com/microsoft/DirectX-Headers") -set(DXHEADERS_DESCRIPTION "Headers for using D3D12") - # It's useful to know if you are a top level project or not, if your project is # being consumed via add_subdirectory if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) @@ -93,13 +89,14 @@ if (DXHEADERS_INSTALL) DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/directx-headers/cmake) # Create pkg-config file - set(DIRECTX_HEADERS_L DirectX-Headers) - set(DIRECTX_GUIDS_L DirectX-Guids) - + include(cmake/JoinPaths.cmake) + # from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files + join_paths(DIRECTX_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") + join_paths(DIRECTX_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/DirectX-Headers.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc" @ONLY) - + # Install the pkg-config file install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectX-Headers.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/cmake/DirectX-Headers.pc.in b/cmake/DirectX-Headers.pc.in index 6999486..937f2db 100644 --- a/cmake/DirectX-Headers.pc.in +++ b/cmake/DirectX-Headers.pc.in @@ -1,11 +1,10 @@ -prefix="@CMAKE_INSTALL_PREFIX@" -exec_prefix="${prefix}" -libdir="${prefix}/lib" -includedir="${prefix}/include" +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@DIRECTX_LIBDIR_FOR_PKG_CONFIG@ +includedir=@DIRECTX_INCLUDEDIR_FOR_PKG_CONFIG@ Name: @PROJECT_NAME@ -Description: @DXHEADERS_DESCRIPTION@ -URL: @DXHEADERS_URL@ +Description: Headers for using D3D12 +URL: https://github.com/microsoft/DirectX-Header Version: @PROJECT_VERSION@ Cflags: -I${includedir} -Libs: -l@DIRECTX_HEADERS_L@ -l@DIRECTX_GUIDS_L@ +Libs: -lDirectX-Headers -lDirectX-Guids diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake new file mode 100644 index 0000000..c68d91b --- /dev/null +++ b/cmake/JoinPaths.cmake @@ -0,0 +1,23 @@ +# 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 +# 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()