summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-21 19:03:13 -0800
committerJosh Blum <josh@joshknows.com>2011-02-21 19:03:13 -0800
commita8bb5ec900d8f2d3d2f274a921d19b564c668323 (patch)
treea3f87f539a8ff641cd6580c0ea28d38adcd0b057 /host/lib/transport
parenta7f9529f77700309dbaaa6250f6bd775bab7a70d (diff)
downloaduhd-a8bb5ec900d8f2d3d2f274a921d19b564c668323.tar.gz
uhd-a8bb5ec900d8f2d3d2f274a921d19b564c668323.tar.bz2
uhd-a8bb5ec900d8f2d3d2f274a921d19b564c668323.zip
uhd: replace header checks in cmake files with more robust compile checks for features
implemented different ifdefs in the cpp files
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/CMakeLists.txt25
-rw-r--r--host/lib/transport/if_addrs.cpp16
2 files changed, 26 insertions, 15 deletions
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index e58957154..a5bf9c5f1 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -48,20 +48,31 @@ ENDIF(ENABLE_USB)
########################################################################
MESSAGE(STATUS "")
MESSAGE(STATUS "Configuring interface address discovery...")
-
+INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckIncludeFileCXX)
-CHECK_INCLUDE_FILE_CXX(ifaddrs.h HAVE_IFADDRS_H)
+
+CHECK_CXX_SOURCE_COMPILES("
+ #include <ifaddrs.h>
+ int main(){
+ struct ifaddrs *ifap;
+ getifaddrs(&ifap);
+ return 0;
+ }
+ " HAVE_GETIFADDRS
+)
+
CHECK_INCLUDE_FILE_CXX(winsock2.h HAVE_WINSOCK2_H)
-IF(HAVE_IFADDRS_H)
+IF(HAVE_GETIFADDRS)
MESSAGE(STATUS " Interface address discovery supported through getifaddrs.")
- SET(IF_ADDRS_DEFS HAVE_IFADDRS_H)
+ SET(IF_ADDRS_DEFS HAVE_GETIFADDRS)
ELSEIF(HAVE_WINSOCK2_H)
MESSAGE(STATUS " Interface address discovery supported through SIO_GET_INTERFACE_LIST.")
- SET(IF_ADDRS_DEFS HAVE_WINSOCK2_H)
-ELSE(HAVE_IFADDRS_H)
+ SET(IF_ADDRS_DEFS HAVE_SIO_GET_INTERFACE_LIST)
+ELSE()
MESSAGE(STATUS " Interface address discovery not supported.")
-ENDIF(HAVE_IFADDRS_H)
+ SET(IF_ADDRS_DEFS HAVE_IF_ADDRS_DUMMY)
+ENDIF()
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_SOURCE_DIR}/if_addrs.cpp
diff --git a/host/lib/transport/if_addrs.cpp b/host/lib/transport/if_addrs.cpp
index 17cf8455b..b7c8ad844 100644
--- a/host/lib/transport/if_addrs.cpp
+++ b/host/lib/transport/if_addrs.cpp
@@ -20,14 +20,10 @@
#include <boost/cstdint.hpp>
#include <iostream>
-uhd::transport::if_addrs_t::if_addrs_t(void){
- /* NOP */
-}
-
/***********************************************************************
* Interface address discovery through ifaddrs api
**********************************************************************/
-#if defined(HAVE_IFADDRS_H)
+#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
static boost::asio::ip::address_v4 sockaddr_to_ip_addr(sockaddr *addr){
@@ -59,10 +55,12 @@ std::vector<uhd::transport::if_addrs_t> uhd::transport::get_if_addrs(void){
return if_addrs;
}
+#endif /* HAVE_GETIFADDRS */
+
/***********************************************************************
* Interface address discovery through windows api
**********************************************************************/
-#elif defined(HAVE_WINSOCK2_H)
+#ifdef HAVE_SIO_GET_INTERFACE_LIST
#include <winsock2.h>
std::vector<uhd::transport::if_addrs_t> uhd::transport::get_if_addrs(void){
@@ -98,13 +96,15 @@ std::vector<uhd::transport::if_addrs_t> uhd::transport::get_if_addrs(void){
return if_addrs;
}
+#endif /* HAVE_SIO_GET_INTERFACE_LIST */
+
/***********************************************************************
* Interface address discovery not included
**********************************************************************/
-#else /* HAVE_IFADDRS_H */
+#ifdef HAVE_IF_ADDRS_DUMMY
std::vector<uhd::transport::if_addrs_t> uhd::transport::get_if_addrs(void){
return std::vector<if_addrs_t>();
}
-#endif /* HAVE_IFADDRS_H */
+#endif /* HAVE_IF_ADDRS_DUMMY */