2018-01-08 09:36:35 -06:00
cmake_minimum_required ( VERSION 3.5 FATAL_ERROR )
2019-10-17 11:22:51 -05:00
if ( POLICY CMP0075 )
cmake_policy ( SET CMP0075 NEW )
endif ( )
2018-01-08 09:36:35 -06:00
# The following must be set BEFORE doing project() or enable_language().
if ( NOT CMAKE_BUILD_TYPE )
message ( STATUS "No build type defined; defaulting to 'Debug'" )
set ( CMAKE_BUILD_TYPE "Debug" CACHE STRING
" T h e t y p e o f b u i l d . P o s s i b l e v a l u e s a r e : D e b u g , R e l e a s e , R e l W i t h D e b I n f o a n d M i n S i z e R e l . " )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 09:36:35 -06:00
set ( PACKAGE "getdns" )
set ( PACKAGE_NAME "getdns" )
2019-10-09 11:19:18 -05:00
set ( PACKAGE_VERSION "1.5.2" )
2018-01-08 09:36:35 -06:00
set ( PACKAGE_BUGREPORT "team@getdnsapi.net" )
2018-01-08 12:59:54 -06:00
set ( PACKAGE_URL "https://getdnsapi.net" )
2018-01-08 09:36:35 -06:00
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" )
set ( PACKAGE_TARNAME "${PACKAGE}-${PACKAGE_VERSION}" )
# Dont forget to put a dash in front of the release candidate!!!
# That is how it is done with semantic versioning!
set ( RELEASE_CANDIDATE "" )
set ( GETDNS_VERSION "${PACKAGE_VERSION}${RELEASE_CANDIDATE}" )
2019-10-09 11:19:18 -05:00
set ( GETDNS_NUMERIC_VERSION 0x01050200 )
2018-01-08 09:36:35 -06:00
set ( API_VERSION "December 2015" )
set ( API_NUMERIC_VERSION 0x07df0c00 )
2019-10-21 07:51:19 -05:00
# Version 11:2:1 in libtool-speak.
set ( GETDNS_VERSION_CURRENT 11 )
set ( GETDNS_VERSION_REVISION 2 )
set ( GETDNS_VERSION_AGE 1 )
2018-01-08 09:36:35 -06:00
2019-10-24 11:49:23 -05:00
project ( getdns VERSION ${ PACKAGE_VERSION } LANGUAGES C )
2019-10-25 09:54:57 -05:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" )
2019-10-24 11:49:23 -05:00
2019-10-14 03:44:28 -05:00
include ( CheckCSourceRuns )
2018-01-08 09:36:35 -06:00
include ( CheckFunctionExists )
include ( CheckIncludeFile )
2019-10-24 11:28:58 -05:00
include ( CheckLibraryExists )
2018-01-08 09:36:35 -06:00
include ( CheckSymbolExists )
include ( CheckTypeSize )
2019-10-24 11:28:58 -05:00
include ( CMakeDependentOption )
include ( CTest )
include ( GNUInstallDirs )
2019-10-14 03:47:03 -05:00
include ( TestBigEndian )
2018-01-08 09:36:35 -06:00
# Directories
if ( DEFINED CMAKE_INSTALL_FULL_RUNSTATEDIR )
set ( RUNSTATEDIR "${CMAKE_INSTALL_FULL_RUNSTATEDIR}" )
else ( )
set ( RUNSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" )
endif ( )
2019-10-24 05:57:34 -05:00
install ( DIRECTORY
2018-01-08 09:36:35 -06:00
D E S T I N A T I O N $ { R U N S T A T E D I R }
D I R E C T O R Y _ P E R M I S S I O N S
O W N E R _ R E A D O W N E R _ W R I T E O W N E R _ E X E C U T E
G R O U P _ R E A D G R O U P _ E X E C U T E
W O R L D _ R E A D W O R L D _ E X E C U T E
)
# Always have build dir as an include directory.
include_directories (
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
)
2018-01-12 10:34:23 -06:00
# Target Platform
2018-01-08 09:36:35 -06:00
if ( WIN32 OR MINGW OR MSYS OR CYGWIN )
set ( HOSTOS "windows" )
2018-01-12 10:34:23 -06:00
set ( GETDNS_ON_WINDOWS 1 )
2019-10-14 03:44:28 -05:00
set ( USE_WINSOCK 1 )
2018-01-08 09:36:35 -06:00
elseif ( APPLE )
set ( HOSTOS "macos" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DARWIN_C_SOURCE" )
elseif ( UNIX )
set ( HOSTOS "unix" )
2019-10-14 03:45:38 -05:00
if ( NOT ${ CMAKE_SYSTEM_NAME } STREQUAL "FreeBSD" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600" )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 09:36:35 -06:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
set ( LINUX 1 )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -D_DEFAULT_SOURCE" )
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Solaris" )
set ( SOLARIS 1 )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS_" )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 09:36:35 -06:00
endif ( )
2019-10-14 03:47:03 -05:00
test_big_endian ( TARGET_IS_BIG_ENDIAN )
set ( HAVE_TARGET_ENDIANNESS 1 )
2018-01-08 12:59:54 -06:00
# Options.
2019-10-24 05:05:26 -05:00
option ( ENABLE_SHARED "Build shared libraries." ON )
option ( ENABLE_STATIC "Build static libraries." ON )
2019-10-24 04:51:28 -05:00
if ( ( NOT ENABLE_SHARED ) AND ( NOT ENABLE_STATIC ) )
message ( FATAL_ERROR "You must build either static or shared libraries." )
endif ( )
2019-10-24 07:43:20 -05:00
option ( ENABLE_DEBUG_ALL "Enable all debugging messages." )
cmake_dependent_option ( ENABLE_DEBUG_REQ "Enable request debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_SCHED "Enable scheduling debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_STUB "Enable stub debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_DAEMON "Enable daemon debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_DNSSEC "Enable DNSSEC debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_SERVER "Enable server debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
cmake_dependent_option ( ENABLE_DEBUG_ANCHOR "Enable anchor debugging messages." OFF "NOT ENABLE_DEBUG_ALL" ON )
2019-10-24 08:21:25 -05:00
option ( ENABLE_SHA1 "Enable SHA1 RRSIG support." ON )
option ( ENABLE_SHA2 "Enable SHA256 and SHA512 RRSIG support." ON )
option ( ENABLE_GOST "Enable GOST support." ON )
option ( ENABLE_ECDSA "Enable ECDSA support." ON )
option ( ENABLE_DSA "Enable DSA support." ON )
option ( ENABLE_ED25519 "Enable ED25519 support." ON )
option ( ENABLE_ED448 "Enable ED448 support." ON )
2019-10-24 08:29:20 -05:00
option ( ENABLE_NATIVE_STUB_DNSSEC "Enable/disable native stub DNSSEC support." ON )
2019-10-24 11:40:37 -05:00
option ( ENABLE_STUB_ONLY "Restricts resolution modes to STUB." ON )
option ( ENABLE_UNBOUND_EVENT_API "Enable usage of libunbound's event API." ON )
2019-10-24 08:29:20 -05:00
2019-10-24 07:43:20 -05:00
# Above names chosen for user consistency. Now define substituted names.
set ( REQ_DEBUG ${ ENABLE_DEBUG_REQ } )
set ( SCHED_DEBUG ${ ENABLE_DEBUG_SCHED } )
set ( STUB_DEBUG ${ ENABLE_DEBUG_STUB } )
set ( DAEMON_DEBUG ${ ENABLE_DEBUG_DAEMON } )
set ( SEC_DEBUG ${ ENABLE_DEBUG_DNSSEC } )
set ( SERVER_DEBUG ${ ENABLE_DEBUG_SERVER } )
set ( ANCHOR_DEBUG ${ ENABLE_DEBUG_ANCHOR } )
2019-10-24 08:21:25 -05:00
set ( USE_SHA1 ${ ENABLE_SHA1 } )
set ( USE_SHA2 ${ ENABLE_SHA2 } )
set ( USE_GOST ${ ENABLE_GOST } )
set ( USE_ECDSA ${ ENABLE_ECDSA } )
set ( USE_DSA ${ ENABLE_DSA } )
set ( USE_ED25519 ${ ENABLE_ED25519 } )
set ( USE_ED448 ${ ENABLE_ED448 } )
2019-10-24 08:29:20 -05:00
set ( STUB_NATIVE_DNSSEC ${ ENABLE_NATIVE_STUB_DNSSEC } )
2019-10-24 07:43:20 -05:00
option ( ENABLE_DEBUG_KEEP_CONNECTIONS_OPEN "Disable connection idle timeout. Do not enable." )
mark_as_advanced ( ENABLE_DEBUG_KEEP_CONNECTIONS_OPEN )
set ( KEEP_CONNECTIONS_OPEN_DEBUG ${ ENABLE_DEBUG_KEEP_CONNECTIONS_OPEN } )
2019-10-24 05:57:16 -05:00
# Options variables.
2019-10-24 06:19:51 -05:00
string ( TIMESTAMP timestamp "%Y-%m-%dT%H:%M:%SZ" )
set ( CURRENT_DATE "${timestamp}" CACHE STRING "Current date of the compilation, set to fixed date for reproducible builds." )
2019-10-24 05:05:26 -05:00
set ( DNSSEC_ROADBLOCK_AVOIDANCE ON CACHE BOOL "Enable/disable DNSSEC roadblock avoidance." )
2019-10-24 05:15:41 -05:00
set ( FD_SETSIZE "" CACHE STRING "Set maximum file descriptor number that can be used by select." )
2019-10-24 05:05:26 -05:00
set ( MAX_UDP_BACKOFF 1000 CACHE STRING "Set the maximum number of messages that can be sent to other upstreams before the upstream which has previously timed out will be tried again." )
2019-10-24 05:57:16 -05:00
if ( WIN32 )
# BUG! Don't hardcode the Windows directory and drive.
set ( hostsfile "C:/Windows/System32/Drivers/etc/hosts" )
else ( )
set ( hostsfile "${CMAKE_INSTALL_FULL_SYSCONFDIR}/hosts" )
endif ( )
set ( PATH_HOSTS "${hostsfile}" CACHE STRING "Set the static table lookup for hostnames path." )
set ( PATH_RESOLVCONF "/etc/resolv.conf" CACHE STRING "Set the resolver configuration file path. Not used on Windows, where values are retrieved via GetNetworkParams()." )
set ( PATH_TRUST_ANCHOR_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/unbound/getdns-root.key" CACHE STRING "Default location of the trust anchor file." )
2019-10-24 05:05:26 -05:00
2019-10-24 08:29:20 -05:00
# Ensure option variables in config.h that get values from the above are
# defined, and so will actually appear in config.h.
2019-10-24 08:07:43 -05:00
set ( GETDNS_FN_HOSTS 1 )
set ( GETDNS_FN_RESOLVCONF 1 )
set ( TRUST_ANCHOR_FILE 1 )
set ( UDP_MAX_BACKOFF 1 )
2019-10-24 05:05:26 -05:00
# Options not exposed in autoconf.
2018-01-08 12:59:54 -06:00
set ( DRAFT_RRTYPES 1 )
set ( EDNS_COOKIE_OPCODE 10 )
set ( EDNS_COOKIE_ROLLOVER_TIME "(24*60*60)" )
2019-10-24 05:05:26 -05:00
set ( EDNS_PADDING_OPCODE 12 )
set ( MAX_CNAME_REFERRALS 100 )
set ( MAXIMUM_UPSTREAM_OPTION_SPACE 3000 )
2018-01-08 12:59:54 -06:00
2019-10-24 06:19:51 -05:00
# Values derived from options.
set ( GETDNS_COMPILATION_COMMENT "${PACKAGE_NAME} ${GETDNS_VERSION} configured on ${CURRENT_DATE} for the ${API_VERSION} version of the API" )
2018-01-08 09:36:35 -06:00
# Does the compiler accept the "format" attribute?
try_compile ( HAVE_ATTR_FORMAT
2018-01-08 12:59:54 -06:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / t e s t s / t e s t _ f o r m a t _ a t t r . c
2018-01-08 09:36:35 -06:00
)
# Does the compiler accept the "unused" attribute?
try_compile ( HAVE_ATTR_UNUSED
2018-01-08 12:59:54 -06:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / t e s t s / t e s t _ u n u s e d _ a t t r . c
2018-01-08 09:36:35 -06:00
)
# Compiler flags
2019-10-10 06:31:12 -05:00
if ( MSVC )
2019-10-14 03:44:28 -05:00
# The Visual Studio C compiler is C90 with some of C99 and C11.
# So full on warnings are not appropriate.
add_compile_options ( /W2 )
2019-10-17 11:21:58 -05:00
else ( )
2019-10-10 06:31:12 -05:00
add_compile_options ( -Wall -Wextra )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-10 06:31:12 -05:00
2019-10-14 03:44:28 -05:00
# Windows. Uh-oh.
2019-10-16 04:29:29 -05:00
set ( getdns_system_libs "" )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
set ( static_lib_suffix "" )
2019-10-14 03:44:28 -05:00
if ( DEFINED GETDNS_ON_WINDOWS )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
set ( static_lib_suffix "_static" )
2019-10-16 04:29:29 -05:00
list ( APPEND getdns_system_libs
2019-10-15 12:35:06 -05:00
" w s 2 _ 3 2 "
" c r y p t 3 2 "
" g d i 3 2 "
" i p h l p a p i "
)
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-14 03:44:28 -05:00
2018-01-08 09:36:35 -06:00
# Check for include files
check_include_file ( assert.h HAVE_ASSERT_H )
check_include_file ( inttypes.h HAVE_INTTYPES_H )
check_include_file ( limits.h HAVE_LIMITS_H )
check_include_file ( sys/limits.h HAVE_SYS_LIMITS_H )
check_include_file ( stdarg.h HAVE_STDARG_H )
check_include_file ( stdint.h HAVE_STDINT_H )
check_include_file ( stdio.h HAVE_STDIO_H )
check_include_file ( stdlib.h HAVE_STDLIB_H )
check_include_file ( string.h HAVE_STRING_H )
check_include_file ( time.h HAVE_TIME_H )
2018-01-12 10:34:23 -06:00
check_include_file ( unistd.h HAVE_UNISTD_H )
2018-01-08 09:36:35 -06:00
2019-10-09 11:19:18 -05:00
check_include_file ( fcntl.h HAVE_FCNTL_H )
2018-01-08 09:36:35 -06:00
check_include_file ( signal.h HAVE_SIGNAL_H )
check_include_file ( sys/poll.h HAVE_SYS_POLL_H )
check_include_file ( poll.h HAVE_POLL_H )
check_include_file ( resource.h HAVE_RESOURCE_H )
check_include_file ( sys/types.h HAVE_SYS_TYPES_H )
check_include_file ( sys/stat.h HAVE_SYS_STAT_H )
2019-10-15 10:41:29 -05:00
check_include_file ( endian.h HAVE_ENDIAN_H )
2018-01-08 09:36:35 -06:00
check_include_file ( netdb.h HAVE_NETDB_H )
2019-10-15 10:41:29 -05:00
check_include_file ( arpa/inet.h HAVE_ARPA_INET_H )
check_include_file ( netinet/in.h HAVE_NETINET_IN_H )
check_include_file ( sys/select.h HAVE_SYS_SELECT_H )
2018-01-08 09:36:35 -06:00
check_include_file ( sys/socket.h HAVE_SYS_SOCKET_H )
2019-10-15 10:41:29 -05:00
check_include_file ( sys/sysctl.h HAVE_SYS_SYSCTL_H )
2018-01-08 09:36:35 -06:00
check_include_file ( sys/time.h HAVE_SYS_TIME_H )
check_include_file ( sys/wait.h HAVE_SYS_WAIT_H )
check_include_file ( windows.h HAVE_WINDOWS_H )
check_include_file ( winsock.h HAVE_WINSOCK_H )
check_include_file ( winsock2.h HAVE_WINSOCK2_H )
check_include_file ( ws2tcpip.h HAVE_WS2TCPIP_H )
# Check for include declarations
2019-10-15 10:41:29 -05:00
check_symbol_exists ( getentropy unistd.h HAVE_DECL_GETENTROPY )
2019-10-14 03:44:28 -05:00
if ( DEFINED GETDNS_ON_WINDOWS )
2019-10-16 04:29:29 -05:00
set ( CMAKE_REQUIRED_LIBRARIES ${ getdns_system_libs } )
2019-10-14 03:44:28 -05:00
check_symbol_exists ( inet_pton ws2tcpip.h HAVE_DECL_INET_PTON )
check_symbol_exists ( inet_ntop ws2tcpip.h HAVE_DECL_INET_NTOP )
2019-10-17 11:21:58 -05:00
else ( )
2019-10-14 03:44:28 -05:00
check_symbol_exists ( inet_pton arpa/inet.h HAVE_DECL_INET_PTON )
check_symbol_exists ( inet_ntop arpa/inet.h HAVE_DECL_INET_NTOP )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:54:13 -05:00
check_symbol_exists ( mkstemp stdlib.h HAVE_DECL_MKSTEMP )
2018-01-08 09:36:35 -06:00
check_symbol_exists ( sigemptyset signal.h HAVE_DECL_SIGEMPTYSET )
check_symbol_exists ( sigfillset signal.h HAVE_DECL_SIGFILLSET )
check_symbol_exists ( sigaddset signal.h HAVE_DECL_SIGADDSET )
2018-01-08 12:59:54 -06:00
check_symbol_exists ( strptime time.h HAVE_DECL_STRPTIME )
2018-01-08 09:36:35 -06:00
# Check for functions
2019-10-09 11:19:18 -05:00
check_function_exists ( fcntl HAVE_FCNTL )
2019-10-15 10:41:29 -05:00
check_function_exists ( getauxval HAVE_GETAUXVAL )
2019-10-14 03:44:28 -05:00
check_function_exists ( gettimeofday HAVE_GETTIMEOFDAY )
2019-10-09 11:19:18 -05:00
check_function_exists ( ioctlsocket HAVE_IOCTLSOCKET )
2018-01-08 09:36:35 -06:00
check_function_exists ( sigemptyset HAVE_SIGEMPTYSET )
check_function_exists ( sigfillset HAVE_SIGFILLSET )
check_function_exists ( sigaddset HAVE_SIGADDSET )
2018-01-08 12:59:54 -06:00
check_function_exists ( strptime HAVE_STRPTIME )
2018-01-08 09:36:35 -06:00
# Check for types
check_type_size ( sigset_t SIGSET_T )
check_type_size ( _sigset_t _SIGSET_T )
# SSL library
2019-10-09 11:19:18 -05:00
find_package ( OpenSSL "1.0.2" REQUIRED )
2018-01-08 09:36:35 -06:00
set ( HAVE_SSL 1 )
2018-01-08 12:59:54 -06:00
set ( CMAKE_REQUIRED_INCLUDES ${ OPENSSL_INCLUDE_DIR } )
2018-01-08 09:36:35 -06:00
check_include_file ( openssl/ssl.h HAVE_OPENSSL_SSL_H )
check_include_file ( openssl/evp.h HAVE_OPENSSL_EVP_H )
check_include_file ( openssl/err.h HAVE_OPENSSL_ERR_H )
check_include_file ( openssl/rand.h HAVE_OPENSSL_RAND_H )
check_include_file ( openssl/conf.h HAVE_OPENSSL_CONF_H )
check_include_file ( openssl/engine.h HAVE_OPENSSL_ENGINE_H )
2019-10-10 06:30:50 -05:00
set ( CMAKE_REQUIRED_LIBRARIES ${ OPENSSL_LIBRARIES } )
check_function_exists ( DSA_SIG_set0 HAVE_DSA_SIG_SET0 )
check_function_exists ( DSA_set0_pqg HAVE_DSA_SET0_PQG )
check_function_exists ( DSA_set0_key HAVE_DSA_SET0_KEY )
check_function_exists ( RSA_set0_key HAVE_RSA_SET0_KEY )
check_function_exists ( EVP_md5 HAVE_EVP_MD5 )
check_function_exists ( EVP_sha1 HAVE_EVP_SHA1 )
check_function_exists ( EVP_sha224 HAVE_EVP_SHA224 )
check_function_exists ( EVP_sha256 HAVE_EVP_SHA256 )
check_function_exists ( EVP_sha384 HAVE_EVP_SHA384 )
check_function_exists ( EVP_sha512 HAVE_EVP_SHA512 )
check_function_exists ( EVP_dss1 HAVE_EVP_DSS1 )
check_function_exists ( EVP_DigestVerify HAVE_EVP_DIGESTVERIFY )
check_function_exists ( EVP_MD_CTX_new HAVE_EVP_MD_CTX_NEW )
check_function_exists ( HMAC_CTX_new HAVE_HMAC_CTX_NEW )
check_function_exists ( OpenSSL_version_num HAVE_OPENSSL_VERSION_NUM )
check_function_exists ( OpenSSL_version HAVE_OPENSSL_VERSION )
check_function_exists ( SSL_CTX_dane_enable HAVE_SSL_CTX_DANE_ENABLE )
check_function_exists ( SSL_CTX_set_ciphersuites HAVE_SSL_CTX_SET_CIPHERSUITES )
check_function_exists ( SSL_set_ciphersuites HAVE_SSL_SET_CIPHERSUITES )
check_function_exists ( OPENSSL_init_crypto HAVE_OPENSSL_INIT_CRYPTO )
check_symbol_exists ( SSL_dane_enable "openssl/ssl.h" HAVE_SSL_DANE_ENABLE )
check_symbol_exists ( SSL_CTX_set1_curves_list "openssl/ssl.h" HAVE_DECL_SSL_CTX_SET1_CURVES_LIST )
check_symbol_exists ( SSL_set1_curves_list "openssl/ssl.h" HAVE_DECL_SSL_SET1_CURVES_LIST )
check_symbol_exists ( SSL_set_min_proto_version "openssl/ssl.h" HAVE_DECL_SSL_SET_MIN_PROTO_VERSION )
2019-10-14 03:44:28 -05:00
check_symbol_exists ( TLS_client_method "openssl/ssl.h" HAVE_TLS_CLIENT_METHOD )
2019-10-10 06:30:50 -05:00
check_symbol_exists ( X509_get_notAfter "openssl/x509.h" HAVE_X509_GET_NOTAFTER )
check_symbol_exists ( X509_get0_notAfter "openssl/x509.h" HAVE_X509_GET0_NOTAFTER )
2019-10-09 11:19:18 -05:00
2018-01-08 09:36:35 -06:00
# Threading library
set ( THREADS_PREFER_PTHREAD_FLAG ON )
find_package ( Threads REQUIRED )
if ( CMAKE_USE_PTHREADS_INIT )
set ( HAVE_PTHREAD 1 )
elseif ( CMAKE_USE_WIN32_THREADS_INIT )
set ( HAVE_WINDOWS_THREADS 1 )
2019-10-17 11:21:58 -05:00
else ( )
2018-01-08 09:36:35 -06:00
message ( WARNING "Neither pthreads nor Windows threading available." )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 09:36:35 -06:00
2018-01-08 12:59:54 -06:00
# Stuff that might be in a BSD library
check_symbol_exists ( strlcpy string.h HAVE_DECL_STRLCPY )
check_symbol_exists ( arc4random stdlib.h HAVE_DECL_ARC4RANDOM )
check_symbol_exists ( arc4random_uniform stdlib.h HAVE_DECL_ARC4RANDOM_UNIFORM )
check_function_exists ( strlcpy HAVE_STRLCPY )
check_function_exists ( arc4random HAVE_ARC4RANDOM )
check_function_exists ( arc4random_uniform HAVE_ARC4RANDOM_UNIFORM )
if ( NOT
( H A V E _ S T R L C P Y A N D H A V E _ D E C L _ S T R L C P Y A N D
H A V E _ A R C 4 R A N D O M A N D H A V E _ D E C L _ A R C 4 R A N D O M A N D
H A V E _ A R C 4 R A N D O M _ U N I F O R M A N D H A V E _ D E C L _ A R C 4 R A N D O M _ U N I F O R M ) )
2019-10-24 06:04:27 -05:00
find_library ( BSD_LIBRARY bsd )
if ( BSD_LIBRARY )
2019-10-24 11:32:05 -05:00
unset ( CMAKE_REQUIRED_LIBRARIES )
set ( CMAKE_REQUIRED_LIBRARIES ${ BSD_LIBRARY } )
2019-10-24 06:04:27 -05:00
mark_as_advanced ( BSD_LIBRARY )
2019-10-24 11:32:05 -05:00
list ( APPEND getdns_system_libs ${ BSD_LIBRARY } )
2019-10-15 12:35:06 -05:00
check_include_file ( bsd/stdlib.h HAVE_BSD_STDLIB_H )
check_include_file ( bsd/string.h HAVE_BSD_STRING_H )
check_symbol_exists ( strlcpy "bsd/string.h" HAVE_BSD_DECL_STRLCPY )
set ( HAVE_DECL_STRLCPY ${ HAVE_BSD_DECL_STRLCPY } )
check_symbol_exists ( arc4random "bsd/stdlib.h" HAVE_BSD_DECL_ARC4RANDOM )
set ( HAVE_DECL_ARC4RANDOM ${ HAVE_BSD_DECL_ARC4RANDOM } )
check_symbol_exists ( arc4random_uniform "bsd/stdlib.h" HAVE_BSD_DECL_ARC4RANDOM_UNIFORM )
set ( HAVE_DECL_ARC4RANDOM_UNIFORM ${ HAVE_BSD_DECL_ARC4RANDOM_UNIFORM } )
check_function_exists ( strlcpy HAVE_BSD_STRLCPY )
set ( HAVE_STRLCPY ${ HAVE_BSD_STRLCPY } )
check_function_exists ( arc4random HAVE_BSD_ARC4RANDOM )
set ( HAVE_ARC4RANDOM ${ HAVE_BSD_ARC4RANDOM } )
check_function_exists ( arc4random_uniform HAVE_BSD_ARC4RANDOM_UNIFORM )
set ( HAVE_ARC4RANDOM_UNIFORM ${ HAVE_BSD_ARC4RANDOM_UNIFORM } )
2019-10-17 11:21:58 -05:00
endif ( )
endif ( )
2019-10-24 11:32:05 -05:00
mark_as_advanced ( BSD_LIBRARY )
2018-01-08 12:59:54 -06:00
2019-10-24 11:40:37 -05:00
# If we're not stub only, we need libunbound.
if ( NOT ENABLE_STUB_ONLY )
find_package ( Libunbound REQUIRED )
set ( HAVE_LIBUNBOUND 1 )
list ( APPEND getdns_system_libs Libunbound::Libunbound )
set ( CMAKE_REQUIRED_INCLUDES ${ LIBUNBOUND_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ LIBUNBOUND_LIBRARIES } )
check_include_file ( unbound-event.h HAVE_UNBOUND_EVENT_H )
check_symbol_exists ( ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API )
check_symbol_exists ( ub_ctx_set_stub "unbound-event.h" HAVE_UB_CTX_SET_STUB )
endif ( )
2018-01-08 12:59:54 -06:00
# Event loop extension
# TODO: other event loops
set ( DEFAULT_EVENTLOOP "select_eventloop" )
if ( HAVE_SYS_POLL_H )
set ( TEST_CFLAG "HAVE_SYS_POLL_H=1" )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 12:59:54 -06:00
try_compile ( USE_POLL_DEFAULT_EVENTLOOP
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / t e s t s / t e s t _ p o l l . c
C O M P I L E _ D E F I N I T I O N S " $ { T E S T _ C F L A G } "
)
if ( USE_POLL_DEFAULT_EVENTLOOP )
set ( DEFAULT_EVENTLOOP "poll_eventloop" )
2019-10-17 11:21:58 -05:00
endif ( )
2018-01-08 12:59:54 -06:00
2019-10-14 03:44:28 -05:00
# Custom checks
set ( STRPTIME_TEST_SOURCE " \n
#define _XOPEN_SOURCE 600\n
#include <time.h>\n
i n t main ( void ) { s t r u c t t m t m ; c h a r * r e s ; \ n
r e s = strptime ( \"2010-07-15T00:00:00+00:00\", \"%t%Y%t-%t%m%t-%t%d%tT%t%H%t:%t%M%t:%t%S%t\", &tm ) ; \ n
if ( !res ) r e t u r n 2 ; \ n
r e s = strptime ( \"20070207111842\", \"%Y%m%d%H%M%S\", &tm ) ; \ n
if ( !res ) r e t u r n 1 ; r e t u r n 0 ; } " )
if ( HAVE_STRPTIME )
check_c_source_runs ( "${STRPTIME_TEST_SOURCE}" STRPTIME_WORKS )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-14 03:44:28 -05:00
2018-01-08 09:36:35 -06:00
# Main library
2019-10-21 07:32:05 -05:00
add_library ( getdns_objects OBJECT
2018-01-08 12:59:54 -06:00
s r c / a n c h o r . c
2018-01-08 09:36:35 -06:00
s r c / c o n s t - i n f o . c
s r c / c o n v e r t . c
2018-01-08 12:59:54 -06:00
s r c / c o n t e x t . c
2018-01-08 09:36:35 -06:00
s r c / d i c t . c
s r c / d n s s e c . c
s r c / g e n e r a l . c
s r c / l i s t . c
s r c / r e q u e s t - i n t e r n a l . c
s r c / m d n s . c
s r c / p l a t f o r m . c
s r c / p u b k e y - p i n n i n g . c
s r c / r r - d i c t . c
s r c / r r - i t e r . c
s r c / s e r v e r . c
s r c / s t u b . c
s r c / s y n c . c
s r c / u b _ l o o p . c
s r c / u t i l - i n t e r n a l . c
2018-01-08 12:59:54 -06:00
s r c / e x t e n s i o n / $ { D E F A U L T _ E V E N T L O O P } . c
2018-01-08 09:36:35 -06:00
s r c / g l d n s / k e y r a w . c
s r c / g l d n s / g b u f f e r . c
s r c / g l d n s / w i r e 2 s t r . c
s r c / g l d n s / p a r s e . c
s r c / g l d n s / p a r s e u t i l . c
s r c / g l d n s / r r d e f . c
s r c / g l d n s / s t r 2 w i r e . c
s r c / u t i l / r b t r e e . c
s r c / u t i l / l r u h a s h . c
s r c / u t i l / l o o k u p 3 . c
s r c / u t i l / l o c k s . c
s r c / j s m n / j s m n . c
s r c / y x m l / y x m l . c
2018-01-08 12:59:54 -06:00
2019-10-09 11:19:18 -05:00
s r c / t l s / v a l _ s e c a l g o . c
s r c / t l s / a n c h o r - i n t e r n a l . c
s r c / o p e n s s l / t l s . c
s r c / o p e n s s l / p u b k e y - p i n n i n g - i n t e r n a l . c
s r c / o p e n s s l / k e y r a w - i n t e r n a l . c
2018-01-08 12:59:54 -06:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / v e r s i o n . c
2018-01-08 09:36:35 -06:00
)
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_GETTIMEOFDAY )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/gettimeofday.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_DECL_INET_PTON )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/inet_pton.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_DECL_INET_NTOP )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/inet_ntop.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:54:13 -05:00
if ( NOT HAVE_DECL_MKSTEMP )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/mkstemp.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_DECL_STRLCPY )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/strlcpy.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_DECL_ARC4RANDOM )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE
2019-10-15 10:41:29 -05:00
s r c / c o m p a t / a r c 4 r a n d o m . c
s r c / c o m p a t / e x p l i c i t _ b z e r o . c
s r c / c o m p a t / a r c 4 _ l o c k . c
)
if ( NOT HAVE_DECL_GETENTROPY )
if ( DEFINED GETDNS_ON_WINDOWS )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/getentropy_win.c )
2019-10-15 10:41:29 -05:00
elseif ( APPLE )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/getentropy_osx.c )
2019-10-15 10:41:29 -05:00
elseif ( DEFINED LINUX )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/getentropy_linux.c )
2019-10-17 11:21:58 -05:00
endif ( )
endif ( )
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT HAVE_DECL_ARC4RANDOM_UNIFORM )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/arc4random_uniform.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-15 10:41:29 -05:00
if ( NOT STRPTIME_WORKS )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/compat/strptime.c )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-21 07:32:05 -05:00
target_include_directories ( getdns_objects
2019-10-18 05:28:39 -05:00
P U B L I C
2019-10-21 07:32:05 -05:00
s r c
2019-10-18 05:28:39 -05:00
P R I V A T E
2019-10-21 07:32:05 -05:00
s r c / u t i l / a u x i l i a r y
s r c / o p e n s s l
s r c / t l s
s r c / y x m l
s t u b b y / s r c # Wrong, wrong, wrong.
2018-01-08 09:36:35 -06:00
2019-10-21 07:32:05 -05:00
$ { O P E N S S L _ I N C L U D E _ D I R }
2018-01-08 09:36:35 -06:00
)
2019-10-09 11:19:18 -05:00
if ( NOT HAVE_SSL_DANE_ENABLE )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_objects PRIVATE src/ssl_dane/danessl.c )
target_include_directories ( getdns_objects PRIVATE src/ssl_dane )
2019-10-09 11:19:18 -05:00
set ( USE_DANESSL 1 )
2019-10-17 11:21:58 -05:00
endif ( )
2019-10-09 11:19:18 -05:00
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
# Don't compile separate objects for shared and static libraries.
# Yes, -fPIC is slightly suboptimal for static libraries, but it looks
# to me that it's the behaviour the autoconf build follows.
set_property ( TARGET getdns_objects PROPERTY POSITION_INDEPENDENT_CODE 1 )
2019-10-21 07:32:05 -05:00
set_property ( TARGET getdns_objects PROPERTY C_STANDARD 11 )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
2019-10-21 07:32:05 -05:00
# Static library version of main library.
2019-10-24 04:51:28 -05:00
if ( ENABLE_STATIC )
add_library ( getdns STATIC $< TARGET_OBJECTS:getdns_objects > )
target_include_directories ( getdns PUBLIC
" $ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c > "
)
target_link_libraries ( getdns
P U B L I C
O p e n S S L : : S S L
O p e n S S L : : C r y p t o
T h r e a d s : : T h r e a d s
$ { g e t d n s _ s y s t e m _ l i b s }
)
set_target_properties ( getdns PROPERTIES OUTPUT_NAME getdns ${ static_lib_suffix } )
endif ( )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
2019-10-21 07:32:05 -05:00
# Shared library version of main library.
2019-10-24 04:51:28 -05:00
if ( ENABLE_SHARED )
add_library ( getdns_shared SHARED $< TARGET_OBJECTS:getdns_objects > )
target_include_directories ( getdns_shared PUBLIC
" $ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c > "
)
target_link_libraries ( getdns_shared
P U B L I C
O p e n S S L : : S S L
O p e n S S L : : C r y p t o
T h r e a d s : : T h r e a d s
$ { g e t d n s _ s y s t e m _ l i b s }
)
set_target_properties ( getdns_shared PROPERTIES OUTPUT_NAME getdns )
2019-10-21 07:32:05 -05:00
2019-10-24 04:51:28 -05:00
if ( NOT ENABLE_STATIC )
add_library ( getdns ALIAS getdns_shared )
endif ( )
# Generate platform-specific link file with the export symbols.
file ( STRINGS src/libgetdns.symbols symbols )
if ( WIN32 )
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/getdns.def" "LIBRARY GETDNS\n VERSION ${GETDNS_VERSION_CURRENT}.${GETDNS_VERSION_REVISION}\n EXPORTS\n" )
foreach ( symbol IN LISTS symbols )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/getdns.def" " ${symbol}\n" )
endforeach ( )
target_sources ( getdns_shared PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/getdns.def" )
elseif ( APPLE )
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/getdns.syms" "" )
foreach ( symbol IN LISTS symbols )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/getdns.syms" "_${symbol}\n" )
endforeach ( )
target_sources ( getdns_shared PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/getdns.syms" )
target_link_libraries ( getdns_shared PRIVATE "-exported_symbols_list getdns.syms" )
# Follow libtool. Add one to major version, as version 0 doesn't work.
# But tag dynlib name with current-age.
math ( EXPR major_version "${GETDNS_VERSION_CURRENT}+1" )
math ( EXPR dynlib_version "${GETDNS_VERSION_CURRENT}-${GETDNS_VERSION_AGE}" )
set_target_properties ( getdns_shared PROPERTIES VERSION "${dynlib_version}" )
target_link_libraries ( getdns_shared PRIVATE "-compatibility_version ${major_version}" )
target_link_libraries ( getdns_shared PRIVATE "-current_version ${major_version}.${GETDNS_VERSION_REVISION}" )
else ( )
# Assume GNU ld.
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/getdns.ver" "{ global:\n" )
foreach ( symbol IN LISTS symbols )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/getdns.ver" " ${symbol};\n" )
endforeach ( )
file ( APPEND "${CMAKE_CURRENT_BINARY_DIR}/getdns.ver" "local:\n *;\n};\n" )
target_link_libraries ( getdns_shared PRIVATE "-Wl,--version-script=getdns.ver" )
# Again, follow libtool. Major version is current-age.
math ( EXPR compat_version "${GETDNS_VERSION_CURRENT}-${GETDNS_VERSION_AGE}" )
set_target_properties ( getdns_shared PROPERTIES VERSION "${compat_version}.${GETDNS_VERSION_AGE}.${GETDNS_VERSION_REVISION}" SOVERSION "${compat_version}" )
endif ( )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
endif ( )
2018-01-08 09:36:35 -06:00
2019-10-21 07:32:05 -05:00
# The tools.
add_executable ( getdns_query src/tools/getdns_query.c )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
if ( NOT HAVE_GETTIMEOFDAY )
2019-10-21 07:32:05 -05:00
target_sources ( getdns_query PRIVATE src/compat/gettimeofday.c )
First pass at adding shared libraries to the current static library build.
* I can't find out where the .so version number currently produced by the autoconf build comes from, so for the moment supply it explicitly.
* Include a version in the Windows DLL. But Windows can only grok major[.minor]. So also supply one of those.
* On Windows, we need a .lib for the .dll, and a static .lib. These, obviously, need different names. So add _static onto the name of the static lib.
* Only build the objects once, so explicitly build both with PIC.
* Only export the explicit list of symbols from the shared library. This has to be done a different way on GNU ld, Mac linker and Windows.
* Although I have left the tools being linked statically, I have tested with dynamic linking. getdns_query uses gettimeofday(), which isn't on Windows. With a static link, it just happens to find it in the getdns library, as the symbols aren't filtered. But this doesn't work for shared use, when they are. So explicitly add the compat implementation into the getdns_query sources.
2019-10-18 12:54:09 -05:00
endif ( )
2019-10-16 04:35:18 -05:00
target_link_libraries ( getdns_query PRIVATE getdns )
2019-10-21 10:54:40 -05:00
set_property ( TARGET getdns_query PROPERTY C_STANDARD 11 )
2019-10-15 10:56:12 -05:00
2019-10-16 04:42:05 -05:00
add_executable ( getdns_server_mon src/tools/getdns_server_mon.c )
target_link_libraries ( getdns_server_mon
2019-10-18 05:28:39 -05:00
P U B L I C
2019-10-21 07:32:05 -05:00
O p e n S S L : : S S L
O p e n S S L : : C r y p t o
2019-10-18 05:28:39 -05:00
P R I V A T E
2019-10-21 07:32:05 -05:00
g e t d n s
2019-10-16 04:42:05 -05:00
)
2019-10-21 10:54:40 -05:00
set_property ( TARGET getdns_server_mon PROPERTY C_STANDARD 11 )
2019-10-16 04:42:05 -05:00
2019-10-24 11:28:58 -05:00
if ( BUILD_TESTING )
find_package ( Check "0.9.6" )
2019-10-23 12:33:50 -05:00
2019-10-24 11:28:58 -05:00
if ( NOT Check_FOUND )
message ( WARNING "check library not found, not building test programs" )
else ( )
add_executable ( check_getdns
s r c / t e s t / c h e c k _ g e t d n s _ c o m m o n . c
s r c / t e s t / c h e c k _ g e t d n s _ c o n t e x t _ s e t _ t i m e o u t . c
s r c / t e s t / c h e c k _ g e t d n s _ t r a n s p o r t . c
s r c / t e s t / c h e c k _ g e t d n s _ s e l e c t l o o p . c
s r c / t e s t / c h e c k _ g e t d n s . c
)
target_link_libraries ( check_getdns
P R I V A T E
g e t d n s
C h e c k : : C h e c k
T h r e a d s : : T h r e a d s
)
add_executable ( tests_dict
s r c / t e s t / t e s t s _ d i c t . c
s r c / t e s t / t e s t m e s s a g e s . c
)
target_link_libraries ( tests_dict PRIVATE getdns Check::Check )
add_executable ( tests_list
s r c / t e s t / t e s t s _ l i s t . c
s r c / t e s t / t e s t m e s s a g e s . c
)
target_link_libraries ( tests_list PRIVATE getdns Check::Check )
add_executable ( tests_namespaces src/test/tests_namespaces.c )
target_link_libraries ( tests_namespaces PRIVATE getdns Check::Check )
add_executable ( tests_stub_async
s r c / t e s t / t e s t s _ s t u b _ a s y n c . c
s r c / t e s t / t e s t m e s s a g e s . c
)
target_link_libraries ( tests_stub_async PRIVATE getdns Check::Check )
add_executable ( tests_stub_sync src/test/tests_stub_sync.c )
target_link_libraries ( tests_stub_sync PRIVATE getdns Check::Check )
add_test ( NAME test_noeventloop COMMAND check_getdns )
set_property ( TEST test_noeventloop PROPERTY
E N V I R O N M E N T " G E T D N S _ T E S T _ P O R T = 4 3 2 1 0 ; C K _ T I M E O U T _ M U L T I P L I E R = 2 ; C K _ L O G _ F I L E _ N A M E = c h e c k _ g e t d n s . l o g "
)
endif ( )
2019-10-23 12:33:50 -05:00
endif ( )
2019-10-22 08:32:44 -05:00
# Substitutions in files.
configure_file ( cmake/include/cmakeconfig.h.in config.h )
configure_file ( src/getdns/getdns.h.in getdns/getdns.h )
configure_file ( src/getdns/getdns_extra.h.in getdns/getdns_extra.h )
configure_file ( src/version.c.in version.c )
set ( version ${ PACKAGE_VERSION } )
set ( date ${ API_VERSION } )
file ( GLOB mans doc/*.3.in )
file ( MAKE_DIRECTORY man3 )
foreach ( man ${ mans } )
get_filename_component ( out ${ man } NAME_WE )
configure_file ( ${ man } man3/ ${ out } .3 @ONLY )
# Look through the page and make copies of the page for all APIs
# defined in that page. Defined means listed in a line ".B <name>"
# between lines ".SH NAME" and ".SH LIBRARY". Ignore terminating ","
# or spaces in .B line.
2019-10-22 08:47:49 -05:00
file ( STRINGS ${ man } manpage REGEX "^\\.(SH +NAME|SH +LIBRARY|B )" )
2019-10-22 08:32:44 -05:00
set ( in_list 0 )
foreach ( line ${ manpage } )
2019-10-22 08:47:49 -05:00
if ( "${line}" MATCHES "^\\.SH +NAME" )
2019-10-22 08:32:44 -05:00
set ( in_list 1 )
2019-10-22 08:47:49 -05:00
elseif ( "${line}" MATCHES "^\\.SH +LIBRARY" )
2019-10-22 08:32:44 -05:00
set ( in_list 0 )
elseif ( ${ in_list } )
2019-10-22 08:47:49 -05:00
string ( REGEX REPLACE ".B +([^ ,]+).*" "\\1" alt "${line}" )
2019-10-22 08:32:44 -05:00
configure_file ( ${ man } man3/ ${ alt } .3 @ONLY )
endif ( )
endforeach ( )
endforeach ( )
set ( prefix ${ CMAKE_INSTALL_PREFIX } )
configure_file ( getdns.pc.in getdns.pc @ONLY )
# Installing.
2019-10-24 04:51:28 -05:00
if ( ENABLE_STATIC )
install ( TARGETS getdns LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
endif ( )
if ( ENABLE_SHARED )
install ( TARGETS getdns_shared LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
endif ( )
install ( TARGETS getdns_query getdns_server_mon RUNTIME DESTINATION bin )
2019-10-22 08:32:44 -05:00
install ( DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /getdns DESTINATION include )
install ( DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /man3 DESTINATION share/man )
set ( docdir share/doc/getdns )
install ( FILES AUTHORS ChangeLog COPYING INSTALL LICENSE NEWS README.md DESTINATION ${ docdir } )
install ( FILES spec/index.html DESTINATION ${ docdir } /spec )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /getdns.pc DESTINATION lib/pkgconfig )
install ( CODE "message(\" \
* * * \ n \
* * * ! ! ! I M P O R T A N T ! ! ! ! \ n \
* * * \ n \
* * * F r o m r e l e a s e 1 . 2 . 0 , g e t d n s c o m e s w i t h b u i l t - i n D N S S E C \ n \
* * * t r u s t a n c h o r m a n a g e m e n t . E x t e r n a l t r u s t a n c h o r m a n a g e m e n t , \ n \
* * * f o r e x a m p l e w i t h u n b o u n d - a n c h o r , i s n o l o n g e r n e c e s s a r y \ n \
* * * a n d n o l o n g e r r e c o m m e n d e d . \ n \
* * * \ n \
* * * P r e v i o u s l y i n s t a l l e d t r u s t a n c h o r s , i n t h e d e f a u l t l o c a t i o n - \ n \
* * * \ n \
* * * / e t c / u n b o u n d / g e t d n s - r o o t . k e y \ n \
* * * \ n \
* * * - w i l l b e p r e f e r r e d a n d u s e d f o r D N S S E C v a l i d a t i o n , h o w e v e r \ n \
* * * g e t d n s w i l l f a l l b a c k t o t r u s t - a n c h o r s o b t a i n e d v i a b u i l t - i n \ n \
* * * t r u s t a n c h o r m a n a g e m e n t w h e n t h e a n c h o r s f r o m t h e d e f a u l t \ n \
* * * l o c a t i o n f a i l t o v a l i d a t e t h e r o o t D N S K E Y r r s e t . \ n \
* * * \ n \
* * * T o p r e v e n t e x p i r e d D N S S E C t r u s t a n c h o r s t o b e u s e d f o r \ n \
* * * v a l i d a t i o n , w e s t r o n g l y r e c o m m e n d r e m o v i n g t h e t r u s t a n c h o r s \ n \
* * * o n t h e d e f a u l t l o c a t i o n w h e n t h e r e i s n o a c t i v e e x t e r n a l \ n \
* * * t r u s t a n c h o r m a n a g e m e n t k e e p i n g i t u p - t o - d a t e . \ n \
* * * \ " ) " )