CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # For more information about using CMake with Android Studio, read the
  2. # documentation: https://d.android.com/studio/projects/add-native-code.html
  3. # Sets the minimum version of CMake required to build the native library.
  4. cmake_minimum_required(VERSION 3.4.1)
  5. # Creates and names a library, sets it as either STATIC
  6. # or SHARED, and provides the relative paths to its source code.
  7. # You can define multiple libraries, and CMake builds them for you.
  8. # Gradle automatically packages shared libraries with your APK.
  9. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})
  10. add_library( # Sets the name of the library.
  11. SerialPortJni
  12. # Sets the library as a shared library.
  13. SHARED
  14. # Provides a relative path to your source file(s).
  15. src/main/cpp/SerialPort.cpp
  16. )
  17. # Searches for a specified prebuilt library and stores the path as a
  18. # variable. Because CMake includes system libraries in the search path by
  19. # default, you only need to specify the name of the public NDK library
  20. # you want to add. CMake verifies that the library exists before
  21. # completing its build.
  22. find_library( # Sets the name of the path variable.
  23. log-lib
  24. # Specifies the name of the NDK library that
  25. # you want CMake to locate.
  26. log )
  27. # Specifies libraries CMake should link to your target library. You
  28. # can link multiple libraries, such as libraries you define in this
  29. # build script, prebuilt third-party libraries, or system libraries.
  30. target_link_libraries( # Specifies the target library.
  31. SerialPortJni
  32. # Links the target library to the log library
  33. # included in the NDK.
  34. ${log-lib}
  35. )