美文网首页
AndroidStudio用Build Output查看CMak

AndroidStudio用Build Output查看CMak

作者: Epimenides | 来源:发表于2020-07-28 19:18 被阅读0次

    CMake可以通过message命令进行打印内容,但是在AndroidStudio中使用不同版本的CMake会导致message输出形式不同。

    CMake可以通过message命令进行打印内容,但是在AndroidStudio中使用不同版本的CMake会导致message输出形式不同。

    我借鉴这位博主的经验后借鉴链接将项目root目录下的build.gradle中的CMake版本改成了version "3.6.0"后就可以看到编译输出了。

    具体gradle文件如下:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 30
        buildToolsVersion "30.0.0"
    
        defaultConfig {
            applicationId "com.epimenides.cmakedemo"
            minSdkVersion 25
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    
            externalNativeBuild {
                cmake {
                    cppFlags ""
                }
            }
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    
        externalNativeBuild {
            cmake {
                path "src/main/cpp/CMakeLists.txt"
                version "3.6.0"
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    }
    

    最后得到的Sync输出提示为:

    debug|x86 :-- Check for working C compiler: D:/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
    debug|x86 :-- Check for working C compiler: D:/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
    debug|x86 :-- Detecting C compiler ABI info
    debug|x86 :-- Detecting C compiler ABI info - done
    debug|x86 :-- Detecting C compile features
    debug|x86 :-- Detecting C compile features - done
    debug|x86 :-- Check for working CXX compiler: D:/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
    debug|x86 :-- Check for working CXX compiler: D:/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
    debug|x86 :-- Detecting CXX compiler ABI info
    debug|x86 :-- Detecting CXX compiler ABI info - done
    debug|x86 :-- Detecting CXX compile features
    debug|x86 :-- Detecting CXX compile features - done
    debug|x86 :var = 123
    debug|x86 :-- Configuring done
    debug|x86 :-- Generating done
    debug|x86 :CMake Warning:
    debug|x86 :  Manually-specified variables were not used by the project:
    debug|x86 :    CMAKE_ANDROID_NDK
    debug|x86 :-- Build files have been written to: F:/AndroidStudioProjects/CMakeDemo/app/.cxx/cmake/debug/x86
    
    CONFIGURE SUCCESSFUL in 3s
    

    可以得到结论: 编译文件的最终会被写入到

    $your-proj/$your-module/.cxx/cmake/debug/x86
    

    目录下的build_output.txt文件当中

    相关文章

      网友评论

          本文标题:AndroidStudio用Build Output查看CMak

          本文链接:https://www.haomeiwen.com/subject/udjqrktx.html