Template:I18n/Language Navigation Bar (zh TW)
These are KDE's FAQ for CMake, there is also a CMake FAQ in the main CMake wiki.
請閱讀CMake Wiki 的 CMake 編輯器支援章節。這裡說明如何設定 Emacs(XEmacs works too)、VIM、Kate、KWrite 和 KDevelop。
使用 ADD_CUSTOM_COMMAND()。在 CMake wiki 的如何在建構過程中生成原始碼檔案有解釋
假設可執行檔叫 genembed。那麼使用 KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})來建立可執行檔。RUN_UNINSTALLED 選項非常重要,因為可執行檔必須從建構目錄執行,並會連結到建構目錄中的一些函式庫。為了達成這個目的,可執行檔透過 RPATH 設定和 shell 腳本包裝編譯,和執行檔的名稱一樣只是多了個「.sh」。這個 shell 腳本建立 LD_LIBRARY_PATH 並呼叫實際的執行檔。
依照上面說明的在 ADD_CUSTOM_COMMAND() 中使用這個 shell 腳本包裝。 您可以通過查詢 WRAPPER_SCRIPT 來找到名稱和確切的路徑。這裡有一個來自 kdelibs/kstyles/keramik/ 的完整例子:
# build the executable
kde4_add_executable(genembed RUN_UNINSTALLED ${genembed_SRCS})
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)
get_target_property(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)
# and the custom command
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h
COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt > \
${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik
DEPENDS genembed ${keramikPics}
)如你所見 genembed 也做為相賴關係列出。這表示 CMake 知道它應該在執行這些規則之前建構 genembed 執行檔。
不。KDE 4 反對使用 $KDEDIR。
如果你有舊版的 Qt 4 在 qt/lib 目錄,你必須刪除這些舊版(4.0.1)檔案。
傳遞 VERBOSE 變數給 make,例如:
% make VERBOSE=1
或
% VERBOSE=1 make
更多細節請查看 CMake wiki:有沒有選項可以產生更多的'verbose'編譯?
只需刪除建構目錄,或建構目錄裡的內容。
This is a problem with KDE's CMakeLists.txt and CMake 2.6.0 and 2.6.1, it will be fixed soon.
QT_*_LIBRARIES must not be used in your target_link_libraries() line of CMakeLists.txt. Use QT_*_LIBRARY instead. Otherwise the variable will look like this (example for QT_QTNETWORK_LIBRARY):
optimized;C:/kde4/lib/QtNetwork4.lib;debug;C:/kde4/lib/QtNetworkd4.lib ^^^^^^^^^
The first optimized part is translated by cmake to optimized.lib so we have got the cannot open file 'optimized.lib' error.