整个CMakeLists.txt文件如下
带# *的是个人增加的解读
cmake_minimum_required(VERSION 3.5)project(rkipc)# *这里是选择什么类型的编译入口
# *通过缺省情况下,所有的都设置为 OFF
# *在BoardConfig 文件中 export RK_APP_TYPE=RKIPC_RV1106
# *则 ../Makefile 中 -DCOMPILE_FOR_RV1106_IPC=ON 重新设置 此处的值为 ON
# *通过判断 添加对应的源文件 add_subdirectory(src/rv1106_ipc)option(COMPILE_FOR_RV1103_IPC "compile for rv1103 ipc" OFF)
option(COMPILE_FOR_RV1106_IPC "compile for rv1106 ipc" OFF)
option(COMPILE_FOR_RV1106_BATTERY_IPC_TUYA "compile for rv1106 battery ipc tuya" OFF)
option(COMPILE_FOR_RV1106_BATTERY_IPC_CLIENT "compile for rv1106 battery ipc client" OFF)
option(COMPILE_FOR_RV1106_DUAL_IPC "compile for rv1106 dual-ipc" OFF)option(COMPILE_FOR_RV1126_RKMEDIA "compile for rv1126 ipc rkmedia" OFF)
option(COMPILE_FOR_RV1126_ROCKIT "compile for rv1126 ipc rockit" OFF)
option(COMPILE_FOR_RV1126_BATTERY_IPC "compile for rv1126 battery ipc" OFF)
option(COMPILE_FOR_RV1126_SNAPSHOT "compile for rv1126 snapshot" OFF)option(COMPILE_FOR_RK3588 "compile for rk3588 ipc" OFF)
option(COMPILE_FOR_RK3588_MULTI_IPC "compile for rk3588 multi-ipc" OFF)# *这个由 build.sh的option控制,通过../Makefile 的-D传递过来
if(${CMAKE_BUILD_TYPE} STREQUAL Debug)message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")add_definitions(-g -ggdb -gdwarf -funwind-tables -rdynamic -O0)add_definitions(-fno-stack-protector -fno-omit-frame-pointer)
elseif(${CMAKE_BUILD_TYPE} STREQUAL Release)message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
elseif(${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
elseif(${CMAKE_BUILD_TYPE} STREQUAL MinSizeRel)message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")add_definitions(-Os)
endif()# *交叉编译器
if(RKIPC_CROSS_COMPILE)
message(STATUS "CROSS COMPILE TOOL: ${RKIPC_CROSS_COMPILE}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wl,-rpath-link,${PROJECT_SOURCE_DIR}/lib/${RKIPC_CROSS_COMPILE}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections -Wl,-rpath-link,${PROJECT_SOURCE_DIR}/lib/${RKIPC_CROSS_COMPILE}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--as-needed")
endif()# *判断添加哪个文件夹的源文件。
if(COMPILE_FOR_RV1103_IPC)add_subdirectory(src/rv1103_ipc)
endif()if(COMPILE_FOR_RV1106_IPC)add_subdirectory(src/rv1106_ipc)
endif()if(COMPILE_FOR_RV1106_BATTERY_IPC_TUYA)add_subdirectory(src/rv1106_battery_ipc_tuya)
endif()if(COMPILE_FOR_RV1106_BATTERY_IPC_CLIENT)add_subdirectory(src/rv1106_battery_ipc_client)
endif()if(COMPILE_FOR_RV1106_DUAL_IPC)add_subdirectory(src/rv1106_dual_ipc)
endif()if(COMPILE_FOR_RV1126_RKMEDIA)add_subdirectory(src/rv1126_ipc_rkmedia)
endif()if(COMPILE_FOR_RV1126_ROCKIT)add_subdirectory(src/rv1126_ipc_rockit)
endif()if(COMPILE_FOR_RV1126_BATTERY_IPC)add_subdirectory(src/rv1126_battery_ipc)
endif()if(COMPILE_FOR_RV1126_SNAPSHOT)add_subdirectory(src/rv1126_snapshot)
endif()if(COMPILE_FOR_RK3588)add_subdirectory(src/rk3588_ipc)
endif()if(COMPILE_FOR_RK3588_MULTI_IPC)add_subdirectory(src/rk3588_multi_ipc)
endif()