Cmake一次编译多个cpp

来源:互联网 发布:阿里云培训 编辑:程序博客网 时间:2024/06/05 06:19


Module下有一个CMakeLists.txt   的文件  默认内容是这样的,(只贴了需要改动的部分)

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( # Sets the name of the library.             native-lib             # Sets the library as a shared library.             SHARED             # Provides a relative path to your source file(s).             # Associated headers in the same location as their source             # file are automatically included.             src/main/cpp/native-lib.cpp )


改为


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.file(GLOB native_srcs "src/main/cpp/*.cpp")add_library( # Sets the name of the library.             native-lib             # Sets the library as a shared library.             SHARED             # Provides a relative path to your source file(s).             # Associated headers in the same location as their source             # file are automatically included.             ${native_srcs})


哈哈,大功告成!再多个cpp都不成问题啦!快去动手试试吧

原创粉丝点击