ClickHouse/contrib/libpoco/Net/cmake/test_anl.cmake

35 lines
892 B
CMake
Raw Normal View History

#
# On ubuntu 16.10 static link libanl.a fails with -fPIC error
#
2017-01-11 10:53:30 +00:00
include (CheckCXXSourceRuns)
find_package (Threads)
if (USE_STATIC_LIBRARIES)
2017-01-11 10:53:30 +00:00
set (ANL_LIB_NAME "libanl.a")
else ()
set(ANL_LIB_NAME "anl")
2017-01-11 10:53:30 +00:00
endif ()
2017-01-11 10:53:30 +00:00
find_library (ANL_LIB NAMES ${ANL_LIB_NAME})
2017-01-11 13:14:41 +00:00
# better use Threads::Threads but incompatible with cmake < 3
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if (ANL_LIB)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ANL_LIB})
endif ()
check_cxx_source_runs("
#include <netdb.h>
2017-01-11 10:53:30 +00:00
int main() {
getaddrinfo_a(GAI_NOWAIT, nullptr, 0, nullptr);
return 0;
}
" HAVE_GETADDRINFO_A)
#message(STATUS "test_anl: USE_STATIC_LIBRARIES=${USE_STATIC_LIBRARIES} ANL_LIB_NAME=${ANL_LIB_NAME} ANL_LIB=${ANL_LIB} HAVE_GETADDRINFO_A=${HAVE_GETADDRINFO_A}")
if (HAVE_GETADDRINFO_A)
2017-01-11 10:53:30 +00:00
add_definitions (-DHAVE_GETADDRINFO_A=1)
endif ()