Skip to content

Commit

Permalink
keep the path for pkg-config path if they are absolute
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
robUx4 committed May 15, 2022
1 parent 8cf9207 commit eab77a2
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,34 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matroska_export.h DESTINATION ${CMAKE_
if(NOT DISABLE_PKGCONFIG)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\$\{prefix\}")
set(libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
get_filename_component(absdir ${CMAKE_INSTALL_LIBDIR} ABSOLUTE)
if (absdir STREQUAL CMAKE_INSTALL_LIBDIR)
set(abs_libdir ON)
else()
set(abs_libdir OFF)
endif()
get_filename_component(absdir ${CMAKE_INSTALL_INCLUDEDIR} ABSOLUTE)
if (absdir STREQUAL CMAKE_INSTALL_INCLUDEDIR)
set(abs_incdir ON)
else()
set(abs_incdir OFF)
endif()
else()
cmake_path(IS_ABSOLUTE CMAKE_INSTALL_LIBDIR abs_libdir)
cmake_path(IS_ABSOLUTE CMAKE_INSTALL_INCLUDEDIR abs_incdir)
endif()
if (${abs_libdir})
set(libdir "${CMAKE_INSTALL_LIBDIR}")
else()
message(STATUS "using relative \$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
set(libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
endif()
if (${abs_incdir})
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
set(PACKAGE_VERSION ${PROJECT_VERSION})
configure_file(libmatroska.pc.in libmatroska.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmatroska.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
Expand Down

0 comments on commit eab77a2

Please sign in to comment.