"Fossies" - the Fresh Open Source Software Archive

Member "c-ares-1.17.2/CMakeLists.txt" (10 Aug 2021, 30600 Bytes) of package /linux/misc/dns/c-ares-1.17.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.17.1_vs_1.17.2.

    1 CMAKE_MINIMUM_REQUIRED (VERSION 3.1.0)
    2 
    3 INCLUDE (CheckIncludeFiles)
    4 INCLUDE (CheckTypeSize)
    5 INCLUDE (CheckFunctionExists)
    6 INCLUDE (CheckSymbolExists)
    7 INCLUDE (CheckCSourceCompiles)
    8 INCLUDE (CheckStructHasMember)
    9 INCLUDE (CheckLibraryExists)
   10 
   11 PROJECT (c-ares LANGUAGES C VERSION "1.17.2" )
   12 
   13 # Set this version before release
   14 SET (CARES_VERSION "1.17.2")
   15 
   16 INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are wrong.
   17 
   18 # This is for libtool compatibility, and specified in a form that is easily
   19 # translatable from libtool (even if the actual form doesn't make sense).
   20 # For instance, in an autotools project, in Makefile.am there is a line that
   21 # contains something like:
   22 #     -version-info 4:0:2
   23 # This breaks down into sections of current:revision:age
   24 # This then generates a version of  "(current-age).age.revision"  with an
   25 # interface version of "(current-age)"
   26 # For example, a version of 4:0:2 would generate output such as:
   27 #    libname.so   -> libname.so.2
   28 #    libname.so.2 -> libname.so.2.2.0
   29 SET (CARES_LIB_VERSIONINFO "6:3:4")
   30 
   31 
   32 OPTION (CARES_STATIC     "Build as a static library"                                             OFF)
   33 OPTION (CARES_SHARED     "Build as a shared library"                                             ON)
   34 OPTION (CARES_INSTALL    "Create installation targets (chain builders may want to disable this)" ON)
   35 OPTION (CARES_STATIC_PIC "Build the static library as PIC (position independent)"                OFF)
   36 OPTION (CARES_BUILD_TESTS "Build and run tests"                                                  OFF)
   37 OPTION (CARES_BUILD_CONTAINER_TESTS "Build and run container tests (implies CARES_BUILD_TESTS, Linux only)" OFF)
   38 OPTION (CARES_BUILD_TOOLS "Build tools"                                                          ON)
   39 
   40 # Tests require static to be enabled on Windows to be able to access otherwise hidden symbols
   41 IF (CARES_BUILD_TESTS AND (NOT CARES_STATIC) AND WIN32)
   42 	SET (CARES_STATIC ON)
   43 	SET (CARES_STATIC_PIC ON)
   44 	MESSAGE (WARNING "Static building was requested be disabled, but reenabled to support tests")
   45 ENDIF ()
   46 
   47 # allow linking against the static runtime library in msvc
   48 IF (MSVC)
   49 	OPTION (CARES_MSVC_STATIC_RUNTIME "Link against the static runtime library" OFF)
   50 	IF (CARES_MSVC_STATIC_RUNTIME)
   51 		# CMAKE_CONFIGURATION_TYPES is empty on non-IDE generators (Ninja, NMake)
   52 		# and that's why we also use CMAKE_BUILD_TYPE to cover for those generators.
   53 		# For IDE generators, CMAKE_BUILD_TYPE is usually empty
   54 		FOREACH (config_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
   55 			STRING (TOUPPER ${config_type} upper_config_type)
   56 			SET (flag_var "CMAKE_C_FLAGS_${upper_config_type}")
   57 			IF (${flag_var} MATCHES "/MD")
   58 				STRING (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
   59 			ENDIF ()
   60 		ENDFOREACH ()
   61 
   62 		# clean up
   63 		SET (upper_config_type)
   64 		SET (config_type)
   65 		SET (flag_var)
   66 	ENDIF ()
   67 ENDIF ()
   68 
   69 # Keep build organized.
   70 SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
   71 SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
   72 SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
   73 SET (PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package)
   74 
   75 # Destinations for installing different kinds of targets (pass to install command).
   76 SET (TARGETS_INST_DEST
   77 	RUNTIME DESTINATION  ${CMAKE_INSTALL_BINDIR}
   78 	BUNDLE DESTINATION   ${CMAKE_INSTALL_BINDIR}
   79 	LIBRARY DESTINATION  ${CMAKE_INSTALL_LIBDIR}
   80 	ARCHIVE DESTINATION  ${CMAKE_INSTALL_LIBDIR}
   81 )
   82 
   83 # Function in Library
   84 # CHECK_LIBRARY_EXISTS can't be used as it will return true if the function
   85 # is found in a different dependent library.
   86 MACRO (CARES_FUNCTION_IN_LIBRARY func lib var)
   87 	CHECK_FUNCTION_EXISTS ("${func}" "_CARES_FUNC_IN_LIB_GLOBAL_${func}")
   88 	IF ("${_CARES_FUNC_IN_LIB_GLOBAL_${func}}")
   89 		SET (${var} FALSE)
   90 	ELSE ()
   91 		CHECK_LIBRARY_EXISTS ("${lib}" "${func}" "" ${var})
   92 	ENDIF ()
   93 ENDMACRO ()
   94 
   95 # Look for dependent/required libraries
   96 CARES_FUNCTION_IN_LIBRARY (res_servicename resolv HAVE_RES_SERVICENAME_IN_LIBRESOLV)
   97 IF (HAVE_RES_SERVICENAME_IN_LIBRESOLV)
   98 	SET (HAVE_LIBRESOLV 1)
   99 ENDIF ()
  100 
  101 IF (APPLE)
  102 	CHECK_C_SOURCE_COMPILES ("
  103 	#include <stdio.h>
  104 	#include <TargetConditionals.h>
  105 	int main() {
  106 #if TARGET_OS_IPHONE == 0
  107 #error Not an iPhone target
  108 #endif
  109 return 0;
  110 	}
  111 	"
  112 	IOS)
  113 
  114 	CHECK_C_SOURCE_COMPILES ("
  115 #include <stdio.h>
  116 #include <TargetConditionals.h>
  117 	int main() {
  118 #if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
  119 #  error Not iOS v10
  120 #endif
  121 return 0;
  122 	}
  123 	"
  124 	IOS_V10)
  125 
  126 	CHECK_C_SOURCE_COMPILES ("
  127 #include <stdio.h>
  128 #include <AvailabilityMacros.h>
  129 #ifndef MAC_OS_X_VERSION_10_12
  130 #  define MAC_OS_X_VERSION_10_12 101200
  131 #endif
  132 	int main() {
  133 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
  134 #  error Not MacOSX 10.12 or higher
  135 #endif
  136 return 0;
  137 	}
  138 	"
  139 	MACOS_V1012)
  140 ENDIF ()
  141 
  142 IF ((IOS OR APPLE OR ZOS) AND HAVE_LIBRESOLV)
  143 	SET (CARES_USE_LIBRESOLV 1)
  144 ENDIF()
  145 
  146 
  147 CARES_FUNCTION_IN_LIBRARY (gethostbyname nsl HAVE_LIBNSL)
  148 CARES_FUNCTION_IN_LIBRARY (gethostbyname socket HAVE_GHBN_LIBSOCKET)
  149 CARES_FUNCTION_IN_LIBRARY (socket socket HAVE_SOCKET_LIBSOCKET)
  150 IF (HAVE_GHBN_LIBSOCKET OR HAVE_SOCKET_LIBSOCKET)
  151 	SET(HAVE_LIBSOCKET TRUE)
  152 ENDIF ()
  153 CARES_FUNCTION_IN_LIBRARY (clock_gettime rt HAVE_LIBRT)
  154 
  155 
  156 # Look for necessary includes
  157 CHECK_INCLUDE_FILES (sys/types.h           HAVE_SYS_TYPES_H)
  158 CHECK_INCLUDE_FILES (sys/socket.h          HAVE_SYS_SOCKET_H)
  159 CHECK_INCLUDE_FILES (arpa/inet.h           HAVE_ARPA_INET_H)
  160 CHECK_INCLUDE_FILES (arpa/nameser_compat.h HAVE_ARPA_NAMESER_COMPAT_H)
  161 CHECK_INCLUDE_FILES (arpa/nameser.h        HAVE_ARPA_NAMESER_H)
  162 CHECK_INCLUDE_FILES (assert.h              HAVE_ASSERT_H)
  163 CHECK_INCLUDE_FILES (errno.h               HAVE_ERRNO_H)
  164 CHECK_INCLUDE_FILES (fcntl.h               HAVE_FCNTL_H)
  165 CHECK_INCLUDE_FILES (inttypes.h            HAVE_INTTYPES_H)
  166 CHECK_INCLUDE_FILES (limits.h              HAVE_LIMITS_H)
  167 CHECK_INCLUDE_FILES (malloc.h              HAVE_MALLOC_H)
  168 CHECK_INCLUDE_FILES (memory.h              HAVE_MEMORY_H)
  169 CHECK_INCLUDE_FILES (netdb.h               HAVE_NETDB_H)
  170 CHECK_INCLUDE_FILES (netinet/in.h          HAVE_NETINET_IN_H)
  171 CHECK_INCLUDE_FILES (net/if.h              HAVE_NET_IF_H)
  172 CHECK_INCLUDE_FILES (signal.h              HAVE_SIGNAL_H)
  173 CHECK_INCLUDE_FILES (socket.h              HAVE_SOCKET_H)
  174 CHECK_INCLUDE_FILES (stdbool.h             HAVE_STDBOOL_H)
  175 CHECK_INCLUDE_FILES (stdint.h              HAVE_STDINT_H)
  176 CHECK_INCLUDE_FILES (stdlib.h              HAVE_STDLIB_H)
  177 CHECK_INCLUDE_FILES (strings.h             HAVE_STRINGS_H)
  178 CHECK_INCLUDE_FILES (string.h              HAVE_STRING_H)
  179 CHECK_INCLUDE_FILES (stropts.h             HAVE_STROPTS_H)
  180 CHECK_INCLUDE_FILES (sys/ioctl.h           HAVE_SYS_IOCTL_H)
  181 CHECK_INCLUDE_FILES (sys/param.h           HAVE_SYS_PARAM_H)
  182 CHECK_INCLUDE_FILES (sys/select.h          HAVE_SYS_SELECT_H)
  183 CHECK_INCLUDE_FILES (sys/stat.h            HAVE_SYS_STAT_H)
  184 CHECK_INCLUDE_FILES (sys/time.h            HAVE_SYS_TIME_H)
  185 CHECK_INCLUDE_FILES (sys/uio.h             HAVE_SYS_UIO_H)
  186 CHECK_INCLUDE_FILES (time.h                HAVE_TIME_H)
  187 CHECK_INCLUDE_FILES (dlfcn.h               HAVE_DLFCN_H)
  188 CHECK_INCLUDE_FILES (unistd.h              HAVE_UNISTD_H)
  189 
  190 # On OpenBSD, you must include sys/types.h before netinet/tcp.h
  191 IF (HAVE_SYS_TYPES_H)
  192   CHECK_INCLUDE_FILES ("sys/types.h;netinet/tcp.h"         HAVE_NETINET_TCP_H)
  193 ELSE ()
  194   CHECK_INCLUDE_FILES (netinet/tcp.h                       HAVE_NETINET_TCP_H)
  195 ENDIF ()
  196 
  197 # Include order matters for these windows files.
  198 CHECK_INCLUDE_FILES ("winsock2.h;windows.h"            HAVE_WINSOCK2_H)
  199 CHECK_INCLUDE_FILES ("winsock2.h;ws2tcpip.h;windows.h" HAVE_WS2TCPIP_H)
  200 CHECK_INCLUDE_FILES ("winsock.h;windows.h"             HAVE_WINSOCK_H)
  201 CHECK_INCLUDE_FILES (windows.h                         HAVE_WINDOWS_H)
  202 
  203 
  204 # Set system-specific compiler flags
  205 IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  206 	LIST (APPEND SYSFLAGS -D_DARWIN_C_SOURCE)
  207 ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
  208 	LIST (APPEND SYSFLAGS -D_GNU_SOURCE -D_POSIX_C_SOURCE=199309L -D_XOPEN_SOURCE=600)
  209 ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  210 	LIST (APPEND SYSFLAGS -D__EXTENSIONS__ -D_REENTRANT -D_XOPEN_SOURCE=600)
  211 ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX")
  212 	LIST (APPEND SYSFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_USE_IRS)
  213 ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  214 	# Don't define _XOPEN_SOURCE on FreeBSD, it actually reduces visibility instead of increasing it
  215 ELSEIF (WIN32)
  216 	LIST (APPEND SYSFLAGS -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0600)
  217 ENDIF ()
  218 ADD_DEFINITIONS(${SYSFLAGS})
  219 
  220 
  221 
  222 # Tell C-Ares about libraries to depend on
  223 IF (HAVE_LIBRESOLV)
  224 	LIST (APPEND CARES_DEPENDENT_LIBS resolv)
  225 ENDIF ()
  226 IF (HAVE_LIBNSL)
  227 	LIST (APPEND CARES_DEPENDENT_LIBS nsl)
  228 ENDIF ()
  229 IF (HAVE_LIBSOCKET)
  230 	LIST (APPEND CARES_DEPENDENT_LIBS socket)
  231 ENDIF ()
  232 IF (HAVE_LIBRT)
  233 	LIST (APPEND CARES_DEPENDENT_LIBS rt)
  234 ENDIF ()
  235 IF (WIN32)
  236 	LIST (APPEND CARES_DEPENDENT_LIBS ws2_32 Advapi32)
  237 ENDIF ()
  238 
  239 
  240 # When checking for symbols, we need to make sure we set the proper
  241 # headers, libraries, and definitions for the detection to work properly
  242 # CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES, and
  243 # CMAKE_EXTRA_INCLUDE_FILES.  When we're done with the detection, we'll
  244 # unset them.
  245 
  246 SET (CMAKE_REQUIRED_DEFINITIONS ${SYSFLAGS})
  247 LIST (APPEND CMAKE_REQUIRED_LIBRARIES ${CARES_DEPENDENT_LIBS})
  248 
  249 MACRO (CARES_EXTRAINCLUDE_IFSET var include)
  250 	IF (${var})
  251 		LIST (APPEND CMAKE_EXTRA_INCLUDE_FILES ${include})
  252 	ENDIF ()
  253 ENDMACRO ()
  254 
  255 CARES_EXTRAINCLUDE_IFSET (HAVE_STDBOOL_H      stdbool.h)
  256 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TYPES_H    sys/types.h)
  257 CARES_EXTRAINCLUDE_IFSET (HAVE_ARPA_INET_H    arpa/inet.h)
  258 CARES_EXTRAINCLUDE_IFSET (HAVE_ARPA_NAMESER_H arpa/nameser.h)
  259 CARES_EXTRAINCLUDE_IFSET (HAVE_NETDB_H        netdb.h)
  260 CARES_EXTRAINCLUDE_IFSET (HAVE_NET_IF_H       net/if.h)
  261 CARES_EXTRAINCLUDE_IFSET (HAVE_NETINET_IN_H   netinet/in.h)
  262 CARES_EXTRAINCLUDE_IFSET (HAVE_NETINET_TCP_H  netinet/tcp.h)
  263 CARES_EXTRAINCLUDE_IFSET (HAVE_SIGNAL_H       signal.h)
  264 CARES_EXTRAINCLUDE_IFSET (HAVE_STDLIB_H       stdlib.h)
  265 CARES_EXTRAINCLUDE_IFSET (HAVE_STRING_H       string.h)
  266 CARES_EXTRAINCLUDE_IFSET (HAVE_STRINGS_H      strings.h)
  267 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_IOCTL_H    sys/ioctl.h)
  268 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_SELECT_H   sys/select.h)
  269 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_SOCKET_H   sys/socket.h)
  270 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TIME_H     sys/time.h)
  271 CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_UIO_H      sys/uio.h)
  272 CARES_EXTRAINCLUDE_IFSET (HAVE_TIME_H         time.h)
  273 CARES_EXTRAINCLUDE_IFSET (HAVE_FCNTL_H        fcntl.h)
  274 CARES_EXTRAINCLUDE_IFSET (HAVE_UNISTD_H       unistd.h)
  275 CARES_EXTRAINCLUDE_IFSET (HAVE_WINSOCK2_H     winsock2.h)
  276 CARES_EXTRAINCLUDE_IFSET (HAVE_WS2TCPIP_H     ws2tcpip.h)
  277 CARES_EXTRAINCLUDE_IFSET (HAVE_WINDOWS_H      windows.h)
  278 
  279 # Check Types
  280 # CHECK_TYPE_SIZE can't be used to see if a type exists because on Apple when
  281 # building multi-arch, it will throw an error.  So we need to wrap
  282 # CHECK_C_SOURCE_COMPILES for our tests.
  283 MACRO (CARES_TYPE_EXISTS type var)
  284 	SET(_CARES_C_SOURCE "
  285 		#include <stdio.h>
  286 		#include <stdlib.h>
  287 	")
  288 	FOREACH(_C_HEADER ${CMAKE_EXTRA_INCLUDE_FILES})
  289 		SET(_CARES_C_SOURCE "${_CARES_C_SOURCE}
  290 		#include <${_C_HEADER}>")
  291 	ENDFOREACH(_C_HEADER)
  292 
  293 	SET(_CARES_C_SOURCE "${_CARES_C_SOURCE}
  294 		int main() {
  295 			${type} var_exists;
  296 			(void)var_exists;
  297 			return 0;
  298 		}
  299 	")
  300 	CHECK_C_SOURCE_COMPILES ("${_CARES_C_SOURCE}" ${var})
  301 ENDMACRO ()
  302 
  303 CARES_TYPE_EXISTS (socklen_t                 HAVE_SOCKLEN_T)
  304 CARES_TYPE_EXISTS (SOCKET                    HAVE_TYPE_SOCKET)
  305 CARES_TYPE_EXISTS (bool                      HAVE_BOOL_T)
  306 CARES_TYPE_EXISTS (ssize_t                   HAVE_SSIZE_T)
  307 CARES_TYPE_EXISTS ("long long"               HAVE_LONGLONG)
  308 CARES_TYPE_EXISTS (sig_atomic_t              HAVE_SIG_ATOMIC_T)
  309 CARES_TYPE_EXISTS ("struct addrinfo"         HAVE_STRUCT_ADDRINFO)
  310 CARES_TYPE_EXISTS ("struct in6_addr"         HAVE_STRUCT_IN6_ADDR)
  311 CARES_TYPE_EXISTS ("struct sockaddr_in6"     HAVE_STRUCT_SOCKADDR_IN6)
  312 CARES_TYPE_EXISTS ("struct sockaddr_storage" HAVE_STRUCT_SOCKADDR_STORAGE)
  313 CARES_TYPE_EXISTS ("struct timeval"          HAVE_STRUCT_TIMEVAL)
  314 
  315 
  316 # Check for preprocessor defines
  317 CHECK_SYMBOL_EXISTS (AF_INET6        "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_AF_INET6)
  318 CHECK_SYMBOL_EXISTS (O_NONBLOCK      "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_O_NONBLOCK)
  319 CHECK_SYMBOL_EXISTS (FIONBIO         "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FIONBIO)
  320 CHECK_SYMBOL_EXISTS (SIOCGIFADDR     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTL_SIOCGIFADDR)
  321 CHECK_SYMBOL_EXISTS (MSG_NOSIGNAL    "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_MSG_NOSIGNAL)
  322 CHECK_SYMBOL_EXISTS (PF_INET6        "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_PF_INET6)
  323 CHECK_SYMBOL_EXISTS (SO_NONBLOCK     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SO_NONBLOCK)
  324 
  325 # XCode v8 bug: iOS when targeting less than v10, or MacOS when targeting less than v10.12 will
  326 # say clock_gettime exists, it is a weak symbol that only exists in iOS10/MacOS10.12 and will
  327 # cause a crash at runtime when running on older versions.  Skip finding CLOCK_MONOTONIC on older
  328 # OS's.
  329 IF ((NOT APPLE) OR IOS_V10 OR MACOS_V1012)
  330 	CHECK_SYMBOL_EXISTS (CLOCK_MONOTONIC "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOCK_GETTIME_MONOTONIC)
  331 ENDIF ()
  332 
  333 CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_scope_id "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID LANGUAGE C)
  334 
  335 # Check for "LL" numeric suffix support
  336 CHECK_C_SOURCE_COMPILES ("int main() { int n=1234LL; return 0; }" HAVE_LL)
  337 
  338 
  339 CHECK_SYMBOL_EXISTS (bitncmp         "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_BITNCMP)
  340 CHECK_SYMBOL_EXISTS (closesocket     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET)
  341 CHECK_SYMBOL_EXISTS (CloseSocket     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET_CAMEL)
  342 CHECK_SYMBOL_EXISTS (connect         "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONNECT)
  343 CHECK_SYMBOL_EXISTS (fcntl           "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FCNTL)
  344 CHECK_SYMBOL_EXISTS (freeaddrinfo    "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FREEADDRINFO)
  345 CHECK_SYMBOL_EXISTS (getaddrinfo     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETADDRINFO)
  346 CHECK_SYMBOL_EXISTS (getenv          "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETENV)
  347 CHECK_SYMBOL_EXISTS (gethostbyaddr   "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTBYADDR)
  348 CHECK_SYMBOL_EXISTS (gethostbyname   "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTBYNAME)
  349 CHECK_SYMBOL_EXISTS (gethostname     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTNAME)
  350 CHECK_SYMBOL_EXISTS (getnameinfo     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETNAMEINFO)
  351 CHECK_SYMBOL_EXISTS (getservbyport_r "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETSERVBYPORT_R)
  352 CHECK_SYMBOL_EXISTS (getservbyname_r "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETSERVBYNAME_R)
  353 CHECK_SYMBOL_EXISTS (gettimeofday    "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETTIMEOFDAY)
  354 CHECK_SYMBOL_EXISTS (if_indextoname  "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_INDEXTONAME)
  355 CHECK_SYMBOL_EXISTS (inet_net_pton   "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NET_PTON)
  356 IF (NOT WIN32)
  357 	# Disabled on Windows, because these functions are only really supported on Windows
  358 	# Vista or newer (_WIN32_WINNT >= 0x0600). Older versions of Windows may provide
  359 	# them as experimental non-working features, so we have to disable them manually.
  360 	CHECK_SYMBOL_EXISTS (inet_ntop       "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NTOP)
  361 	CHECK_SYMBOL_EXISTS (inet_pton       "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_PTON)
  362 ENDIF ()
  363 CHECK_SYMBOL_EXISTS (ioctl           "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTL)
  364 CHECK_SYMBOL_EXISTS (ioctlsocket     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTLSOCKET)
  365 CHECK_SYMBOL_EXISTS (IoctlSocket     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTLSOCKET_CAMEL)
  366 CHECK_SYMBOL_EXISTS (recv            "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_RECV)
  367 CHECK_SYMBOL_EXISTS (recvfrom        "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_RECVFROM)
  368 CHECK_SYMBOL_EXISTS (send            "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SEND)
  369 CHECK_SYMBOL_EXISTS (setsockopt      "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SETSOCKOPT)
  370 CHECK_SYMBOL_EXISTS (socket          "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKET)
  371 CHECK_SYMBOL_EXISTS (strcasecmp      "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRCASECMP)
  372 CHECK_SYMBOL_EXISTS (strcmpi         "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRCMPI)
  373 CHECK_SYMBOL_EXISTS (strdup          "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRDUP)
  374 CHECK_SYMBOL_EXISTS (stricmp         "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRICMP)
  375 CHECK_SYMBOL_EXISTS (strncasecmp     "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCASECMP)
  376 CHECK_SYMBOL_EXISTS (strncmpi        "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCMPI)
  377 CHECK_SYMBOL_EXISTS (strnicmp        "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNICMP)
  378 CHECK_SYMBOL_EXISTS (writev          "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_WRITEV)
  379 
  380 # On Android, the system headers may define __system_property_get(), but excluded
  381 # from libc.  We need to perform a link test instead of a header/symbol test.
  382 CHECK_FUNCTION_EXISTS (__system_property_get HAVE___SYSTEM_PROPERTY_GET)
  383 
  384 # Unset temporary data
  385 SET (CMAKE_EXTRA_INCLUDE_FILES)
  386 SET (CMAKE_REQUIRED_DEFINITIONS)
  387 SET (CMAKE_REQUIRED_LIBRARIES)
  388 
  389 
  390 find_file(CARES_RANDOM_FILE urandom /dev)
  391 mark_as_advanced(CARES_RANDOM_FILE)
  392 
  393 
  394 ################################################################################
  395 # recv, recvfrom, send, getnameinfo, gethostname
  396 # ARGUMENTS AND RETURN VALUES
  397 #
  398 # The AutoTools build tries to be really thorough here.  So much so that it
  399 # takes forever.  We really don't want to do that.  Lets make some educated
  400 # guesses based on datatypes we have available, and for others, use some 'sane'
  401 # defaults.  This should be much quicker and nearly as accurate ... and even
  402 # if not, it probably won't matter in the least.
  403 
  404 IF (HAVE_SSIZE_T AND HAVE_SOCKLEN_T)
  405 	# If we have ssize_t and socklen_t, the API is usually sane and uses ssize_t and size_t for lengths
  406 	SET (RECVFROM_TYPE_RETV ssize_t)
  407 	SET (RECVFROM_TYPE_ARG3 size_t)
  408 ELSE ()
  409 	SET (RECVFROM_TYPE_RETV int)
  410 	SET (RECVFROM_TYPE_ARG3 int)
  411 ENDIF ()
  412 
  413 IF (HAVE_TYPE_SOCKET)
  414 	# If the SOCKET type is defined, it uses socket ... should be windows only
  415 	SET (RECVFROM_TYPE_ARG1 SOCKET)
  416 ELSE ()
  417 	SET (RECVFROM_TYPE_ARG1 int)
  418 ENDIF()
  419 
  420 IF (HAVE_SOCKLEN_T)
  421 	# If we have socklen_t the APIs pretty much always actually use it
  422 	SET (RECVFROM_TYPE_ARG6 "socklen_t *")
  423 	SET (GETNAMEINFO_TYPE_ARG2 socklen_t)
  424 	SET (GETNAMEINFO_TYPE_ARG46 socklen_t)
  425 ELSE ()
  426 	SET (RECVFROM_TYPE_ARG6 "int *")
  427 	SET (GETNAMEINFO_TYPE_ARG2 int)
  428 	SET (GETNAMEINFO_TYPE_ARG46 int)
  429 ENDIF ()
  430 
  431 IF (WIN32)
  432 	SET (RECV_TYPE_ARG2 "char *")
  433 ELSE ()
  434 	SET (RECV_TYPE_ARG2 "void *")
  435 ENDIF ()
  436 
  437 # Functions are typically consistent so the equivalent fields map ... equivalently
  438 SET (RECV_TYPE_RETV ${RECVFROM_TYPE_RETV})
  439 SET (SEND_TYPE_RETV ${RECVFROM_TYPE_RETV})
  440 SET (RECV_TYPE_ARG1 ${RECVFROM_TYPE_ARG1})
  441 SET (RECVFROM_TYPE_ARG2 ${RECV_TYPE_ARG2})
  442 SET (SEND_TYPE_ARG1 ${RECVFROM_TYPE_ARG1})
  443 SET (RECV_TYPE_ARG3 ${RECVFROM_TYPE_ARG3})
  444 SET (SEND_TYPE_ARG3 ${RECVFROM_TYPE_ARG3})
  445 SET (GETHOSTNAME_TYPE_ARG2 ${RECVFROM_TYPE_ARG3})
  446 
  447 # These should always be "sane" values to use always
  448 SET (RECVFROM_QUAL_ARG5 )
  449 SET (RECVFROM_TYPE_ARG4 int)
  450 SET (RECVFROM_TYPE_ARG5 "struct sockaddr *")
  451 SET (RECV_TYPE_ARG4 int)
  452 SET (GETNAMEINFO_TYPE_ARG1 "struct sockaddr *")
  453 SET (GETNAMEINFO_TYPE_ARG7 int)
  454 SET (SEND_TYPE_ARG2 "void *")
  455 SET (SEND_TYPE_ARG4 int)
  456 ################################################################################
  457 
  458 
  459 # HAVE_CXX11  ??
  460 # HAVE_SIG_ATOMIC_T_VOLATILE  ??
  461 
  462 
  463 # Set a few variables by hand that C-Ares wants, logically, based on detection
  464 # data.
  465 
  466 IF (HAVE_SOCKLEN_T)
  467 	Set (CARES_TYPEOF_ARES_SOCKLEN_T "socklen_t")
  468 ELSE ()
  469 	Set (CARES_TYPEOF_ARES_SOCKLEN_T "int")
  470 ENDIF ()
  471 
  472 IF (HAVE_SSIZE_T)
  473 	Set (CARES_TYPEOF_ARES_SSIZE_T "ssize_t")
  474 ELSE ()
  475 	IF (WIN32)
  476 		IF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  477 			Set (CARES_TYPEOF_ARES_SSIZE_T "__int64")
  478 		ELSE ()
  479 			Set (CARES_TYPEOF_ARES_SSIZE_T "int")
  480 		ENDIF ()
  481 	ELSE ()
  482 		Set (CARES_TYPEOF_ARES_SSIZE_T "long")
  483 	ENDIF ()
  484 ENDIF ()
  485 
  486 IF (HAVE_FCNTL AND HAVE_O_NONBLOCK)
  487 	SET (HAVE_FCNTL_O_NONBLOCK 1)
  488 ENDIF ()
  489 
  490 IF (HAVE_IOCTL AND HAVE_FIONBIO)
  491 	SET (HAVE_IOCTL_FIONBIO 1)
  492 ENDIF ()
  493 
  494 IF (HAVE_IOCTLSOCKET AND HAVE_FIONBIO)
  495 	SET (HAVE_IOCTLSOCKET_FIONBIO 1)
  496 ENDIF ()
  497 
  498 IF (HAVE_IOCTLSOCKET_CAMEL AND HAVE_FIONBIO)
  499 	SET (HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1)
  500 ENDIF ()
  501 
  502 IF (HAVE_GETADDRINFO)
  503 	IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
  504 		CMAKE_SYSTEM_NAME STREQUAL "HPUX" OR
  505 		CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
  506 		CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR
  507 		CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
  508 		CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
  509 		WIN32)
  510 			SET (HAVE_GETADDRINFO_THREADSAFE 1)
  511 	ENDIF ()
  512 ENDIF ()
  513 
  514 IF (HAVE_TIME_H AND HAVE_SYS_TIME_H)
  515 	SET (TIME_WITH_SYS_TIME 1)
  516 ENDIF ()
  517 
  518 IF (HAVE_GETSERVBYPORT_R)
  519 	# TODO : Should probably autodetect
  520 	IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  521 		SET (GETSERVBYPORT_R_ARGS 5)
  522 	ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
  523 		CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
  524 		SET (GETSERVBYPORT_R_ARGS 4)
  525 	ELSE ()
  526 		# Probably linux
  527 		SET (GETSERVBYPORT_R_ARGS 6)
  528 	ENDIF ()
  529 ENDIF ()
  530 
  531 IF (HAVE_GETSERVBYNAME_R)
  532 	# TODO : Should probably autodetect
  533 	IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  534 		SET (GETSERVBYNAME_R_ARGS 5)
  535 	ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
  536 		CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
  537 		SET (GETSERVBYNAME_R_ARGS 4)
  538 	ELSE ()
  539 		# Probably linux
  540 		SET (GETSERVBYNAME_R_ARGS 6)
  541 	ENDIF ()
  542 ENDIF ()
  543 
  544 # Set some aliases used for ares_build.h
  545 IF (HAVE_SYS_TYPES_H)
  546 	SET (CARES_HAVE_SYS_TYPES_H 1)
  547 ENDIF ()
  548 IF (HAVE_SYS_SOCKET_H)
  549 	SET (CARES_HAVE_SYS_SOCKET_H 1)
  550 ENDIF()
  551 IF (HAVE_WS2TCPIP_H)
  552 	SET (CARES_HAVE_WS2TCPIP_H 1)
  553 ENDIF()
  554 IF (HAVE_WINSOCK2_H)
  555 	SET (CARES_HAVE_WINSOCK2_H 1)
  556 ENDIF()
  557 IF (HAVE_WINDOWS_H)
  558 	SET (CARES_HAVE_WINDOWS_H 1)
  559 ENDIF()
  560 
  561 # Record toplevel CMakeLists.txt path
  562 set(CARES_TOPLEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
  563 
  564 
  565 # TRANSFORM_MAKEFILE_INC
  566 #
  567 # This function consumes the "Makefile.inc" autotools file, and converts it into
  568 #  "Makefile.inc.cmake", a cmake include file; transforming this:
  569 #
  570 # CSOURCES = ares__close_sockets.c	\
  571 #   ares__get_hostent.c			\
  572 #   ares__read_line.c			\
  573 #   ...
  574 #
  575 #   into this:
  576 #
  577 # SET (CSOURCES
  578 # 	ares__close_sockets.c
  579 # 	ares__get_hostent.c
  580 # 	ares__read_line.c
  581 #	...
  582 function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
  583 	file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
  584 	string(REPLACE "$(top_srcdir)"   "\${PROJECT_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  585 	string(REPLACE "$(top_builddir)" "\${PROJECT_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  586 
  587 	string(REGEX REPLACE "\\\\\n" "ß!ß" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  588 	string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  589 	string(REPLACE "ß!ß" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
  590 
  591 	string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})    # Replace $() with ${}
  592 	string(REGEX REPLACE "@([a-zA-Z_][a-zA-Z0-9_]*)@" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})    # Replace @@ with ${}, even if that may not be read by CMake scripts.
  593 	file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
  594 endfunction()
  595 
  596 # Directory for includes
  597 ADD_SUBDIRECTORY (include)
  598 
  599 # Directory for lib and tools
  600 ADD_SUBDIRECTORY (src)
  601 
  602 # Docs
  603 ADD_SUBDIRECTORY (docs)
  604 
  605 # Tests
  606 IF (CARES_BUILD_TESTS OR CARES_BUILD_CONTAINER_TESTS)
  607 	ENABLE_TESTING ()
  608 	ADD_SUBDIRECTORY (test)
  609 ENDIF ()
  610 
  611 
  612 # Export targets
  613 IF (CARES_INSTALL)
  614 	SET (CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
  615 	INCLUDE (CMakePackageConfigHelpers)
  616 	CONFIGURE_PACKAGE_CONFIG_FILE (${PROJECT_NAME}-config.cmake.in ${PROJECT_NAME}-config.cmake
  617 		INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
  618 		PATH_VARS CMAKE_INSTALL_INCLUDEDIR
  619 		NO_CHECK_REQUIRED_COMPONENTS_MACRO
  620 	)
  621 
  622 	WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_NAME}-config-version.cmake VERSION "${CARES_VERSION}" COMPATIBILITY SameMajorVersion)
  623 	INSTALL (EXPORT ${PROJECT_NAME}-targets COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ${PROJECT_NAME}::)
  624 	INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR})
  625 
  626 	# pkgconfig support
  627 	IF (NOT CARES_SHARED)
  628 		SET (CPPFLAG_CARES_STATICLIB "-DCARES_STATICLIB")
  629 		FOREACH (LIB ${CARES_DEPENDENT_LIBS})
  630 			SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}")
  631 		ENDFOREACH ()
  632 	ENDIF ()
  633 	CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY)
  634 	INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
  635 ENDIF ()
  636 
  637 
  638 # Legacy chain-building variables (provided for compatibility with old code).
  639 # Don't use these, external code should be updated to refer to the aliases directly (e.g., Cares::cares).
  640 SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND")
  641 SET (CARES_LIBRARIES ${PROJECT_NAME}::cares CACHE INTERNAL "CARES LIBRARIES")
  642 
  643 
  644 IF (CARES_INSTALL)
  645     # Package creation
  646     set( CPACK_PACKAGE_NAME ${PROJECT_NAME} )
  647     set( CPACK_PACKAGE_VENDOR "Daniel Stenberg" ) # Github project owner
  648     set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "A C library for asynchronous DNS requests" )
  649     set( CPACK_PACKAGE_HOMEPAGE_URL "https://c-ares.haxx.se/" )
  650     set( CPACK_PACKAGE_CONTACT      "https://c-ares.haxx.se/" )
  651     set( CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} )
  652     set( CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR} )
  653     set( CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH} )
  654     set( CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
  655     set( CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME} )
  656     set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" )
  657     set( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md" )
  658 
  659     set( CPACK_COMPONENT_Library_DISPLAY_NAME "c-ares Library" )
  660     set( CPACK_COMPONENT_Library_DESCRIPTION "The c-ares binary library." )
  661     set( CPACK_COMPONENT_Library_REQUIRED 1 )
  662     set( CPACK_COMPONENT_Devel_DISPLAY_NAME "c-ares Development Files" )
  663     set( CPACK_COMPONENT_Devel_DESCRIPTION "Development files for compiling against c-ares." )
  664     set( CPACK_COMPONENT_Devel_REQUIRED 0 )
  665     IF (CARES_BUILD_TOOLS)
  666         set( CPACK_COMPONENT_Tools_DISPLAY_NAME "c-ares Tools" )
  667         set( CPACK_COMPONENT_Tools_DESCRIPTION "Tools for using c-ares." )
  668         set( CPACK_COMPONENT_Tools_REQUIRED 0 )
  669     ENDIF ()
  670 
  671     if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
  672 
  673         if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" )
  674             # Note: the architecture should default to the local architecture, but it
  675             # in fact comes up empty.  We call `uname -m` to ask the kernel instead.
  676             EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE )
  677         endif()
  678 
  679         set( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1 )
  680         set( CPACK_PACKAGE_RELEASE 1 )
  681 
  682 
  683         # RPM - https://cmake.org/cmake/help/latest/cpack_gen/rpm.html
  684         set( CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} )
  685         set( CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} )
  686         set( CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} )
  687         set( CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_HOMEPAGE_URL} )
  688         set( CPACK_RPM_PACKAGE_LICENSE "MIT" )
  689         set( CPACK_RPM_COMPONENT_INSTALL 1 )
  690         set( CPACK_RPM_COMPRESSION_TYPE "xz" )
  691         set( CPACK_RPM_PACKAGE_AUTOPROV 1 )
  692 
  693         set( CPACK_RPM_Library_PACKAGE_SUMMARY ${CPACK_COMPONENT_Library_DESCRIPTION} )
  694         set( CPACK_RPM_Library_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE} )
  695         set( CPACK_RPM_Library_PACKAGE_NAME "libcares${CARES_LIB_VERSION_MAJOR}" )
  696         set( CPACK_RPM_Library_FILE_NAME "RPM-DEFAULT" )
  697 
  698         set( CPACK_RPM_Devel_PACKAGE_REQUIRES "cmake >= ${CMAKE_MINIMUM_REQUIRED_VERSION}, ${CPACK_RPM_Library_PACKAGE_NAME} >= ${CPACK_PACKAGE_VERSION}" )
  699         set( CPACK_RPM_Devel_PACKAGE_SUMMARY ${CPACK_COMPONENT_Devel_DESCRIPTION} )
  700         set( CPACK_RPM_Devel_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE} )
  701         set( CPACK_RPM_Devel_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-devel" )
  702         set( CPACK_RPM_Devel_FILE_NAME "RPM-DEFAULT" )
  703 
  704         IF (CARES_BUILD_TOOLS)
  705             set( CPACK_RPM_Tools_PACKAGE_REQUIRES "${CPACK_RPM_Library_PACKAGE_NAME} >= ${CPACK_PACKAGE_VERSION}" )
  706             set( CPACK_RPM_Tools_PACKAGE_SUMMARY ${CPACK_COMPONENT_Tools_DESCRIPTION} )
  707             set( CPACK_RPM_Tools_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE} )
  708             set( CPACK_RPM_Tools_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-tools" )
  709             set( CPACK_RPM_Tools_FILE_NAME "RPM-DEFAULT" )
  710         ENDIF ()
  711 
  712 
  713         # DEB - https://cmake.org/cmake/help/latest/cpack_gen/deb.html
  714         set( CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} )
  715         set( CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL} )
  716         set( CPACK_DEB_COMPONENT_INSTALL 1 )
  717         set( CPACK_DEBIAN_COMPRESSION_TYPE "xz")
  718         set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS 1 )
  719 
  720         if ( ${CPACK_PACKAGE_ARCHITECTURE} STREQUAL "x86_64" )
  721             set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" )  # DEB doesn't always use the kernel's arch name
  722         else()
  723             set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} )
  724         endif()
  725 
  726         set( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) # Use default naming scheme
  727 
  728         set( CPACK_DEBIAN_LIBRARY_PACKAGE_NAME ${CPACK_RPM_Library_PACKAGE_NAME} )
  729 
  730         set( CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS "cmake (>= ${CMAKE_MINIMUM_REQUIRED_VERSION}), ${CPACK_DEBIAN_LIBRARY_PACKAGE_NAME} (>= ${CPACK_PACKAGE_VERSION})" )
  731         set( CPACK_DEBIAN_DEVEL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev" )
  732 
  733         IF (CARES_BUILD_TOOLS)
  734             set( CPACK_DEBIAN_TOOLS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-tools" )
  735             set( CPACK_DEBIAN_TOOLS_PACKAGE_SHLIBDEPS OFF ) # dpkg-shlibdeps can't find the libs we built
  736             set( CPACK_DEBIAN_TOOLS_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIBRARY_PACKAGE_NAME} (>= ${CPACK_PACKAGE_VERSION})" )
  737         ENDIF ()
  738 
  739     elseif( ${CMAKE_HOST_WIN32} )
  740         set( CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON )
  741         set( CPACK_NSIS_DISPLAY_NAME ${PROJECT_NAME} )
  742         set( CPACK_NSIS_PACKAGE_NAME ${PROJECT_NAME} )
  743         set( CPACK_NSIS_URL_INFO_ABOUT ${CPACK_PACKAGE_HOMEPAGE_URL} )
  744     endif()
  745 
  746     # This must always be last!
  747     include( CPack )
  748 ENDIF ()