Linux.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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()
  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()
  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()
  40. set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
  41. "Install .so files without execute permission.")
  42. endif()
  43. endif()
  44. # Match multiarch library directory names.
  45. set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
  46. include(Platform/UnixPaths)
  47. # Debian has lib32 and lib64 paths only for compatibility so they should not be
  48. # searched.
  49. if(NOT CMAKE_CROSSCOMPILING AND EXISTS "/etc/debian_version")
  50. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
  51. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
  52. endif()