icculus / physfs

A portable, flexible file i/o abstraction.
https://icculus.org/physfs/
zlib License
559 stars 98 forks source link

Add an option to turn off CMAKE_SKIP_RPATH or make it target specific #49

Open Silentd00m opened 2 years ago

Silentd00m commented 2 years ago

Currently projects using CPM that use this library will have their RPATH broken for all targets defined after the CPMAddPackage for physfs, unless CMAKE_SKIP_RPATH is force-set to OFF.

Example:

CPMAddPackage(
  NAME physfs
  GIT_REPOSITORY https://github.com/icculus/physfs
  GIT_TAG release-3.2.0
  OPTIONS "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}"
                  "PHYSFS_ARCHIVE_GRP OFF"
          "PHYSFS_ARCHIVE_WAD OFF"
          "PHYSFS_ARCHIVE_HOG OFF"
          "PHYSFS_ARCHIVE_MVL OFF"
          "PHYSFS_ARCHIVE_QPAK OFF"
          "PHYSFS_ARCHIVE_SLB OFF"
          "PHYSFS_ARCHIVE_ISO9660 OFF"
          "PHYSFS_ARCHIVE_VDF OFF")

# Cleanup after physfs' use of set to avoid breaking the linker.
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
  set(CMAKE_SKIP_RPATH OFF CACHE BOOL "Skip RPATH" FORCE)
endif()

Having an option to turn this behaviour off would be appreciated.

I can provide a small pull request that implements this, if this feature is accepted.

madebr commented 9 months ago

set(CMAKE_SKIP_RPATH OFF CACHE BOOL "Skip RPATH" FORCE) has already been removed from the 4.0 branch. I think it can also be removed from the 3.2 branch.

I noticed Ryan adds/added these to lots of his projects, probably because the build-time rpath should not be present in installed libraries. When doing cmake --install $buildfolder, by default, CMake will remove the runpath.