CMake:How To Build KDE4 Software: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Let's just start with a simple example for an application, let's name it, well, kFoo | Let's just start with a simple example for an application, let's name it, well, kFoo. The CMakeLists.txt below gives the project a name, so that the project files for KDevelop/XCode/MSVC will have a good name. It will then find the KDE 4 installation on the system and setup the required include directories. The list of source files will be put into a variable named mySources, which will be automoced and then used to build an executable from it. The executable and its desktop file will finally be installed. | ||
<pre> | <pre> | ||
project(kfoo) | project(kfoo) | ||
find_package(KDE4 REQUIRED) | find_package(KDE4 REQUIRED) | ||
include_directories( ${KDE4_INCLUDES} ) | include_directories( ${KDE4_INCLUDES} ) | ||
set(mySources main.cpp mywidget.cpp mypart.cpp) | set(mySources main.cpp mywidget.cpp mypart.cpp) | ||
kde4_automoc( ${mySources} ) | kde4_automoc( ${mySources} ) | ||
kde4_add_executable(kfoo ${mySources}) | kde4_add_executable(kfoo ${mySources}) | ||
target_link_libraries(kfoo ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) | target_link_libraries(kfoo ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) | ||
install_targets( /bin kfoo) | install_targets( /bin kfoo) | ||
install_files( ${XDG_APPS_DIR} FILES kfoo.desktop) | install_files( ${XDG_APPS_DIR} FILES kfoo.desktop) | ||
</pre> | </pre> |
Revision as of 21:13, 30 March 2006
Let's just start with a simple example for an application, let's name it, well, kFoo. The CMakeLists.txt below gives the project a name, so that the project files for KDevelop/XCode/MSVC will have a good name. It will then find the KDE 4 installation on the system and setup the required include directories. The list of source files will be put into a variable named mySources, which will be automoced and then used to build an executable from it. The executable and its desktop file will finally be installed.
project(kfoo) find_package(KDE4 REQUIRED) include_directories( ${KDE4_INCLUDES} ) set(mySources main.cpp mywidget.cpp mypart.cpp) kde4_automoc( ${mySources} ) kde4_add_executable(kfoo ${mySources}) target_link_libraries(kfoo ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) install_targets( /bin kfoo) install_files( ${XDG_APPS_DIR} FILES kfoo.desktop)