From patchwork Thu May 8 17:46:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4243 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:62cb:b0:656:592e:a137 with SMTP id d11csp557614maf; Thu, 8 May 2025 10:46:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVQ8oxb17G8mknp+jhwpLJfROvSf8lHKz/sV1+eHKEfkz3PNC6DxtfOLSc8CdNKfjJQcI+MuUErO7E=@openvpn.net X-Google-Smtp-Source: AGHT+IF9CryYlxWXSocwtM+f1083Xdj2TDVTVH9I17WGe9nY2N+tcbVjDcvibE4fGilo8VZuqXKS X-Received: by 2002:a05:6830:3788:b0:72b:9ce5:6da6 with SMTP id 46e09a7af769-732269fcf3fmr584551a34.9.1746726406371; Thu, 08 May 2025 10:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746726406; cv=none; d=google.com; s=arc-20240605; b=CGEshoero+CASW11aJIH+3LKAFJO1HFObyzDsMdILgbd5iPuVMELQ866wEi6oL9HWp be+FkoNOFrj8mDVjp0bChvBqZO0dmgLCBOylsWFb083LNs5kVfew+zV0zCBH8D8NidBU zOge/53/EL2dl35o9R1oplpy7DX1x/4MprIzmmfwcS6HngAeXsq9EHOF8tL87a3o9Q96 IUAYMdZtC+qqyNDvHUXXWvQiuhwKs5tUmCeCGlk4qHkAQDMKUfVaqRNmTCtmPlrcFBGZ xfJuRxDq3gMdzrLlXmjSairoddrX0Aht/9kMX9VBKHGptQ5ClU3s2bs5+93UvYxm/4Y7 0k4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=wjv2NlQltK6HsQci/NyHObsdnXpLRn9LhEMtJra/3cQ=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=OGBgwuJ7FBmT0USNj9SVYs0WPhSUBksY8/roLcvbWVowgnr4h8WgmH4ssQfpD9cZ0W zo89rkRKl14mWsaVwuI4W4vPS/Xv6a6ZqSRggSUH1TnJpdvCvbk01LDcSUWTBvp6ZqX2 ktygr0AdrYMArnaphtBDuTdqgw4+m475VPLjiw88RO/MQiW8jcq01Opnuqoo6iAvnemx GJeUeiTAkUG4wNvJFvz+qHrjCVdO/mqkDKu0xFKkb9VS/O+0iW5Ul3CZIRNwTKgBJrEY 16oFmv6FUyW5AtQ0fGAACE+CCzff7GRFbcVg3A3yzzm0x4DNY5xlxtn2VxTAH47jYegi ua/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=AVap0Vr1; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Dmy7JhTz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=aD23ZP3e; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-732264ad6a3si254950a34.105.2025.05.08.10.46.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 May 2025 10:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=AVap0Vr1; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Dmy7JhTz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=aD23ZP3e; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wjv2NlQltK6HsQci/NyHObsdnXpLRn9LhEMtJra/3cQ=; b=AVap0Vr1u0tIiY4b16q5xM+ZsY Mn5okaFBC2VVw09ZazGlnYcLWoxKciLdc07fxcKIiavVYfP6Rv15Z2O1q77v9OPA20TjwKfRUXn80 3faIobCqnnzvCXxYruAMxK0wiA6/zxzUqHNcrCumGN6sTzmG4+SPMm62zmGUWdABxzTU=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1uD5KS-0000PN-Vr; Thu, 08 May 2025 17:46:40 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uD5KR-0000PF-AL for openvpn-devel@lists.sourceforge.net; Thu, 08 May 2025 17:46:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tD7VskUjI3aN4nTEa2vS0e9PsLa73J3u5ky453GT0ZM=; b=Dmy7JhTz9Ute6rL/eYQvXXBqqw mcYNk8B/VEIqNWUSCFMEq1RNS/P4Mb0CFSlAFYWNeZalcp5EOl4PHIrxFPpwcouz6BjaTvSA81YCb hEqXbO++PA/ShpitCtZbUU6ETXpSxQYEx5IFfdFebH8kiv94dZzu/ZGhG/btHP+SFMuA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tD7VskUjI3aN4nTEa2vS0e9PsLa73J3u5ky453GT0ZM=; b=aD23ZP3e3N8QJsJ/+1SqO8EV9M Y7VuSM9RGP/tqjs9ZGK23Z1EIWiUqxay6C4YSTXmU4PjQRuFLnpDTZ+i5y4K29wkFRavZiMPkGl+U TSywWYPRbO9JAV5tWEemuTGpS5FYEX6y6e+UYGmvdySVkx8cYO5Nh89PtoClkg1txkTQ=; Received: from [193.149.48.143] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1uD5KP-0004u5-3k for openvpn-devel@lists.sourceforge.net; Thu, 08 May 2025 17:46:39 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 548HkOlM007541 for ; Thu, 8 May 2025 19:46:24 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 548HkOoj007540 for openvpn-devel@lists.sourceforge.net; Thu, 8 May 2025 19:46:24 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 8 May 2025 19:46:15 +0200 Message-ID: <20250508174624.7504-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "6901ab67b84d", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld When we check for the header and then symbols in that header combine this so that the relationship between the tests is clear and that we do not do tests we know will fail. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1uD5KP-0004u5-3k Subject: [Openvpn-devel] [PATCH v2] CMake: Reorganize header and symbol tests X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1831575388077453615?= X-GMAIL-MSGID: =?utf-8?q?1831575388077453615?= From: Frank Lichtenheld When we check for the header and then symbols in that header combine this so that the relationship between the tests is clear and that we do not do tests we know will fail. Change-Id: I0c4fce76c81c5297ff5469d787114f1279bf35e5 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/924 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/CMakeLists.txt b/CMakeLists.txt index c19d29a..ae818c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,11 @@ endfunction() if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS) + add_compile_definitions( + _CRT_SECURE_NO_WARNINGS + _CRT_NONSTDC_NO_DEPRECATE + _WINSOCK_DEPRECATED_NO_WARNINGS + ) if (USE_WERROR) add_compile_options(/WX) endif () @@ -171,88 +175,102 @@ set(TARGET_WIN32 YES) endif () -check_symbol_exists(chroot unistd.h HAVE_CHROOT) -check_symbol_exists(chdir unistd.h HAVE_CHDIR) -check_symbol_exists(dup unistd.h HAVE_DUP) -check_symbol_exists(dup2 unistd.h HAVE_DUP2) -check_symbol_exists(fork unistd.h HAVE_FORK) -check_symbol_exists(execve unistd.h HAVE_EXECVE) -check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE) -check_symbol_exists(nice unistd.h HAVE_NICE) -check_symbol_exists(setgid unistd.h HAVE_SETGID) -check_symbol_exists(setuid unistd.h HAVE_SETUID) -check_symbol_exists(setsid unistd.h HAVE_SETSID) -check_symbol_exists(getpeereid "unistd.h;sys/socket.h" HAVE_GETPEEREID) +check_include_files(unistd.h HAVE_UNISTD_H) +if (HAVE_UNISTD_H) + check_symbol_exists(chroot unistd.h HAVE_CHROOT) + check_symbol_exists(chdir unistd.h HAVE_CHDIR) + check_symbol_exists(dup unistd.h HAVE_DUP) + check_symbol_exists(dup2 unistd.h HAVE_DUP2) + check_symbol_exists(fork unistd.h HAVE_FORK) + check_symbol_exists(execve unistd.h HAVE_EXECVE) + check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE) + check_symbol_exists(nice unistd.h HAVE_NICE) + check_symbol_exists(setgid unistd.h HAVE_SETGID) + check_symbol_exists(setuid unistd.h HAVE_SETUID) + check_symbol_exists(setsid unistd.h HAVE_SETSID) + check_symbol_exists(daemon "unistd.h;stdlib.h" HAVE_DAEMON) + check_symbol_exists(getpeereid "unistd.h;sys/socket.h" HAVE_GETPEEREID) +endif() -check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE) +check_include_files(grp.h HAVE_GRP_H) +if (HAVE_GRP_H) + check_symbol_exists(getgrnam grp.h HAVE_GETGRNAM) +endif() +check_include_files(libgen.h HAVE_LIBGEN_H) +if (HAVE_LIBGEN_H) + check_symbol_exists(basename libgen.h HAVE_BASENAME) + check_symbol_exists(dirname libgen.h HAVE_DIRNAME) +endif() +check_include_files(pwd.h HAVE_PWD_H) +if (HAVE_PWD_H) + check_symbol_exists(getpwnam pwd.h HAVE_GETPWNAM) +endif() +check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) +if (HAVE_SYS_EPOLL_H) + check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE) +endif() +check_include_files(syslog.h HAVE_SYSLOG_H) +if (HAVE_SYSLOG_H) + check_symbol_exists(openlog syslog.h HAVE_OPENLOG) + check_symbol_exists(syslog syslog.h HAVE_SYSLOG) +endif() +check_include_files(sys/mman.h HAVE_SYS_MMAN_H) +if (HAVE_SYS_MMAN_H) + check_symbol_exists(mlockall sys/mman.h HAVE_MLOCKALL) +endif() +check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) +if (HAVE_SYS_SOCKET_H) + check_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG) + check_symbol_exists(recvmsg sys/socket.h HAVE_RECVMSG) + check_symbol_exists(getsockname sys/socket.h HAVE_GETSOCKNAME) + # Checking for existence of structs with check_symbol_exists does not work, + # so we use check_struct_hash_member with a member instead + check_struct_has_member("struct cmsghdr" cmsg_len sys/socket.h HAVE_CMSGHDR) +endif() +check_include_files(sys/time.h HAVE_SYS_TIME_H) +if (HAVE_SYS_TIME_H) + check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) + check_symbol_exists(getrlimit "sys/time.h;sys/resource.h" HAVE_GETRLIMIT) +endif() -check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) -check_symbol_exists(basename libgen.h HAVE_BASENAME) check_symbol_exists(chsize io.h HAVE_CHSIZE) -check_symbol_exists(daemon "unistd.h;stdlib.h" HAVE_DAEMON) -check_symbol_exists(dirname libgen.h HAVE_DIRNAME) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) -check_symbol_exists(mlockall sys/mman.h HAVE_MLOCKALL) - -check_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG) -check_symbol_exists(recvmsg sys/socket.h HAVE_RECVMSG) -check_symbol_exists(openlog syslog.h HAVE_OPENLOG) -check_symbol_exists(syslog syslog.h HAVE_SYSLOG) -check_symbol_exists(getgrnam grp.h HAVE_GETGRNAM) -check_symbol_exists(getpwnam pwd.h HAVE_GETPWNAM) -check_symbol_exists(getsockname sys/socket.h HAVE_GETSOCKNAME) -check_symbol_exists(getrlimit "sys/time.h;sys/resource.h" HAVE_GETRLIMIT) - -# Checking for existence of structs with check_symbol_exists does not work, -# so we use check_struct_hash_member with a member instead -check_struct_has_member("struct cmsghdr" cmsg_len sys/socket.h HAVE_CMSGHDR) - # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers set(NETEXTRA sys/types.h) check_include_files("${NETEXTRA};netinet/in.h" HAVE_NETINET_IN_H) - if (HAVE_NETINET_IN_H) list(APPEND NETEXTRA netinet/in.h) endif () -check_include_files("${NETEXTRA};netinet/in6.h" HAVE_NETINET_IN_H) +check_include_files(arpa/inet.h HAVE_ARPA_INET_H) +check_include_files(dlfcn.h HAVE_DLFCN_H) +check_include_files(dmalloc.h HAVE_DMALLOC_H) +check_include_files(fcntl.h HAVE_FCNTL_H) +check_include_files(err.h HAVE_ERR_H) check_include_files(linux/if_tun.h HAVE_LINUX_IF_TUN_H) check_include_files(linux/sockios.h HAVE_LINUX_SOCKIOS_H) -check_include_files(dlfcn.h HAVE_DLFCN_H) -check_include_files(fcntl.h HAVE_FCNTL_H) -check_include_files(dmalloc.h HAVE_DMALLOC_H) -check_include_files(err.h HAVE_ERR_H) -check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H) -check_include_files(poll.h HAVE_POLL_H) -check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) -check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files(netdb.h HAVE_NETDB_H) -check_include_files(unistd.h HAVE_UNISTD_H) -check_include_files(sys/un.h HAVE_SYS_UN_H) -check_include_files(libgen.h HAVE_LIBGEN_H) +check_include_files("${NETEXTRA};netinet/in6.h" HAVE_NETINET_IN_H) check_include_files(net/if.h HAVE_NET_IF_H) -check_include_files("${NETEXTRA};netinet/ip.h" HAVE_NETINET_IP_H) -check_include_files(arpa/inet.h HAVE_ARPA_INET_H) +check_include_files("${NETEXTRA};net/if_tun.h" HAVE_NET_IF_TUN_H) +check_include_files(poll.h HAVE_POLL_H) +check_include_files("${NETEXTRA};resolv.h" HAVE_RESOLV_H) check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H) check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H) check_include_files("${NETEXTRA};sys/uio.h" HAVE_SYS_UIO_H) -check_include_files(syslog.h HAVE_SYSLOG_H) +check_include_files(sys/un.h HAVE_SYS_UN_H) check_include_files(sys/wait.h HAVE_SYS_WAIT_H) -check_include_files(grp.h HAVE_GRP_H) -check_include_files(pwd.h HAVE_PWD_H) -check_include_files(sys/mman.h HAVE_SYS_MMAN_H) - -check_include_files("${NETEXTRA};resolv.h" HAVE_RESOLV_H) -check_include_files("${NETEXTRA};net/if_tun.h" HAVE_NET_IF_TUN_H) - -set(CMAKE_EXTRA_INCLUDE_FILES netinet/ip.h) -check_type_size("struct in_pktinfo" IN_PKTINFO) -check_struct_has_member("struct in_pktinfo" ipi_spec_dst netinet/ip.h HAVE_IPI_SPEC_DST) -check_type_size("struct msghdr" MSGHDR) -set(CMAKE_EXTRA_INCLUDE_FILES) +check_include_files("${NETEXTRA};netinet/ip.h" HAVE_NETINET_IP_H) +if (HAVE_NETINET_IP_H) + set(CMAKE_EXTRA_INCLUDE_FILES netinet/ip.h) + check_type_size("struct in_pktinfo" IN_PKTINFO) + check_struct_has_member("struct in_pktinfo" ipi_spec_dst netinet/ip.h HAVE_IPI_SPEC_DST) + check_type_size("struct msghdr" MSGHDR) + set(CMAKE_EXTRA_INCLUDE_FILES) +endif() find_program(IFCONFIG_PATH ifconfig) find_program(IPROUTE_PATH ip) @@ -317,8 +335,8 @@ if (MINGW) target_compile_definitions(${target} PRIVATE - -DWIN32_LEAN_AND_MEAN - -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA + WIN32_LEAN_AND_MEAN + NTDDI_VERSION=NTDDI_VISTA _WIN32_WINNT=_WIN32_WINNT_VISTA ) endif() @@ -360,7 +378,7 @@ configure_file(config.h.cmake.in config.h) configure_file(include/openvpn-plugin.h.in openvpn-plugin.h) # TODO we should remove the need for this, and always include config.h -add_definitions(-DHAVE_CONFIG_H) +add_compile_definitions(HAVE_CONFIG_H) include_directories(${CMAKE_CURRENT_BINARY_DIR})