j0r1 / JRTPLIB

RTP Library
MIT License
581 stars 220 forks source link

Update CMakeLists.txt to include FORCE_RTP_SUPPORT_IFADDRS_FALSE to it can be built on gradle #11

Closed lattice0 closed 6 years ago

lattice0 commented 6 years ago

Thanks to this answer: https://stackoverflow.com/a/49980222/6655884, If the android API is below 24, it will have ifaddrs.h but it'll now have the freeifaddrs and getifaddrs functions, so that's why the test failed for me.

I added the variable FORCE_RTP_SUPPORT_IFADDRS_FALSE to force it to be false after the test happens.

As an example, I was able to compile using gradle by doing:

defaultConfig {
        applicationId "com.jscam"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        externalNativeBuild {
            cmake {
                arguments "-DFORCE_RTP_SUPPORT_IFADDRS_FALSE=TRUE"
            }
        }
    }

    // Encapsulates your external native build configurations.
    externalNativeBuild {

        // Encapsulates your CMake build configurations.
        cmake {
            // Provides a relative path to your CMake build script.
            path "../../JRTPLIB/CMakeLists.txt"
        }
    }
j0r1 commented 6 years ago

Thanks for following up on this!

So if I understand correctly, ifaddrs.h exists, but the required functions are not defined, right? In that case, wouldn't it be cleaner to check if the functions exist as well? I've created a branch 'ifaddrs' that tries to do this, can you test if this works for you?

lattice0 commented 6 years ago

Yes, much better this way. Just tested and it works!

j0r1 commented 6 years ago

Great! Thanks for testing, I've merged it with the master branch.