前言:研究別人代碼喊巍,發(fā)現(xiàn)google現(xiàn)在推薦并在Android Studio 支持cmkelist 放棄mk方式屠缭。比較蛋疼,但是也是學(xué)習(xí)的一個方式崭参。一步步積累如何使用Cmakelist
對比
- LOCAL_MODULE,LOCAL_SRC_FILES
mk 寫法,整個mk文件我拆分兩部分呵曹,主要是為了學(xué)習(xí)寫法
前部分
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := KRoom
LOCAL_SRC_FILES := KRoom.cpp \
./manager/JniManager.cpp \
./manager/AVMediaPlayer.cpp \
./manager/AudioManager.cpp \
./manager/VideoManager.cpp \
./opengl/NativeRender.cpp \
./common/Buffer.cpp \
./common/Mutex.cpp \
./common/Frame.cpp \
./common/FrameMap.cpp \
./common/FrameList.cpp \
./common/FrameSub.cpp \
./common/FrameSubMap.cpp \
./common/util.cpp \
./stream/StreamDecoder.cpp \
./stream/StreamPlayer.cpp \
./vedio/VideoDecoder.cpp \
./shellmp4/FileControl.cpp \
./shellmp4/HttpShellInterface.cpp \
./shellmp4/MakeAACHead.cpp \
./shellmp4/MP4Control.cpp \
./shellmp4/MP4Handler.cpp \
./shellmp4/ShellMain.cpp \
./shellmp4/ShellMp4.cpp \
./shellmp4/GetData.cpp \
check.c \
md5.c
后部分
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
# for native audio
LOCAL_LDLIBS += -lOpenSLES
# for native bitmap
LOCAL_LDLIBS += -ljnigraphics
# for native opengl es v2
LOCAL_LDLIBS += -lGLESv2
# for native opengl es v1
LOCAL_LDLIBS += -lGLESv1_CM
# for native asset manager
LOCAL_LDLIBS += -landroid
LOCAL_CFLAGS += -g
LOCAL_STATIC_LIBRARIES := avcodec avutil x264 macdecoder reverb
#LOCAL_STATIC_LIBRARIES := faad2 faac avcodec avutil x264 macdecoder reverb
LOCAL_SHARED_LIBRARIES := decoding
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/ffmpeg/ \
$(LOCAL_PATH)/shellmp4/
include $(BUILD_SHARED_LIBRARY)
轉(zhuǎn)換成cmakelist寫法超級簡單
add_library( # Sets the name of the library.
KRoom
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
./main/cpp/kroom/KRoom.cpp
./main/cpp/kroom/manager/JniManager.cpp
./main/cpp/kroom/manager/AVMediaPlayer.cpp
./main/cpp/kroom/manager/AudioManager.cpp
./main/cpp/kroom/manager/VideoManager.cpp
./main/cpp/kroom/opengl/NativeRender.cpp
./main/cpp/kroom/common/Buffer.cpp
./main/cpp/kroom/common/Mutex.cpp
./main/cpp/kroom/common/Frame.cpp
./main/cpp/kroom/common/FrameMap.cpp
./main/cpp/kroom/common/FrameList.cpp
./main/cpp/kroom/common/FrameSub.cpp
./main/cpp/kroom/common/FrameSubMap.cpp
./main/cpp/kroom/common/util.cpp
./main/cpp/kroom/stream/StreamDecoder.cpp
./main/cpp/kroom/stream/StreamPlayer.cpp
./main/cpp/kroom/vedio/VideoDecoder.cpp
./main/cpp/kroom/shellmp4/FileControl.cpp
./main/cpp/kroom/shellmp4/HttpShellInterface.cpp
./main/cpp/kroom/shellmp4/MakeAACHead.cpp
./main/cpp/kroom/shellmp4/MP4Control.cpp
./main/cpp/kroom/shellmp4/MP4Handler.cpp
./main/cpp/kroom/shellmp4/ShellMain.cpp
./main/cpp/kroom/shellmp4/ShellMp4.cpp
./main/cpp/kroom/shellmp4/GetData.cpp
./main/cpp/kroom/check.c
./main/cpp/kroom/md5.c )