code style

2016年10月24日 星期一

CMake筆記(4) - 運算子

邏輯運算:

當 expr 值為 FALSE 時成立。
if(NOT <expr> )
當 expr1 和 expr2 同時為 TRUE 時成立。
if(<expr1> AND <expr2> )

當 expr1 和 expr2 至少其中之一為 TRUE 時成立。
if(<expr1&gt OR <expr2> )

數值比較:
if(variable LESS number)
if(string LESS number)

if(variable GREATER number)
if(string GREATER number)

if(variable EQUAL number)
if(string EQUAL number)

字串比較:
if(variable STRLESS string)
if(string STRLESS string)

if(variable STRGREATER string)
if(string STRGREATER string)

if(variable STREQUAL string)
if(string STREQUAL string)

字串比較依照 字母順序決定大小。 LESS、GREATER、EQUAL、STRLESS、

STRGREATER、STREQUAL 會分別檢查左右運算元是否為已定義過的變數,若是則採用變數值,否則視為字串。這點在比較中通用,只要不是變數,就視為字串。

Regular Expression 比對:
if(EXISTS file-name)
if(EXISTS directory-name)

檔案相關:
只支援絕對路徑
判斷檔案和資料夾是否存在。
if(EXISTS file-name)
if(EXISTS directory-name)

當 file1 比 file2 新,或者其中一個檔案不存在時。
if(file1 IS_NEWER_THAN file2)

判斷給定的path是否是絕對路徑。

if(IS_ABSOLUTE path)

其它:
判斷給定的 command-name 是否屬於指令、function、macro。

if(COMMAND command-name)

判斷給定的 variable-name 是否已經被定義過。

if(DEFINED variable-name)

沒有留言:

張貼留言