• android CMakeLists


    https://developer.android.google.cn/studio/projects/configure-cmake

    https://blog.csdn.net/songmingzhan/article/details/80720903

    # Sets the minimum version of CMake required to build the native
    # library. You should either keep the default value or only pass a
    # value of 3.4.0 or lower.
    
    cmake_minimum_required(VERSION 3.4.1)
    
    # Creates and names a library, sets it as either STATIC
    # or SHARED, and provides the relative paths to its source code.
    # You can define multiple libraries, and CMake builds it for you.
    # Gradle automatically packages shared libraries with your APK.
    
    add_library(samba_client
                SHARED
                src/main/cpp/jni_helper/JniHelper.cc
                src/main/cpp/jni_helper/JavaClassCache.cc
                src/main/cpp/samba_client/SambaClient.cc
                src/main/cpp/credential_cache/CredentialCache.cc
                )
    
    include_directories(src/main/cpp)
    
    set(CMAKE_CXX_FLAGS
        "${CMAKE_CXX_FLAGS} -std=c++0x -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE")
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie")
    
    # Searches for a specified prebuilt library and stores the path as a
    # variable. Because system libraries are included in the search path by
    # default, you only need to specify the name of the public NDK library
    # you want to add. CMake verifies that the library exists before
    # completing its build.
    
    find_library( # Sets the name of the path variable.
                  log-lib
    
                  # Specifies the name of the NDK library that
                  # you want CMake to locate.
                  log )
    
    # Specifies libraries CMake should link to your target library. You
    # can link multiple libraries, such as libraries you define in the
    # build script, prebuilt third-party libraries, or system libraries.
    
    #set(libfolder "${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}")
    set(libfolder "${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}")
    add_library(libsmbclient
                SHARED
                IMPORTED)
    set_target_properties(libsmbclient
                          PROPERTIES IMPORTED_LOCATION
                          ${libfolder}/libsmbclient.so)
    
    target_link_libraries(samba_client ${log-lib} libsmbclient)
  • 相关阅读:
    directUI
    PyLucene测试成功
    MFC笔记(1)CPaintDC, CClientDC
    sprintf缓冲区溢出
    2.5 攻击示例:对Microsoft C++编译器的攻击 ZZ
    C++笔记(3)类中与类外的运算符重载
    C++笔记(2)public,private,protected关键字
    RTSP协议
    使用虚函数,减少累赘的if/else/switch
    C++笔记(4)成员函数定义在类内与类外
  • 原文地址:https://www.cnblogs.com/pengmn/p/10373156.html
Copyright © 2020-2023  润新知