User:Argonel/Development/CMake/Addons for KDE/Macros

From KDE TechBase

Macros

Lots of useful macros: KDE4Macros.cmake

KDE4_ADD_UI_FILES (SRCS_VAR file1.ui ... fileN.ui)
Use this to add Qt designer ui files to your application/library.
KDE4_ADD_UI3_FILES (SRCS_VAR file1.ui ... fileN.ui)
Use this to add Qt designer ui files from Qt version 3 to your application/library.
KDE4_ADD_KCFG_FILES (SRCS_VAR [GENERATE_MOC] file1.kcfgc ... fileN.kcfgc)
Use this to add KDE config compiler files to your application/library.
  • Add optional GENERATE_MOC to generate moc if you use signals in your kcfg files.
KDE4_ADD_WIDGET_FILES (SRCS_VAR file1.widgets ... fileN.widgets)
Use this to add widget description files for the makekdewidgets code generator for Qt Designer plugins.
KDE4_ADD_PLUGIN ( name [WITH_PREFIX] file1 ... fileN )
Create a KDE plugin (KPart, kioslave, etc.) from the given source files.
  • Supports KDE4_ENABLE_FINAL.
  • If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", otherwise it won't.
  • Creates and installs an appropriate libtool la-file.
KDE4_ADD_KDEINIT_EXECUTABLE (name [NOGUI] [RUN_UNINSTALLED] file1 ... fileN)
Create a KDE application in the form of a module loadable via kdeinit.
  • A library named kdeinit_<name> will be created and a small executable which links to it.
  • Supports KDE4_ENABLE_FINAL
  • If the executable has to be run from the buildtree (e.g. unit tests and code generators used later on when compiling), set the option RUN_UNINSTALLED.
  • If the executable doesn't have a GUI, use the option NOGUI. By default on OS X application bundles are created, with the NOGUI option no bundles but simple executables are created. Currently it doesn't have any effect on other platforms.
KDE4_ADD_EXECUTABLE (name [NOGUI] [RUN_UNINSTALLED] file1 ... fileN)
Equivalent to ADD_EXECUTABLE(), but additionally adds some more features:
  • support for KDE4_ENABLE_FINAL
  • support for atomic
  • automatic RPATH handling
  • If the executable has to be run from the buildtree (e.g. unit tests and code generators used later on when compiling), set the option RUN_UNINSTALLED.
  • If the executable doesn't have a GUI, use the option NOGUI. By default on OS X application bundles are created, with the NOGUI option no bundles but simple executables are created. Currently it doesn't have any effect on other platforms.
KDE4_ADD_LIBRARY (name [STATIC | SHARED | MODULE ] file1 ... fileN)
Equivalent to ADD_LIBRARY(), but additionally it supports KDE4_ENABLE_FINAL
  • Under Windows, -DMAKE_<name>_LIB definition is added to the compilation.
KDE4_ADD_UNIT_TEST (testname [TESTNAME targetname] file1 ... fileN)
Add a unit test, which is executed when running make test
  • It will be built with RPATH pointing to the build dir
  • The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.
  • The name of the target can be specified using TESTNAME <targetname>, if it is not given the macro will default to the <testname>
KDE4_ADD_TEST_EXECUTABLE (name file1 ... fileN)
Add a test executable
  • It will be built with RPATH pointing to the build dir
  • The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.
  • KDESRCDIR is set to the source directory of the test, this can be used to enable the use of xmlgui and other things in the test that normally require installation
    Example
    KGlobal::dirs()->addResourceDir( "data", KDESRCDIR );
    
KDE4_UPDATE_ICONCACHE ()
Notifies the icon cache that new icons have been installed by updating mtime of the ${ICON_INSTALL_DIR}/hicolor directory.
KDE4_INSTALL_ICONS (path theme)
Installs all png and svgz files in the current directory that comply to the icon naming scheme to the icon directory given in PATH, in the subdirectory for the given icon THEME.
KDE4_ADD_APP_ICON (appsources pattern)
Mac OS X and Windows only:
  • Adds application icon to target source list. This macro adds an application icon to the specified target.
Mac OS X notes:
  • The application icon is added to a Mac OS X bundle so that Finder and friends show the right thing. You need to provide a 128x128 version of the icon for this to work.
Windows notes:
  • The application icon(s) are compiled into the application binary.
Parameters
appsources
specifies the list of source files
pattern
regular expression for searching application icons
Examples
KDE4_ADD_APP_ICON(myapp_sources "pics/cr*-myapp.png")
KDE4_ADD_APP_ICON(myapp_sources "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/apps/myapp.png")
KDE4_CREATE_HANDBOOK( docbookfile )
Create the handbook from the docbookfile (using meinproc)
KDE4_MOC_HEADERS
KDE4_HANDLE_AUTOMOC
KDE4_CREATE_FINAL_FILES
KDE4_REMOVE_OBSOLETE_CMAKE_FILES
KDE4_NO_ENABLE_FINAL
Deprecated
KDE4_SET_CUSTOM_TARGET_PROPERTY
KDE4_GET_CUSTOM_TARGET_PROPERTY