Use the GNUInstallDirs CMake module to respect installation locations

Apparently use of LIB_SUFFIX is now discouraged. GNUInstallDirs does a
better job of setting a default.

The libdir of ${prefix}/lib in the pkg-config file caused warnings,
and possibly even failures, when linking on multilib systems where
/usr/lib is for 32-bit libraries rather than 64-bit libraries.
This commit is contained in:
James Le Cuirot 2021-07-10 22:55:53 +01:00 committed by Ryan C. Gordon
parent 0145431345
commit d8ba1a935c
2 changed files with 12 additions and 11 deletions

View File

@ -14,6 +14,8 @@ cmake_minimum_required(VERSION 2.8.12)
project(PhysicsFS) project(PhysicsFS)
set(PHYSFS_VERSION 3.1.0) set(PHYSFS_VERSION 3.1.0)
include(GNUInstallDirs)
# Increment this if/when we break backwards compatibility. # Increment this if/when we break backwards compatibility.
set(PHYSFS_SOVERSION 1) set(PHYSFS_SOVERSION 1)
@ -215,14 +217,14 @@ if(PHYSFS_BUILD_TEST)
endif() endif()
install(TARGETS ${PHYSFS_INSTALL_TARGETS} EXPORT PhysFSExport install(TARGETS ${PHYSFS_INSTALL_TARGETS} EXPORT PhysFSExport
RUNTIME DESTINATION bin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION lib${LIB_SUFFIX} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include) INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES src/physfs.h DESTINATION include) install(FILES src/physfs.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT PhysFSExport install(EXPORT PhysFSExport
DESTINATION "lib${LIB_SUFFIX}/cmake/PhysFS" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PhysFS"
FILE PhysFSConfig.cmake FILE PhysFSConfig.cmake
) )
@ -279,7 +281,7 @@ if(NOT MSVC)
) )
install( install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc" FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
) )
endif() endif()
@ -310,4 +312,3 @@ if(PHYSFS_BUILD_TEST)
endif() endif()
# end of CMakeLists.txt ... # end of CMakeLists.txt ...

View File

@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/lib libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=${prefix}/include includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: PhysicsFS Name: PhysicsFS
Description: PhysicsFS is a library to provide abstract access to various archives. Description: PhysicsFS is a library to provide abstract access to various archives.