2 set(CMAKE_DL_LIBS "dl")
3 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
4 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
5 set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
6 set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
7 set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
8 set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
10 # Shared libraries with no builtin soname may not be linked safely by
11 # specifying the file path.
12 set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
14 # Initialize C link type selection flags. These flags are used when
15 # building a shared library, shared module, or executable that links
16 # to other libraries to select whether to use the static or shared
17 # versions of the libraries.
18 foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
19 set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
20 set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
24 # Features for LINK_LIBRARY generator expression
25 ## check linker capabilities
26 if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
27 execute_process(COMMAND "${CMAKE_LINKER}" --help
28 OUTPUT_VARIABLE __linker_help
29 ERROR_VARIABLE __linker_help)
30 if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
31 set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
33 set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
37 ## WHOLE_ARCHIVE: Force loading all members of an archive
38 if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
39 set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
43 set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
45 "LINKER:--no-whole-archive")
47 set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
49 # Features for LINK_GROUP generator expression
50 ## RESCAN: request the linker to rescan static libraries until there is
51 ## no pending undefined symbols
52 set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group")
53 set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
56 # Debian policy requires that shared libraries be installed without
57 # executable permission. Fedora policy requires that shared libraries
58 # be installed with the executable permission. Since the native tools
59 # create shared libraries with execute permission in the first place a
60 # reasonable policy seems to be to install with execute permission by
61 # default. In order to support debian packages we provide an option
62 # here. The option default is based on the current distribution, but
63 # packagers can set it explicitly on the command line.
64 if(DEFINED CMAKE_INSTALL_SO_NO_EXE)
65 # Store the decision variable in the cache. This preserves any
66 # setting the user provides on the command line.
67 set(CMAKE_INSTALL_SO_NO_EXE "${CMAKE_INSTALL_SO_NO_EXE}" CACHE INTERNAL
68 "Install .so files without execute permission.")
70 # Store the decision variable as an internal cache entry to avoid
71 # checking the platform every time. This option is advanced enough
72 # that only package maintainers should need to adjust it. They are
73 # capable of providing a setting on the command line.
74 if(EXISTS "/etc/debian_version")
75 set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
76 "Install .so files without execute permission.")
78 set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
79 "Install .so files without execute permission.")
83 # Match multiarch library directory names.
84 set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
86 include(Platform/UnixPaths)
88 # Debian has lib32 and lib64 paths only for compatibility so they should not be
90 if(NOT CMAKE_CROSSCOMPILING)
91 if (EXISTS "/etc/debian_version")
92 set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
93 set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
95 if (EXISTS "/etc/arch-release")
96 set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)