From 12dd45e17c286f08c0ccc68d4d4c0ea089bc7a5a Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Tue, 30 Dec 2025 09:33:00 +0800 Subject: [PATCH] use GNUInstallDirs for installation --- CMakeLists.txt | 5 +++-- src/CMakeLists.txt | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f913fca..6cd59f2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) if (NOT CMAKE_BUILD_TYPE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release) endif() +include(GNUInstallDirs) option(BUILD_SHARED_LIBS "Make library a shared library instead of static." ON) option(BUILD_TESTING "Build test harnesses along with library." ON) @@ -92,9 +93,9 @@ if (NOT GRAPHITE2_NFILEFACE) endif() set(version 3.0.1) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) +set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) set(includedir ${CMAKE_INSTALL_PREFIX}/include) configure_file(graphite2.pc.in graphite2.pc) -install(FILES ${PROJECT_BINARY_DIR}/graphite2.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) +install(FILES ${PROJECT_BINARY_DIR}/graphite2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 76177edb..24ccf563 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ set(GRAPHITE_VERSION ${GRAPHITE_API_CURRENT}.${GRAPHITE_API_REVISION}.${GRAPHITE set(GRAPHITE_SO_VERSION ${GRAPHITE_API_CURRENT}) include(TestBigEndian) +include(GNUInstallDirs) include_directories(${PROJECT_SOURCE_DIR}) @@ -112,7 +113,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif () set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") if (BUILD_SHARED_LIBS) - CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + CREATE_LIBTOOL_FILE(graphite2 "/${CMAKE_INSTALL_LIBDIR}") endif() endif() @@ -131,7 +132,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") endif () set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") if (BUILD_SHARED_LIBS) - CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + CREATE_LIBTOOL_FILE(graphite2 "/${CMAKE_INSTALL_LIBDIR}") endif() endif() @@ -141,5 +142,5 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") endif() -install(TARGETS graphite2 EXPORT graphite2 LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} PUBLIC_HEADER DESTINATION include/graphite2 RUNTIME DESTINATION bin) +install(TARGETS graphite2 EXPORT graphite2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION include/graphite2 RUNTIME DESTINATION bin) install(EXPORT graphite2 DESTINATION share/graphite2 NAMESPACE gr2_)