Linux.cmake 3.0 KB

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