2011-08-06 19:10:25 +00:00
|
|
|
# ConfigureChecks.cmake
|
|
|
|
#
|
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
# Copyright 1998 Gerald Combs
|
|
|
|
#
|
2018-03-06 15:31:02 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2011-08-06 19:10:25 +00:00
|
|
|
#
|
|
|
|
|
2013-10-06 16:11:50 +00:00
|
|
|
include(CMakePushCheckState)
|
|
|
|
|
2011-08-06 19:10:25 +00:00
|
|
|
#check system for includes
|
|
|
|
include(CheckIncludeFile)
|
2018-05-30 13:35:04 -07:00
|
|
|
include(CheckIncludeFiles)
|
|
|
|
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
|
|
|
|
check_include_file("grp.h" HAVE_GRP_H)
|
|
|
|
#
|
|
|
|
# This may require <sys/types.h> to be included
|
|
|
|
#
|
|
|
|
check_include_files("sys/types.h;ifaddrs.h" HAVE_IFADDRS_H)
|
|
|
|
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
|
|
|
|
check_include_file("netdb.h" HAVE_NETDB_H)
|
|
|
|
check_include_file("pwd.h" HAVE_PWD_H)
|
|
|
|
check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
|
|
|
|
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
|
|
|
|
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
|
|
|
check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
|
|
|
|
check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
|
|
|
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
2011-08-06 19:10:25 +00:00
|
|
|
|
2025-04-21 21:19:06 -04:00
|
|
|
# Check that the C compiler works on a trivial program.
|
|
|
|
# Do this early on before more specific tests so we can give
|
|
|
|
# an appropriate error message.
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
check_c_source_runs("
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
"
|
|
|
|
COMPILER_RUNS
|
|
|
|
)
|
|
|
|
if(NOT COMPILER_RUNS)
|
|
|
|
if(WIN32)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"${CMAKE_C_COMPILER} failed to compile and run a trivial test program. \
|
|
|
|
This is likely a permissions error or the result of security software like \
|
|
|
|
Windows Defender preventing untrusted code from running."
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"${CMAKE_C_COMPILER} failed to compile and run a trivial test program. \
|
|
|
|
This is likely a permissions error or the result of security software \
|
|
|
|
preventing untrusted code from running."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-03-30 11:21:17 -07:00
|
|
|
#
|
|
|
|
# On Linux, check for some additional headers, which we need as a
|
|
|
|
# workaround for a bonding driver bug and for libpcap's current lack
|
|
|
|
# of its own workaround for that bug.
|
|
|
|
#
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
#
|
|
|
|
# Those header files require <sys/socket.h>.
|
|
|
|
#
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <sys/socket.h>
|
|
|
|
#include <linux/sockios.h>
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_LINUX_SOCKIOS_H
|
|
|
|
)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <sys/socket.h>
|
|
|
|
#include <linux/if_bonding.h>
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_LINUX_IF_BONDING_H
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2011-08-06 19:10:25 +00:00
|
|
|
#Functions
|
|
|
|
include(CheckFunctionExists)
|
2014-12-20 00:23:05 -08:00
|
|
|
include(CheckSymbolExists)
|
2013-08-13 09:58:09 +00:00
|
|
|
|
2018-05-04 23:00:29 -07:00
|
|
|
#
|
|
|
|
# Platform-specific functions used in platform-specific code.
|
|
|
|
# We check for them only on the platform on which we use them.
|
|
|
|
#
|
2018-05-04 23:39:46 -07:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
|
|
|
|
#
|
|
|
|
# HP-UX
|
|
|
|
#
|
|
|
|
cmake_push_check_state()
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
|
|
|
check_function_exists("dlget" HAVE_DLGET)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
|
2018-05-04 23:00:29 -07:00
|
|
|
#
|
|
|
|
# Solaris
|
|
|
|
#
|
|
|
|
check_function_exists("getexecname" HAVE_GETEXECNAME)
|
|
|
|
endif()
|
2013-08-13 09:58:09 +00:00
|
|
|
|
2021-12-27 10:47:16 +00:00
|
|
|
check_symbol_exists("clock_gettime" "time.h" HAVE_CLOCK_GETTIME)
|
2021-12-15 13:06:57 +00:00
|
|
|
# Some platforms (macOS pre 10.15) are non-conformant with C11 and lack timespec_get()
|
2021-12-27 10:47:16 +00:00
|
|
|
check_symbol_exists("timespec_get" "time.h" HAVE_TIMESPEC_GET)
|
2023-09-03 01:35:31 +01:00
|
|
|
if(NOT MSVC)
|
|
|
|
check_symbol_exists("localtime_r" "time.h" HAVE_LOCALTIME_R)
|
Add a routine to format an nstime as an ISO 8601-style date/time.
This replaces code in both absolute_time_string(), in capinfos, and
set_abs_ymd_time(), in libwireshark. Like absolute_time_string(), it
reports, in the formatted string, an error if the seconds value in the
nstime can't be converted to a struct tm (looking at *you*, Visual
Studio C library),
Have that routine handle all time precision values from 0 (seconds) to 9
(nanoseconds).
Add a ws_gmtime_r(), matching ws_localtime_r(), for use by that routine.
2023-09-11 02:21:59 -07:00
|
|
|
check_symbol_exists("gmtime_r" "time.h" HAVE_GMTIME_R)
|
2023-09-04 19:59:52 +01:00
|
|
|
check_symbol_exists("timegm" "time.h" HAVE_TIMEGM)
|
2023-09-03 01:35:31 +01:00
|
|
|
check_symbol_exists("tzset" "time.h" HAVE_TZSET)
|
2023-09-02 22:57:53 +01:00
|
|
|
check_symbol_exists("tzname" "time.h" HAVE_TZNAME)
|
2024-10-16 20:29:04 -04:00
|
|
|
check_symbol_exists("getline" "stdio.h" HAVE_GETLINE)
|
2023-09-03 01:35:31 +01:00
|
|
|
endif()
|
2016-02-23 14:33:54 +01:00
|
|
|
check_function_exists("getifaddrs" HAVE_GETIFADDRS)
|
2011-08-06 19:10:25 +00:00
|
|
|
check_function_exists("issetugid" HAVE_ISSETUGID)
|
2013-10-10 23:54:53 +00:00
|
|
|
check_function_exists("setresgid" HAVE_SETRESGID)
|
|
|
|
check_function_exists("setresuid" HAVE_SETRESUID)
|
2014-11-10 14:24:18 -06:00
|
|
|
if (APPLE)
|
|
|
|
cmake_push_check_state()
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
|
|
|
|
check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
endif()
|
2021-11-27 17:57:46 +00:00
|
|
|
if(UNIX)
|
|
|
|
cmake_push_check_state()
|
|
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
2021-12-27 10:47:16 +00:00
|
|
|
check_symbol_exists("memmem" "string.h" HAVE_MEMMEM)
|
2023-10-11 08:43:35 -04:00
|
|
|
check_symbol_exists("memrchr" "string.h" HAVE_MEMRCHR)
|
2021-12-27 13:28:29 +00:00
|
|
|
check_symbol_exists("strerrorname_np" "string.h" HAVE_STRERRORNAME_NP)
|
2021-12-27 02:03:26 +00:00
|
|
|
check_symbol_exists("strptime" "time.h" HAVE_STRPTIME)
|
2021-12-27 10:47:16 +00:00
|
|
|
check_symbol_exists("vasprintf" "stdio.h" HAVE_VASPRINTF)
|
2021-11-27 17:57:46 +00:00
|
|
|
cmake_pop_check_state()
|
|
|
|
endif()
|
2012-09-06 10:37:17 +00:00
|
|
|
|
2013-04-19 16:38:28 +00:00
|
|
|
#Struct members
|
|
|
|
include(CheckStructHasMember)
|
2019-01-03 14:56:31 +01:00
|
|
|
check_struct_has_member("struct stat" st_blksize sys/stat.h HAVE_STRUCT_STAT_ST_BLKSIZE)
|
2016-10-22 01:56:48 -07:00
|
|
|
check_struct_has_member("struct stat" st_birthtime sys/stat.h HAVE_STRUCT_STAT_ST_BIRTHTIME)
|
|
|
|
check_struct_has_member("struct stat" __st_birthtime sys/stat.h HAVE_STRUCT_STAT___ST_BIRTHTIME)
|
On UN*X, st_ctime is the last status change time, not the creation time.
That's the time the file's inode last changed, so size changes,
permission changes, etc. affect it. It's *not* the time the file was
created; most UN*Xes don't provide that. Newer versions of FreeBSD,
NetBSD, OpenBSD, and macOS do, but other UN*Xes don't appear to.
On Windows, at least according to Microsoft's documentation, st_ctime
*is* the creation time. Hopefully that's not the result of confusion on
the part of somebody at Microsoft.
Change-Id: I20743703f6ef66e40dff9004dc91bed46af6fad0
Reviewed-on: https://code.wireshark.org/review/18378
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-21 22:19:46 -07:00
|
|
|
check_struct_has_member("struct tm" tm_zone time.h HAVE_STRUCT_TM_TM_ZONE)
|
2023-09-02 22:57:53 +01:00
|
|
|
check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_STRUCT_TM_TM_GMTOFF)
|
2012-09-10 18:35:56 +00:00
|
|
|
|
2021-11-12 17:23:04 +00:00
|
|
|
# Types
|
|
|
|
include(CheckTypeSize)
|
|
|
|
check_type_size("ssize_t" SSIZE_T)
|
|
|
|
|
2025-05-13 10:59:13 -04:00
|
|
|
# Unconditionally force use of 64-bit time_t on 32-bit platforms with glibc.
|
|
|
|
check_symbol_exists(__GLIBC__ "time.h" HAVE___GLIBC__)
|
|
|
|
|
|
|
|
if(HAVE___GLIBC__ AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
|
|
# _TIME_BITS=64 requires _FILE_OFFSET_BITS=64, which we should have
|
|
|
|
# already ensured is set by FindLFS, but this doesn't hurt
|
|
|
|
check_symbol_exists(_FILE_OFFSET_BITS "time.h" HAVE__FILE_OFFSET_BITS)
|
|
|
|
if (NOT HAVE__FILE_OFFSET_BITS)
|
|
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64)
|
|
|
|
endif()
|
|
|
|
check_symbol_exists(_TIME_BITS "time.h" HAVE__TIME_BITS)
|
|
|
|
if (NOT HAVE__TIME_BITS)
|
|
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_TIME_BITS=64)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Do we want to eventually just fail for non Y2038 compliant hosts (or all
|
|
|
|
# less than 64-bit time_t hosts, if we don't want to consider theoretical
|
|
|
|
# cases like unsigned 32 bit time_t?)
|
|
|
|
# The only way to truly test this is to compile a program, especially
|
|
|
|
# due to multiple architectures.
|
|
|
|
#check_type_size("time_t" TIME_T_SIZE)
|
|
|
|
#if(TIME_T_SIZE_64 EQUAL 0)
|
|
|
|
# message("multiple architectures with possibly different time_t sizes.")
|
|
|
|
#elseif(TIME_T_SIZE_64 LESS 8)
|
|
|
|
# message(FATAL_ERROR "time_t is less than 64-bit")
|
|
|
|
#endif()
|
|
|
|
|
2021-09-21 18:54:55 +01:00
|
|
|
#
|
|
|
|
# Check if the libc vsnprintf() conforms to C99. If this fails we may
|
|
|
|
# need to fall-back on GLib I/O.
|
|
|
|
#
|
2023-05-26 13:29:23 +01:00
|
|
|
# If cross-compiling we can't check so just assume this requirement is met.
|
|
|
|
#
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
check_c_source_runs("
|
|
|
|
#include <stdio.h>
|
2024-08-15 13:59:24 +02:00
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored \"-Wall\"
|
2023-05-26 13:29:23 +01:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
/* Check that snprintf() and vsnprintf() don't return
|
|
|
|
* -1 if the buffer is too small. C99 says this value
|
|
|
|
* is the length that would be written not including
|
|
|
|
* the nul byte. */
|
|
|
|
char buf[3];
|
|
|
|
return snprintf(buf, sizeof(buf), \"%s\", \"ABCDEF\") > 0 ? 0 : 1;
|
2024-08-15 13:59:24 +02:00
|
|
|
}
|
|
|
|
#pragma GCC diagnostic pop"
|
2023-05-26 13:29:23 +01:00
|
|
|
HAVE_C99_VSNPRINTF
|
|
|
|
)
|
|
|
|
if (NOT HAVE_C99_VSNPRINTF)
|
|
|
|
message(FATAL_ERROR
|
2021-09-21 18:54:55 +01:00
|
|
|
"Building Wireshark requires a C99 compliant vsnprintf() and this \
|
|
|
|
target does not meet that requirement. Compiling for ${CMAKE_SYSTEM} \
|
|
|
|
using ${CMAKE_C_COMPILER_ID}. Please report this issue to the Wireshark \
|
|
|
|
developers at wireshark-dev@wireshark.org."
|
2023-05-26 13:29:23 +01:00
|
|
|
)
|
|
|
|
endif()
|
2021-09-21 18:54:55 +01:00
|
|
|
endif()
|
2015-01-04 16:31:49 -08:00
|
|
|
|
|
|
|
#
|
|
|
|
# *If* we found libnl, check if we can use nl80211 stuff with it.
|
|
|
|
#
|
|
|
|
if (NL_FOUND)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <linux/nl80211.h>
|
2018-04-24 20:20:33 +02:00
|
|
|
int main(void) {
|
2015-01-04 16:31:49 -08:00
|
|
|
int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
|
2015-02-16 00:14:18 +01:00
|
|
|
x |= NL80211_ATTR_SUPPORTED_IFTYPES;
|
|
|
|
x |= NL80211_ATTR_SUPPORTED_COMMANDS;
|
|
|
|
x |= NL80211_ATTR_WIPHY_FREQ;
|
|
|
|
x |= NL80211_CHAN_NO_HT;
|
|
|
|
(void)x;
|
2015-01-04 16:31:49 -08:00
|
|
|
}"
|
|
|
|
HAVE_NL80211
|
|
|
|
)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <linux/nl80211.h>
|
2018-04-24 20:20:33 +02:00
|
|
|
int main(void) {
|
2015-01-04 16:31:49 -08:00
|
|
|
enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
|
|
|
|
}"
|
|
|
|
HAVE_NL80211_CMD_SET_CHANNEL
|
|
|
|
)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <linux/nl80211.h>
|
2018-04-24 20:20:33 +02:00
|
|
|
int main(void) {
|
2015-01-04 16:31:49 -08:00
|
|
|
enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
|
|
|
|
}"
|
|
|
|
HAVE_NL80211_SPLIT_WIPHY_DUMP
|
|
|
|
)
|
2016-02-07 00:40:51 +01:00
|
|
|
check_c_source_compiles(
|
|
|
|
"#include <linux/nl80211.h>
|
2018-04-24 20:20:33 +02:00
|
|
|
int main(void) {
|
2016-02-07 00:40:51 +01:00
|
|
|
enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;
|
|
|
|
}"
|
|
|
|
HAVE_NL80211_VHT_CAPABILITY
|
|
|
|
)
|
2015-01-04 16:31:49 -08:00
|
|
|
endif()
|
2015-01-04 17:43:19 -08:00
|
|
|
|
2015-12-14 11:53:27 +01:00
|
|
|
#
|
2019-07-26 11:43:17 -07:00
|
|
|
# Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2015-12-14 11:53:27 +01:00
|
|
|
#
|
|
|
|
# Local variables:
|
|
|
|
# c-basic-offset: 8
|
|
|
|
# tab-width: 8
|
|
|
|
# indent-tabs-mode: t
|
|
|
|
# End:
|
|
|
|
#
|
|
|
|
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
# :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
#
|