getifaddrs missing more user friendly in CMake. 37/3137/1
authorJoakim Soderberg <joakim.soderberg@gmail.com>
Fri, 22 Feb 2013 01:28:02 +0000 (09:28 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:38 +0000 (13:01 -0800)
Don't require the user to enable using the built-in BSD getifaddrs implementation on systems such as uclibc that lacks it manually.

Instead if getifaddrs doesn't exist, use the BSD one automatically, except if the user explicitly tells the user not to do this using WITHOUT_BUILTIN_GETIFADDRS (which will result in a compilation error, but at least with a nice error message explaining why).

CMakeLists.txt

index 505bba0..0d4fb89 100644 (file)
@@ -31,7 +31,7 @@ endif()
 option(WITH_SSL "Include SSL support (default OpenSSL, CyaSSL if USE_CYASSL is set)" ON)
 option(USE_EXTERNAL_ZLIB "Search the system for ZLib instead of using the included one (on Windows)" OFF)
 option(USE_CYASSL "Use CyaSSL replacement for OpenSSL. When settings this, you also need to specify CYASSL_LIB and CYASSL_INCLUDE_DIRS" OFF)
-option(WITH_BUILTIN_GETIFADDRS "Use BSD getifaddrs implementation from libwebsockets... default is your libc provides it" OFF)
+option(WITHOUT_BUILTIN_GETIFADDRS "Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist." OFF)
 option(WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
 option(WITHOUT_CLIENT "Don't build the client part of the library" OFF)
 option(WITHOUT_SERVER "Don't build the server part of the library" OFF)
@@ -146,10 +146,11 @@ CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
 CHECK_FUNCTION_EXISTS(vfork HAVE_VFORK)
 CHECK_FUNCTION_EXISTS(getifaddrs HAVE_GETIFADDRS)
 
-if (WITH_BUILTIN_GETIFADDRS)
-       if (HAVE_GETIFADDRS)
-               warning("getifaddrs already exists on the system, are you sure you want to build using the BSD version? (This is normally only needed on systems running uclibc)")
+if (NOT HAVE_GETIFADDRS)
+       if (WITHOUT_BUILTIN_GETIFADDRS)
+               message(FATAL_ERROR "No getifaddrs was found on the system. Turn off the WITHOUT_BUILTIN_GETIFADDRS compile option to use the supplied BSD version.")
        endif()
+
        set(LWS_BUILTIN_GETIFADDRS 1)
 endif()
 
@@ -264,7 +265,7 @@ else()
 endif()
 
 if (UNIX)
-       if (NOT WITH_BUILTIN_GETIFADDRS)
+       if (NOT HAVE_GETIFADDRS)
                list(APPEND HDR_PRIVATE lib/getifaddrs.h)
                list(APPEND SOURCES lib/getifaddrs.c)
        endif()