diff --git a/CMakeLists.txt b/CMakeLists.txt index 90ca3e2..0b99c1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,20 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME}) +# Create pkg-config file +include(build/JoinPaths.cmake) +# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files +join_paths(DIRECTXMATH_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") +join_paths(DIRECTXMATH_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/build/DirectXMath.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/DirectXMath.pc" @ONLY) + +# Install the pkg-config file +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectXMath.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + #--- Test suite if (DEFINED VCPKG_TARGET_ARCHITECTURE) set(DXMATH_ARCHITECTURE ${VCPKG_TARGET_ARCHITECTURE}) diff --git a/build/DirectXMath.pc.in b/build/DirectXMath.pc.in new file mode 100644 index 0000000..2814d49 --- /dev/null +++ b/build/DirectXMath.pc.in @@ -0,0 +1,10 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@DIRECTXMATH_LIBDIR_FOR_PKG_CONFIG@ +includedir=@DIRECTXMATH_INCLUDEDIR_FOR_PKG_CONFIG@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +URL: @PROJECT_HOMEPAGE_URL@ +Version: @PROJECT_VERSION@ +Cflags: -I${includedir} +Libs: diff --git a/build/JoinPaths.cmake b/build/JoinPaths.cmake new file mode 100644 index 0000000..c68d91b --- /dev/null +++ b/build/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()