diff --git a/CMakeLists.txt b/CMakeLists.txt index ae1d0220..52a1c142 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,8 +120,34 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ebml_export.h DESTINATION ${CMAKE_INST 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}) if (HAVE_WINAPIFAMILY_H) set(WINAPIFAMILY_PC -DHAVE_WINAPIFAMILY_H)