Fix issues from discussion.

This commit is contained in:
MARINA\jpmug 2023-05-21 04:28:29 -04:00
parent 37144c617a
commit e369292807
3 changed files with 34 additions and 15 deletions

View File

@ -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)

View File

@ -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

23
cmake/JoinPaths.cmake Normal file
View File

@ -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 Pythons 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()