Linux.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. SET(CMAKE_DL_LIBS "dl")
  2. SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
  3. SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
  4. SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
  5. SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
  6. SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
  7. # Shared libraries with no builtin soname may not be linked safely by
  8. # specifying the file path.
  9. SET(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
  10. # Initialize C link type selection flags. These flags are used when
  11. # building a shared library, shared module, or executable that links
  12. # to other libraries to select whether to use the static or shared
  13. # versions of the libraries.
  14. FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE)
  15. SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
  16. SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
  17. ENDFOREACH(type)
  18. # Debian policy requires that shared libraries be installed without
  19. # executable permission. Fedora policy requires that shared libraries
  20. # be installed with the executable permission. Since the native tools
  21. # create shared libraries with execute permission in the first place a
  22. # reasonable policy seems to be to install with execute permission by
  23. # default. In order to support debian packages we provide an option
  24. # here. The option default is based on the current distribution, but
  25. # packagers can set it explicitly on the command line.
  26. IF(DEFINED CMAKE_INSTALL_SO_NO_EXE)
  27. # Store the decision variable in the cache. This preserves any
  28. # setting the user provides on the command line.
  29. SET(CMAKE_INSTALL_SO_NO_EXE "${CMAKE_INSTALL_SO_NO_EXE}" CACHE INTERNAL
  30. "Install .so files without execute permission.")
  31. ELSE(DEFINED CMAKE_INSTALL_SO_NO_EXE)
  32. # Store the decision variable as an internal cache entry to avoid
  33. # checking the platform every time. This option is advanced enough
  34. # that only package maintainers should need to adjust it. They are
  35. # capable of providing a setting on the command line.
  36. IF(EXISTS "/etc/debian_version")
  37. SET(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
  38. "Install .so files without execute permission.")
  39. ELSE(EXISTS "/etc/debian_version")
  40. SET(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
  41. "Install .so files without execute permission.")
  42. ENDIF(EXISTS "/etc/debian_version")
  43. ENDIF(DEFINED CMAKE_INSTALL_SO_NO_EXE)
  44. INCLUDE(Platform/UnixPaths)
  45. # Debian has lib64 paths only for compatibility so they should not be
  46. # searched.
  47. IF(EXISTS "/etc/debian_version")
  48. SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
  49. ENDIF(EXISTS "/etc/debian_version")