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.