2012-01-03 64 views
18

如何在CMakeLists.txt中指定字符串option?語法option(OPT1 "Helpstring" ON)完美適用於布爾選項,但我想有幾個字符串選項,如-march=參數傳遞給gccCMAKE字符串選項

回答

23

任何用戶可設置的變量可以被定義:

set(OPT2 "Default" CACHE STRING "Helpstring") 

所以-​​march會是這樣的:

set(ARCH "" CACHE STRING "Architecture to tell gcc to optimize for (-march)") 
+4

用例:'MKDIR構建;光盤建立; cmake .. -DARCH = native' – olibre 2015-12-09 18:14:59