Skip to content

Commit

Permalink
CmakeLists.txt: Cleanup C function detection
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed Dec 10, 2017
1 parent 65d3ab1 commit ac96a4b
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,33 @@ endif()
#
# Look for C library functions
#
set(CMAKE_EXTRA_INCLUDE_FILES string.h)
check_function_exists(rawmemchr HAS_RAWMEMCHR)
set(HAS_RAWMEMCHR ${HAS_RAWMEMCHR})

set(CMAKE_EXTRA_INCLUDE_FILES stdlib.h)
check_function_exists(reallocarray HAS_REALLOCARRAY)
set(HAS_REALLOCARRAY ${HAS_REALLOCARRAY})
set(CMAKE_EXTRA_INCLUDE_FILES
fcntl.h
stdlib.h
sys/socket.h
sys/types.h
string.h
time.h
unistd.h
)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

check_function_exists(rawmemchr HAS_RAWMEMCHR)
check_function_exists(reallocarray HAS_REALLOCARRAY)
check_function_exists(mempcpy HAS_MEMPCPY)
set(HAS_MEMPCPY ${HAS_MEMPCPY})

check_function_exists(memrchr HAS_MEMRCHR)
set(HAS_MEMRCHR ${HAS_MEMRCHR})

set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
check_function_exists(pipe2 HAS_PIPE2)
set(HAS_PIPE2 ${HAS_PIPE2})

set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h)
check_function_exists(accept4 HAS_ACCEPT4)
set(HAS_ACCEPT4 ${HAS_ACCEPT4})

set(CMAKE_EXTRA_INCLUDE_FILES fcntl.h)
check_function_exists(readahead HAS_READAHEAD)
set(HAS_READAHEAD ${HAS_READAHEAD})

check_function_exists(mkostemp HAS_MKOSTEMP)
set(HAS_MKOSTEMP ${HAS_MKOSTEMP})

set(CMAKE_EXTRA_INCLUDE_FILES time.h)
check_function_exists(clock_gettime HAS_CLOCK_GETTIME)
check_function_exists(pthread_barrier_init HAS_PTHREADBARRIER)

if (NOT HAS_CLOCK_GETTIME AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND ADDITIONAL_LIBRARIES rt)
endif ()

set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
check_function_exists(pthread_barrier_init HAS_PTHREADBARRIER)


#
# Ensure compiler is compatible with GNU99 standard
Expand Down

0 comments on commit ac96a4b

Please sign in to comment.