diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b4688455a1604dbdc13f74460fb04329e4b641..c4a4576e69a12ba641fc1299f23d3ecfb1adc116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -566,6 +566,14 @@ IF(KWSYS_USE_SystemTools) ENDIF() IF(KWSYS_USE_SystemInformation) + IF(NOT CYGWIN) + INCLUDE(CheckIncludeFiles) + CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H) + IF(KWSYS_SYS_HAS_IFADDRS_H) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1) + ENDIF() + ENDIF() IF(WIN32) INCLUDE(CheckSymbolExists) SET(CMAKE_REQUIRED_LIBRARIES Psapi) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index ccffaa593477dc02a806220abf91fdce08724e34..85186d8d1da8816871b0fcf48f90424617613faa 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -79,7 +79,6 @@ typedef int siginfo_t; #include <fenv.h> #include <sys/socket.h> #include <netdb.h> -#include <ifaddrs.h> #include <netinet/in.h> # if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 >= 1050 # include <execinfo.h> @@ -91,7 +90,6 @@ typedef int siginfo_t; # include <fenv.h> # include <sys/socket.h> # include <netdb.h> -# include <ifaddrs.h> # include <netinet/in.h> # if defined(__GNUG__) # include <execinfo.h> @@ -102,6 +100,10 @@ typedef int siginfo_t; # include <sys/pstat.h> #endif +#if defined(KWSYS_SYS_HAS_IFADDRS_H) +# include <ifaddrs.h> +#endif + #ifdef __HAIKU__ #include <OS.h> #endif @@ -1083,7 +1085,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( WSACleanup(); return 0; -#elif defined(__linux) || defined(__APPLE__) +#elif defined(KWSYS_SYS_HAS_IFADDRS_H) // gethostname typical returns an alias for loopback interface // we want the fully qualified domain name. Because there are // any number of interfaces on this system we look for the