@@ -87,9 +87,29 @@ endif()
87
87
FetchContent_MakeAvailable (SwiftFoundationICU SwiftFoundation )
88
88
89
89
include (CheckLinkerFlag )
90
+ include (CheckSymbolExists )
90
91
91
92
check_linker_flag (C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID )
92
93
94
+ # Detect if the system libc defines symbols for these functions.
95
+ # If it is not availble, swift-corelibs-foundation has its own implementations
96
+ # that will be used. If it is available, it should not redefine them.
97
+ # Note: SwiftPM does not have the ability to introspect the contents of the SDK
98
+ # and therefore will always include these functions in the build and will
99
+ # cause build failures on platforms that define these functions.
100
+ check_symbol_exists ("strlcat" "string.h" HAVE_STRLCAT )
101
+ check_symbol_exists ("strlcpy" "string.h" HAVE_STRLCPY )
102
+ check_symbol_exists ("issetugid" "unistd.h" HAVE_ISSETUGID )
103
+ add_compile_definitions (
104
+ $< $< AND:$< COMPILE_LANGUAGE:C> ,$< BOOL:${HAVE_STRLCAT} > > :HAVE_STRLCAT>
105
+ $< $< AND:$< COMPILE_LANGUAGE:C> ,$< BOOL:${HAVE_STRLCPY} > > :HAVE_STRLCPY>
106
+ $< $< AND:$< COMPILE_LANGUAGE:C> ,$< BOOL:${HAVE_ISSETUGID} > > :HAVE_ISSETUGID> )
107
+
108
+ if (CMAKE_SYSTEM_NAME STREQUAL Linux )
109
+ check_symbol_exists (sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY )
110
+ add_compile_definitions ($< $< COMPILE_LANGUAGE:C> :HAVE_SCHED_GETAFFINITY> )
111
+ endif ()
112
+
93
113
# Precompute module triple for installation
94
114
if (NOT SwiftFoundation_MODULE_TRIPLE )
95
115
set (module_triple_command "${CMAKE_Swift_COMPILER} " -print-target-info )
@@ -103,6 +123,7 @@ if(NOT SwiftFoundation_MODULE_TRIPLE)
103
123
endif ()
104
124
105
125
# System dependencies
126
+ find_package (LibRT )
106
127
find_package (dispatch CONFIG )
107
128
if (NOT dispatch_FOUND )
108
129
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
0 commit comments