The compile test would fail on certain systems due to usage of uninitialized variable. Amends 4a46ba1209907796f4a14f6feb35ed4d70155d7d Fixes: QTBUG-120141 Pick-to: 6.6 Change-Id: I4ebbd9dcc820a26c4f8cec0460c5dacbd85c4d4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 75964763660cb131a0afe7b0bc051fd901939821) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
54 lines
1.4 KiB
CMake
54 lines
1.4 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 **argv)
|
|
{
|
|
res_state statep = 0;
|
|
int n = res_nmkquery(statep, 0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
|
|
n = res_nsend(statep, NULL, 0, NULL, 0);
|
|
n = dn_expand(NULL, NULL, NULL, NULL, 0);
|
|
return n;
|
|
}
|
|
" HAVE_LIBRESOLV_FUNCTIONS)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
if(HAVE_LIBRESOLV_FUNCTIONS)
|
|
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)
|