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