(New page: == Frequently Asked Questions == These are KDE's FAQ for CMake, there is also a CMake FAQ in the [http://www.cmake.org/Wiki/CMake_FAQ main CMake wiki]. === How can I teach my favorite e...) |
|||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| + | |||
== Frequently Asked Questions == | == Frequently Asked Questions == | ||
| Line 13: | Line 14: | ||
Use this wrapper shell script in the ADD_CUSTOM_COMMAND() as described above. | Use this wrapper shell script in the ADD_CUSTOM_COMMAND() as described above. | ||
You can find out the name and exact location by querying the property WRAPPER_SCRIPT. Here's a full example taken from kdelibs/kstyles/keramik/ : | You can find out the name and exact location by querying the property WRAPPER_SCRIPT. Here's a full example taken from kdelibs/kstyles/keramik/ : | ||
| − | < | + | <syntaxhighlight lang="text"> |
# build the executable | # 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 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 | # and the custom command | ||
| − | + | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h | |
COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt > \ | COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt > \ | ||
${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik | ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik | ||
DEPENDS genembed ${keramikPics} | DEPENDS genembed ${keramikPics} | ||
) | ) | ||
| − | </ | + | </syntaxhighlight> |
As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule. | As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule. | ||
| Line 38: | Line 39: | ||
=== How do I tell cmake to create noisy makefiles? I want to see the exact commands that are run during the make process. === | === How do I tell cmake to create noisy makefiles? I want to see the exact commands that are run during the make process. === | ||
Pass the VERBOSE variable to make, i.e. | Pass the VERBOSE variable to make, i.e. | ||
| − | < | + | <syntaxhighlight lang="text"> |
% make VERBOSE=1 | % make VERBOSE=1 | ||
| − | </ | + | </syntaxhighlight> |
or | or | ||
| − | < | + | <syntaxhighlight lang="text"> |
% VERBOSE=1 make | % VERBOSE=1 make | ||
| − | </ | + | </syntaxhighlight> |
For more details see the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?] | For more details see the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?] | ||
| Line 57: | Line 58: | ||
'''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): | '''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): | ||
| − | < | + | <syntaxhighlight lang="text"> |
optimized;C:/kde4/lib/QtNetwork4.lib;debug;C:/kde4/lib/QtNetworkd4.lib | optimized;C:/kde4/lib/QtNetwork4.lib;debug;C:/kde4/lib/QtNetworkd4.lib | ||
^^^^^^^^^ | ^^^^^^^^^ | ||
| − | </ | + | </syntaxhighlight> |
The first <tt>optimized</tt> part is translated by cmake to optimized.lib so we have got the ''cannot open file 'optimized.lib' error.'' | The first <tt>optimized</tt> part is translated by cmake to optimized.lib so we have got the ''cannot open file 'optimized.lib' error.'' | ||
These are KDE's FAQ for CMake, there is also a CMake FAQ in the main CMake wiki.
Read the CMake Wiki section CMake Editors Support. It describes how to setup Emacs (XEmacs works too), VIM, Kate, KWrite, and KDevelop.
Use ADD_CUSTOM_COMMAND(). It's explained here in the CMake wiki: How can I generate a source file during the build
Let's say the executable is called genembed. Then use KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})to create the executable. The RUN_UNINSTALLED option is important, because the executable has to run from the build dir and has to link to the libraries in the builddir. To achieve this, the executable is compiled with RPATH set accordingly and a wrapper shell script, named just like the executable but with the suffix ".sh" is created. This shell scripts sets up LD_LIBRARY_PATH and the calls the actual executable. Use this wrapper shell script in the ADD_CUSTOM_COMMAND() as described above. You can find out the name and exact location by querying the property WRAPPER_SCRIPT. Here's a full example taken from 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}
)As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule.
No. $KDEDIR is deprecated in KDE 4.
A: If you have an old Qt4 version in your qt/lib directory you must delete the old (4.0.1) files.
Pass the VERBOSE variable to make, i.e.
% make VERBOSE=1
or
% VERBOSE=1 make
For more details see the CMake wiki: Is there an option to produce more 'verbose' compiling?
Simply remove the build directory, or just the contents of the build directory.
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.