Skip to content

Commit

Permalink
Attempt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky committed Sep 7, 2021
1 parent 3fd30b0 commit 3b97e05
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
# just check and igore the variable.
endif()

# We compile with -Werror, so we need to make sure these code fragments compile without warnings.
# Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors
# which are not distinguished from the test failing. So no error for that one.
# For clang-5.0 avoid errors like "unused variable 'err' [-Werror,-Wunused-variable]".
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wno-error=unused-value -Wno-error=unused-variable")
# We don't want to use deprecated APIs
check_c_compiler_flag("-Wdeprecated-declarations" "C_SUPPORTS_DEPRECATED_DECLARATIONS")
if(C_SUPPORTS_DEPRECATED_DECLARATIONS)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=deprecated-declarations")
endif()

# Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK,
# the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it.
# The compiler raises a warning when using an unsupported API, turn that into an error so check_symbol_exists()
# can correctly identify whether the API is supported on the target.
check_c_compiler_flag("-Wunguarded-availability" "C_SUPPORTS_WUNGUARDED_AVAILABILITY")
if(C_SUPPORTS_WUNGUARDED_AVAILABILITY)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wunguarded-availability")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability")
endif()

# in_pktinfo: Find whether this struct exists
Expand Down Expand Up @@ -671,7 +671,16 @@ check_symbol_exists(
time.h
HAVE_CLOCK_GETTIME_NSEC_NP)

check_library_exists(pthread pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK)
check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
check_library_exists(c pthread_create "" HAVE_PTHREAD_IN_LIBC)

if (HAVE_LIBPTHREAD)
set(PTHREAD_LIBRARY pthread)
elseif (HAVE_PTHREAD_IN_LIBC)
set(PTHREAD_LIBRARY c)
endif()

check_library_exists(${PTHREAD_LIBRARY} pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK)

check_symbol_exists(
futimes
Expand Down

0 comments on commit 3b97e05

Please sign in to comment.