Have CMake generate pkg-config file for library (#133)
This commit is contained in:
Родитель
25d3dde4af
Коммит
de7730929e
|
@ -237,6 +237,35 @@ 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(UVATLAS_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
join_paths(UVATLAS_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
set(UVATLAS_DEP_L "")
|
||||
if(ENABLE_USE_EIGEN)
|
||||
list(APPEND UVATLAS_DEP_L "eigen3")
|
||||
endif()
|
||||
if(directxmath_FOUND)
|
||||
list(APPEND UVATLAS_DEP_L "DirectXMath")
|
||||
endif()
|
||||
if(directx-headers_FOUND)
|
||||
list(APPEND UVATLAS_DEP_L "DirectX-Headers")
|
||||
endif()
|
||||
list(LENGTH UVATLAS_DEP_L DEP_L)
|
||||
if(DEP_L)
|
||||
string(REPLACE ";" ", " UVATLAS_DEP " ${UVATLAS_DEP_L}")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/build/UVAtlas.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/UVAtlas.pc" @ONLY)
|
||||
|
||||
# Install the pkg-config file
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UVAtlas.pc"
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
#--- Command-line tool
|
||||
if(BUILD_TOOLS AND WIN32)
|
||||
set(TOOL_EXES uvatlastool)
|
||||
|
|
|
@ -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()
|
|
@ -0,0 +1,11 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=@UVATLAS_LIBDIR_FOR_PKG_CONFIG@
|
||||
includedir=@UVATLAS_INCLUDEDIR_FOR_PKG_CONFIG@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
URL: @PROJECT_HOMEPAGE_URL@
|
||||
Version: @PROJECT_VERSION@
|
||||
Requires:@UVATLAS_DEP@
|
||||
Cflags: -I${includedir}
|
||||
Libs: -l@PROJECT_NAME@
|
Загрузка…
Ссылка в новой задаче