OSDN Git Service

link function tests to socket and nsl libraries if found
authorIvailo Monev <xakepa10@gmail.com>
Sat, 18 Sep 2021 20:55:51 +0000 (23:55 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 18 Sep 2021 20:55:51 +0000 (23:55 +0300)
fixes getifaddrs() and accept4() function tests on OpenIndiana

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
CMakeLists.txt

index b6717c2..940e292 100644 (file)
@@ -420,6 +420,10 @@ else()
     message(FATAL_ERROR "Unknown CPU '${KATIE_PROCESSOR}'")
 endif()
 
+# only Solaris is known to have these
+find_library(SOCKET_LIBRARY NAMES socket)
+find_library(NSL_LIBRARY NAMES nsl)
+
 # used in components, tests and JavaScriptCore
 katie_check_header("cxxabi.h")
 katie_check_function(posix_memalign "stdlib.h")
@@ -429,13 +433,10 @@ katie_check_function(get_current_dir_name "unistd.h")
 katie_check_function(prctl "sys/prctl.h")
 katie_check_function(feenableexcept "fenv.h")
 katie_check_function(madvise "sys/mman.h")
-katie_check_function(getifaddrs "ifaddrs.h")
 katie_check_function(timegm "time.h")
 katie_check_function(inotify_init1 "sys/inotify.h")
 katie_check_function(kevent "sys/event.h")
 katie_check_function(pipe2 "unistd.h")
-katie_check_function(accept4 "sys/socket.h")
-katie_check_function(paccept "sys/socket.h")
 katie_check_function(getdomainname "unistd.h")
 katie_check_function(renameat2 "stdio.h")
 katie_check_struct(tm tm_gmtoff "time.h")
@@ -447,6 +448,26 @@ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
 katie_check_function(pthread_setname_np "pthread.h")
 cmake_reset_check_state()
 
+cmake_reset_check_state()
+set(socket_and_nls_libraries)
+if(SOCKET_LIBRARY)
+    set(socket_and_nls_libraries
+        ${socket_and_nls_libraries}
+        ${SOCKET_LIBRARY}
+    )
+endif()
+if(NSL_LIBRARY)
+    set(socket_and_nls_libraries
+        ${socket_and_nls_libraries}
+        ${NSL_LIBRARY}
+    )
+endif()
+set(CMAKE_REQUIRED_LIBRARIES ${socket_and_nls_libraries})
+katie_check_function(getifaddrs "ifaddrs.h")
+katie_check_function(accept4 "sys/socket.h")
+katie_check_function(paccept "sys/socket.h")
+cmake_reset_check_state()
+
 katie_check_proc(exe)
 katie_check_proc(cmdline)