CMake通過外部傳參執行不同邏輯的2種方案
SET(BUILD_PLATFORM "x86" CACHE STRING "select build cpu type") # 外部用cmake . -DBUILD_PLATFORM=arm進行值傳入,便可以執行不同的邏輯 if (BUILD_PLATFORM STREQUAL arm) message("this is arm platform") else() message("this is x86 platform") endif()
2、OPTION指令開關
option(USE_AEC "Set to switch to build use AEC" OFF) # 外部用cmake . -DUSE_AEC=ON進行值傳入,便可以執行不同的邏輯 if (USE_AEC) #根據宏開關判斷邏輯 message("use aec to restrict audio echo") else() message("do not use aec") endif()
*博客內容為網友個人發布,僅代表博主個人觀點,如有侵權請聯系工作人員刪除。