diff --git a/CMakeLists.txt b/CMakeLists.txt index bf434b691d..54cc320b3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,6 @@ find_package(LibXml2 REQUIRED) include(SwiftSupport) include(GNUInstallDirs) -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - include(CheckSymbolExists) - include(CheckIncludeFile) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) - check_include_file("sched.h" HAVE_SCHED_H) - check_symbol_exists(sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY) -endif() - string(TOLOWER ${CMAKE_SYSTEM_NAME} swift_os) get_swift_host_arch(swift_arch) diff --git a/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt index fc1b5f9f71..e2fb89a10a 100644 --- a/CoreFoundation/CMakeLists.txt +++ b/CoreFoundation/CMakeLists.txt @@ -368,6 +368,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android) target_compile_definitions(CFXMLInterface PRIVATE -D_GNU_SOURCE) + + if(CMAKE_SYSTEM_NAME STREQUAL Linux) + include(CheckSymbolExists) + include(CheckIncludeFile) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) + check_include_file("sched.h" HAVE_SCHED_H) + if(HAVE_SCHED_H) + check_symbol_exists(sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY) + endif() + endif() + if(HAVE_SCHED_GETAFFINITY) target_compile_definitions(CoreFoundation PRIVATE