68b625901f
There's little need for us to dynamically load it. The reasons why that was necessary aren't in the public history (Qt 4.5 already had it[1]). I remember writing the code in 2007-2008, I just don't remember why. On modern Linux and FreeBSD, there's no libresolv.so any more and those symbols have been rolled up into libc.so. It's still necessary on Darwin systems, so this commit introduces WrapResolv. It also resolves the unity build issues relating to libresolv symbols. [1] https://code.qt.io/cgit/qt/qt.git/tree/src/network/kernel/qhostinfo_unix.cpp?h=v4.5.1 Task-number: QTBUG-109394 Change-Id: Ic5799e4d000b6c9395109e008780643bac52122b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
50 lines
1.2 KiB
CMake
50 lines
1.2 KiB
CMake
# Copyright (C) 2022 The Qt Company Ltd.
|
|
# Copyright (C) 2023 Intel Corpotation.
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# We can't create the same interface imported target multiple times, CMake will complain if we do
|
|
# that. This can happen if the find_package call is done in multiple different subdirectories.
|
|
if(TARGET WrapResolv::WrapResolv)
|
|
set(WrapResolv_FOUND ON)
|
|
return()
|
|
endif()
|
|
|
|
set(WrapResolv_FOUND OFF)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
include(CMakePushCheckState)
|
|
|
|
if(QNX)
|
|
find_library(LIBRESOLV socket)
|
|
else()
|
|
find_library(LIBRESOLV resolv)
|
|
endif()
|
|
|
|
cmake_push_check_state()
|
|
if(LIBRESOLV)
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRESOLV}")
|
|
endif()
|
|
|
|
check_cxx_source_compiles("
|
|
#include <netinet/in.h>
|
|
#include <resolv.h>
|
|
|
|
int main(int, char **)
|
|
{
|
|
res_init();
|
|
}
|
|
" HAVE_RES_INIT)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
if(HAVE_RES_INIT)
|
|
set(WrapResolv_FOUND ON)
|
|
add_library(WrapResolv::WrapResolv INTERFACE IMPORTED)
|
|
if(LIBRESOLV)
|
|
target_link_libraries(WrapResolv::WrapResolv INTERFACE "${LIBRESOLV}")
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(WrapResolv DEFAULT_MSG WrapResolv_FOUND)
|