<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>
"); //-->

博客專(zhuān)欄

EEPW首頁(yè) > 博客 > CMake通過(guò)外部傳參執行不同邏輯的2種方案

CMake通過(guò)外部傳參執行不同邏輯的2種方案

發(fā)布人:電子禪石 時(shí)間:2024-11-15 來(lái)源:工程師 發(fā)布文章

有時(shí)候一些場(chǎng)景需要在執行cmake指令時(shí)傳入一些參數的值,使得CMakeLists.txt文件中的程序執行不同的邏輯,下面給出2種方案。

1、SET指令給參數默認值

SET(BUILD_PLATFORM "x86" CACHE STRING "select build cpu type")
 # 外部用cmake . -DBUILD_PLATFORM=arm進(jìn)行值傳入,便可以執行不同的邏輯
if (BUILD_PLATFORM STREQUAL arm)
  message("this is arm platform")
else()
  message("this is x86 platform")
endif()

   默認情況下會(huì )執行else,打印“this is x86 platform”,但可以更改,比如運行cmake指令時(shí)如下:

        cmake . -DBUILD_PLATFORM=arm

  那么打印出來(lái)的是“this is arm platform”。

2、OPTION指令開(kāi)關(guān)

option(USE_AEC "Set to switch to build use AEC"  OFF)
# 外部用cmake . -DUSE_AEC=ON進(jìn)行值傳入,便可以執行不同的邏輯
if (USE_AEC) #根據宏開(kāi)關(guān)判斷邏輯
    message("use aec to restrict audio echo")
else()
    message("do not use aec")
endif()

  默認情況下會(huì )執行else,打印“do not use aec”,但若運行cmake指令時(shí)如下:

        cmake . -DUSE_AEC=ON

    則會(huì )打印出“use aec to restrict audio echo”。


*博客內容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀(guān)點(diǎn),如有侵權請聯(lián)系工作人員刪除。



關(guān)鍵詞: cmake

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>