kdelibs/cmake/modules/FindKDE4Internal.cmake

1025 lines
52 KiB
CMake
Raw Normal View History

2014-11-13 01:04:59 +02:00
# - Find the KDE4 include and library dirs, KDE preprocessors and define a some macros
#
# This module defines the following variables:
#
# KDE4_FOUND - set to TRUE if everything required for building KDE software has been found
#
# KDE4_DEFINITIONS - compiler definitions required for compiling KDE software
# KDE4_INCLUDE_DIR - the KDE 4 include directory
# KDE4_INCLUDES - all include directories required for KDE, i.e.
# KDE4_INCLUDE_DIR, but also the Qt4 include directories
# and other platform specific include directories
# KDE4_LIB_DIR - the directory where the KDE libraries are installed,
# intended to be used with LINK_DIRECTORIES(). In general, this is not necessary.
# KDE4_LIBEXEC_INSTALL_DIR - the directory where libexec executables from kdelibs are installed
# KDE4_BIN_INSTALL_DIR - the directory where executables from kdelibs are installed
# KDE4_SBIN_INSTALL_DIR - the directory where system executables from kdelibs are installed
# KDE4_DATA_INSTALL_DIR - the parent directory where kdelibs applications install their data
# KDE4_CONFIG_INSTALL_DIR - the directory where config files from kdelibs are installed
# KDE4_ICON_INSTALL_DIR - the directory where icons from kdelibs are
# KDE4_IMPORTS_INSTALL_DIR - the directory where imports from kdelibs are
# KDE4_KCFG_INSTALL_DIR - the directory where kconfig files from kdelibs are installed
# KDE4_LOCALE_INSTALL_DIR - the directory where translations from kdelibs are installed
# KDE4_MIME_INSTALL_DIR - the directory where mimetype desktop files from kdelibs are installed
# KDE4_SOUND_INSTALL_DIR - the directory where sound files from kdelibs are installed
# KDE4_TEMPLATES_INSTALL_DIR - the directory where templates (Create new file...) from kdelibs are installed
# KDE4_WALLPAPER_INSTALL_DIR - the directory where wallpapers from kdelibs are installed
# KDE4_KCONF_UPDATE_INSTALL_DIR - the directory where kconf_update files from kdelibs are installed
# KDE4_AUTOSTART_INSTALL_DIR - the directory where autostart from kdelibs are installed
# KDE4_XDG_APPS_INSTALL_DIR - the XDG apps dir from kdelibs
# KDE4_XDG_DIRECTORY_INSTALL_DIR - the XDG directory from kdelibs
# KDE4_SYSCONF_INSTALL_DIR - the directory where sysconfig files from kdelibs are installed
# KDE4_MAN_INSTALL_DIR - the directory where man pages from kdelibs are installed
# KDE4_INFO_INSTALL_DIR - the directory where info files from kdelibs are installed
# KDE4_DBUS_INTERFACES_DIR - the directory where dbus interfaces from kdelibs are installed
# KDE4_DBUS_SERVICES_DIR - the directory where dbus service files from kdelibs are installed
#
# The following variables are defined for the various tools required to
# compile KDE software:
#
# KDE4_KCFGC_EXECUTABLE - the kconfig_compiler executable
# KDE4_MAKEKDEWIDGETS_EXECUTABLE - the makekdewidgets executable
#
# The following variables point to the location of the KDE libraries,
# but shouldn't be used directly:
#
# KDE4_KDECORE_LIBRARY - the kdecore library
# KDE4_KDEUI_LIBRARY - the kdeui library
# KDE4_KIO_LIBRARY - the kio library
# KDE4_KPARTS_LIBRARY - the kparts library
# KDE4_KEMOTICONS_LIBRARY - the kemoticons library
# KDE4_KIDLETIME_LIBRARY - the kidletime library
# KDE4_KCMUTILS_LIBRARY - the kcmutils library
# KDE4_KPRINTUTILS_LIBRARY - the kprintutils library
# KDE4_KFILE_LIBRARY - the kfile library
# KDE4_KDNSSD_LIBRARY - the kdnssd library
# KDE4_PHONON_LIBRARY - the phonon library
# KDE4_THREADWEAVER_LIBRARY- the threadweaver library
# KDE4_SOLID_LIBRARY - the solid library
# KDE4_KNOTIFYCONFIG_LIBRARY- the knotifyconfig library
# KDE4_KROSSCORE_LIBRARY - the krosscore library
# KDE4_KTEXTEDITOR_LIBRARY - the ktexteditor library
# KDE4_PLASMA_LIBRARY - the plasma library
# KDE4_KUNITCONVERSION_LIBRARY - the kunitconversion library
# KDE4_KDEWEBKIT_LIBRARY - the kdewebkit library
#
# Compared to the variables above, the following variables
# also contain all of the depending libraries, so the variables below
# should be used instead of the ones above:
#
# KDE4_KDECORE_LIBS - the kdecore library and all depending libraries
# KDE4_KDEUI_LIBS - the kdeui library and all depending libraries
# KDE4_KIO_LIBS - the kio library and all depending libraries
# KDE4_KPARTS_LIBS - the kparts library and all depending libraries
# KDE4_KEMOTICONS_LIBS - the kemoticons library and all depending libraries
# KDE4_KIDLETIME_LIBS - the kidletime library and all depending libraries
# KDE4_KCMUTILS_LIBS - the kcmutils library and all depending libraries
# KDE4_KPRINTUTILS_LIBS - the kprintutils library and all depending libraries
# KDE4_KFILE_LIBS - the kfile library and all depending libraries
# KDE4_KDNSSD_LIBS - the kdnssd library and all depending libraries
# KDE4_KDESU_LIBS - the kdesu library and all depending libraries
# KDE4_KPTY_LIBS - the kpty library and all depending libraries
# KDE4_PHONON_LIBS - the phonon library and all depending librairies
2015-09-01 21:22:19 +03:00
# KDE4_THREADWEAVER_LIBS - the threadweaver library and all depending libraries
2014-11-13 01:04:59 +02:00
# KDE4_SOLID_LIBS - the solid library and all depending libraries
# KDE4_KNOTIFYCONFIG_LIBS - the knotify config library and all depending libraries
# KDE4_KROSSCORE_LIBS - the kross core library and all depending libraries
# KDE4_KROSSUI_LIBS - the kross ui library which includes core and all depending libraries
# KDE4_KTEXTEDITOR_LIBS - the ktexteditor library and all depending libraries
# KDE4_PLASMA_LIBS - the plasma library and all depending librairies
# KDE4_KUNITCONVERSION_LIBS - the kunitconversion library and all depending libraries
# KDE4_KDEWEBKIT_LIBS - the kdewebkit library and all depending libraries
#
# This module defines also a bunch of variables used as locations for install directories
# for files of the package which is using this module. These variables don't say
# anything about the location of the installed KDE.
# They can be relative (to CMAKE_INSTALL_PREFIX) or absolute.
# Under Windows they are always relative.
#
# BIN_INSTALL_DIR - the directory where executables will be installed (default is prefix/bin)
# BUNDLE_INSTALL_DIR - Mac only: the directory where application bundles will be installed (default is /Applications/KDE4 )
# SBIN_INSTALL_DIR - the directory where system executables will be installed (default is prefix/sbin)
# LIB_INSTALL_DIR - the directory where libraries will be installed (default is prefix/lib)
# CONFIG_INSTALL_DIR - the directory where config files will be installed
# DATA_INSTALL_DIR - the parent directory where applications can install their data
# ICON_INSTALL_DIR - the directory where the icons will be installed (default prefix/share/icons/)
# INFO_INSTALL_DIR - the directory where info files will be installed (default prefix/info)
# KCFG_INSTALL_DIR - the directory where kconfig files will be installed
# LOCALE_INSTALL_DIR - the directory where translations will be installed
# MAN_INSTALL_DIR - the directory where man pages will be installed (default prefix/man/)
# MIME_INSTALL_DIR - the directory where mimetype desktop files will be installed
2014-11-20 09:05:46 +00:00
# PLUGIN_INSTALL_DIR - the subdirectory relative to the install prefix where plugins will be installed (default is ${KDE4_LIB_INSTALL_DIR}/kde4)
2014-11-13 01:04:59 +02:00
# IMPORTS_INSTALL_DIR - the subdirectory relative to the install prefix where imports will be installed
# SERVICES_INSTALL_DIR - the directory where service (desktop, protocol, ...) files will be installed
# SERVICETYPES_INSTALL_DIR - the directory where servicestypes desktop files will be installed
# SOUND_INSTALL_DIR - the directory where sound files will be installed
# TEMPLATES_INSTALL_DIR - the directory where templates (Create new file...) will be installed
# WALLPAPER_INSTALL_DIR - the directory where wallpapers will be installed
# AUTOSTART_INSTALL_DIR - the directory where autostart files will be installed
# DEMO_INSTALL_DIR - the directory where demos will be installed
# KCONF_UPDATE_INSTALL_DIR - the directory where kconf_update files will be installed
2015-09-05 00:43:47 +00:00
# SYSCONF_INSTALL_DIR - the directory where sysconfig files will be installed (default /usr/etc)
2014-11-13 01:04:59 +02:00
# XDG_APPS_INSTALL_DIR - the XDG apps dir
# XDG_DIRECTORY_INSTALL_DIR- the XDG directory
# XDG_MIME_INSTALL_DIR - the XDG mimetypes install dir
# DBUS_INTERFACES_INSTALL_DIR - the directory where dbus interfaces will be installed (default is prefix/share/dbus-1/interfaces)
# DBUS_SERVICES_INSTALL_DIR - the directory where dbus services will be installed (default is prefix/share/dbus-1/services )
# DBUS_SYSTEM_SERVICES_INSTALL_DIR - the directory where dbus system services will be installed (default is prefix/share/dbus-1/system-services )
#
# The variable INSTALL_TARGETS_DEFAULT_ARGS can be used when installing libraries
# or executables into the default locations.
# The INSTALL_TARGETS_DEFAULT_ARGS variable should be used when libraries are installed.
# It should also be used when installing applications, since then
# on OS X application bundles will be installed to BUNDLE_INSTALL_DIR.
# The variable MUST NOT be used for installing plugins.
# It also MUST NOT be used for executables which are intended to go into sbin/ or libexec/.
#
# Usage is like this:
# install(TARGETS kdecore kdeui ${INSTALL_TARGETS_DEFAULT_ARGS} )
#
# This will install libraries correctly under UNIX, OSX and Windows (i.e. dll's go
# into bin/.
#
#
# The following user adjustable options are provided:
#
# KDE4_ENABLE_FPIE - enable it to use gcc Position Independent Executables feature
# KDE4_SERIALIZE_TOOL - wrapper to serialize potentially resource-intensive commands during
# parallel builds (set to 'icecc' when using icecream)
#
# It also adds the following macros and functions (from 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_KCFG_FILES (SRCS_VAR [GENERATE_MOC] [USE_RELATIVE_PATH] file1.kcfgc ... fileN.kcfgc)
# Use this to add KDE config compiler files to your application/library.
# Use optional GENERATE_MOC to generate moc if you use signals in your kcfg files.
# Use optional USE_RELATIVE_PATH to generate the classes in the build following the given
# relative path to the file.
#
# 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.
# If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", otherwise it won't.
#
2015-09-01 03:15:05 +03:00
# KDE4_ADD_TEST (testname file1 ... fileN)
# add a unit test, which is executed when running make test. The targets
# are build and executed only if the ENABLE_TESTING option is enabled.
# KDESRCDIR is set to the source directory of the test, this can be used
# with KGlobal::dirs()->addResourceDir( "data", KDESRCDIR )
2014-11-13 01:04:59 +02:00
#
# KDE4_INSTALL_ICONS( path theme)
# Installs all png and svgz files in the current directory to the icon
# directory given in path, in the subdirectory for the given icon theme.
#
# KDE4_CREATE_MANPAGE( docbookfile section )
# Create the manpage for the specified section from the docbookfile
2014-11-13 01:04:59 +02:00
# The resulting manpage will be installed to <installdest> when using
# INSTALL_DESTINATION <installdest>, or to <installdest>/<subdir> if
# SUBDIR <subdir> is specified.
#
# KDE4_INSTALL_AUTH_HELPER_FILES( HELPER_TARGET HELPER_ID HELPER_USER )
# This macro adds the needed files for an helper executable meant to be used by applications using KAuth.
# It accepts the helper target, the helper ID (the DBUS name) and the user under which the helper will run on.
# This macro takes care of generate the needed files, and install them in the right location. This boils down
# to a DBus policy to let the helper register on the system bus, and a service file for letting the helper
# being automatically activated by the system bus.
# *WARNING* You have to install the helper in ${LIBEXEC_INSTALL_DIR} to make sure everything will work.
#
#
#
# A note on the possible values for CMAKE_BUILD_TYPE and how KDE handles
# the flags for those buildtypes. FindKDE4Internal supports the values
# Debug, Release, RelWithDebInfo, Profile and Debugfull:
#
# Release
# optimised for speed, qDebug/kDebug turned off, no debug symbols, no asserts
# RelWithDebInfo (Release with debug info)
# similar to Release, optimised for speed, but with debugging symbols on (-g)
# Debug
# optimised but debuggable, debugging on (-g)
# (-fno-reorder-blocks -fno-schedule-insns -fno-inline)
# DebugFull
# no optimization, full debugging on (-g3)
# Profile
# DebugFull + -ftest-coverage -fprofile-arcs
#
#
# The default buildtype is RelWithDebInfo.
# It is expected that the "Debug" build type be still debuggable with gdb
# without going all over the place, but still produce better performance.
# It's also important to note that gcc cannot detect all warning conditions
# unless the optimiser is active.
#
#
# This module allows to depend on a particular minimum version of kdelibs.
# To acomplish that one should use the appropriate cmake syntax for
# find_package. For example to depend on kdelibs >= 4.1.0 one should use
#
# find_package(KDE4 4.1.0 REQUIRED)
#
# In earlier versions of KDE you could use the variable KDE_MIN_VERSION to
# have such a dependency. This variable is deprecated with KDE 4.2.0, but
# will still work to make the module backwards-compatible.
# _KDE4_PLATFORM_INCLUDE_DIRS is used only internally
# _KDE4_PLATFORM_DEFINITIONS is used only internally
# Copyright (c) 2006-2009, Alexander Neundorf <neundorf@kde.org>
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# this is required now by cmake 2.6 and so must not be skipped by if(KDE4_FOUND) below
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
2014-11-13 01:04:59 +02:00
# CMake 2.6, set compatibility behaviour to cmake 2.4
# this must be executed always, because the CMAKE_MINIMUM_REQUIRED() command above
# resets the policy settings, so we get a lot of warnings
# CMP0000: don't require cmake_minimum_version() directly in the top level CMakeLists.txt, FindKDE4Internal.cmake is good enough
cmake_policy(SET CMP0000 OLD)
# CMP0002: in KDE4 we have multiple targets with the same name for the unit tests
cmake_policy(SET CMP0002 OLD)
# CMP0003: add the link paths to the link command as with cmake 2.4
cmake_policy(SET CMP0003 OLD)
# CMP0005: keep escaping behaviour for definitions added via add_definitions()
cmake_policy(SET CMP0005 OLD)
# since cmake 2.6.3: NEW behaviour is that setting policies doesn't "escape" the file
# where this is done, macros and functions are executed with the policies as they
# were when the were defined. Keep the OLD behaviour so we can set the policies here
# for all KDE software without the big warning
cmake_policy(SET CMP0011 OLD)
# since cmake 2.8.4: when include()ing from inside cmake's module dir, prefer the files
# in this directory over those from CMAKE_MODULE_PATH
cmake_policy(SET CMP0017 NEW)
# since cmake 3.0: use of the LOCATION target property is disallowed while it is used in KDE4Macros.cmake
if(POLICY CMP0026)
2014-11-13 01:04:59 +02:00
cmake_policy(SET CMP0026 OLD)
endif(POLICY CMP0026)
2014-11-13 01:04:59 +02:00
# Only do something if it hasn't been found yet
if(NOT KDE4_FOUND)
# get the directory of the current file, used later on in the file
2015-09-01 21:22:19 +03:00
get_filename_component(kde_cmake_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
2014-11-13 01:04:59 +02:00
2015-09-01 21:22:19 +03:00
include(MacroEnsureVersion)
2014-11-13 01:04:59 +02:00
# We may only search for other packages with "REQUIRED" if we are required ourselves.
# This file can be processed either (usually) included in FindKDE4.cmake or
# (when building kdelibs) directly via FIND_PACKAGE(KDE4Internal), that's why
# we have to check for both KDE4_FIND_REQUIRED and KDE4Internal_FIND_REQUIRED.
2015-09-01 21:22:19 +03:00
if(KDE4_FIND_REQUIRED OR KDE4Internal_FIND_REQUIRED)
2014-11-13 01:04:59 +02:00
set(_REQ_STRING_KDE4 "REQUIRED")
set(_REQ_STRING_KDE4_MESSAGE "FATAL_ERROR")
2015-09-05 00:43:47 +00:00
else()
2014-11-13 01:04:59 +02:00
set(_REQ_STRING_KDE4 )
set(_REQ_STRING_KDE4_MESSAGE "STATUS")
2015-09-05 00:43:47 +00:00
endif()
2014-11-13 01:04:59 +02:00
# Store CMAKE_MODULE_PATH and then append the current dir to it, so we are sure
# we get the FindQt4.cmake located next to us and not a different one.
# The original CMAKE_MODULE_PATH is restored later on.
set(_kde_cmake_module_path_back ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${kde_cmake_module_dir} ${CMAKE_MODULE_PATH} )
# if the minimum Qt requirement is changed, change all occurrence in the
# following lines
2015-09-05 00:43:47 +00:00
if(NOT QT_MIN_VERSION )
set(QT_MIN_VERSION "4.8.2")
endif()
if(${QT_MIN_VERSION} VERSION_LESS "4.8.2")
set(QT_MIN_VERSION "4.8.2")
endif()
2014-11-13 01:04:59 +02:00
# Tell FindQt4.cmake to point the QT_QTFOO_LIBRARY targets at the imported targets
# for the Qt libraries, so we get full handling of release and debug versions of the
# Qt libs and are flexible regarding the install location of Qt under Windows:
set(QT_USE_IMPORTED_TARGETS TRUE)
#this line includes FindQt4.cmake, which searches the Qt library and headers
# TODO: we should check here that all necessary modules of Qt have been found, e.g. QtDBus
find_package(Qt4 ${_REQ_STRING_KDE4})
# set(KATIE_COMPAT TRUE)
# find_package(Katie)
2014-11-13 01:04:59 +02:00
# Perl is not required for building KDE software, but we had that here since 4.0
find_package(Perl)
if(NOT PERL_FOUND)
message(STATUS "Perl not found")
endif(NOT PERL_FOUND)
# restore the original CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH ${_kde_cmake_module_path_back})
# we check for Phonon not here, but further below, i.e. after KDELibsDependencies.cmake
# has been loaded, which helps in the case that phonon is installed to the same
# directory as kdelibs.
# find_package(Phonon ${_REQ_STRING_KDE4})
# Check that we really found everything.
# If KDE4 was searched with REQUIRED, we error out with FATAL_ERROR if something wasn't found
# already above in the other FIND_PACKAGE() calls.
# If KDE4 was searched without REQUIRED and something in the FIND_PACKAGE() calls above wasn't found,
# then we get here and must check that everything has actually been found. If something is missing,
# we must not fail with FATAL_ERROR, but only not set KDE4_FOUND.
if(NOT QT4_FOUND)
message(STATUS "KDE4 not found, because Qt4 was not found")
return()
endif(NOT QT4_FOUND)
# now we are sure we have everything we need
include (MacroLibrary)
include (CheckCXXCompilerFlag)
include (CheckCXXSourceCompiles)
# are we trying to compile kdelibs ? kdelibs_SOURCE_DIR comes from "project(kdelibs)" in kdelibs/CMakeLists.txt
# then enter bootstrap mode
if(kdelibs_SOURCE_DIR)
set(_kdeBootStrapping TRUE)
message(STATUS "Building kdelibs...")
else(kdelibs_SOURCE_DIR)
set(_kdeBootStrapping FALSE)
endif(kdelibs_SOURCE_DIR)
# helper macro, sets both the KDE4_FOO_LIBRARY and KDE4_FOO_LIBS variables to KDE4__foo
# It is used both in bootstrapping and in normal mode.
macro(_KDE4_SET_LIB_VARIABLES _var _lib _prefix)
set(KDE4_${_var}_LIBRARY ${_prefix}${_lib} )
set(KDE4_${_var}_LIBS ${_prefix}${_lib} )
endmacro(_KDE4_SET_LIB_VARIABLES _var _lib _prefix)
####################### #now try to find some kde stuff ################################
if (_kdeBootStrapping)
set(KDE4_INCLUDE_DIR ${kdelibs_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${kdelibs_BINARY_DIR}/bin )
2014-11-21 00:52:02 +00:00
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib )
set(KDE4_KCFGC_EXECUTABLE kconfig_compiler${CMAKE_EXECUTABLE_SUFFIX} )
set(KDE4_MAKEKDEWIDGETS_EXECUTABLE makekdewidgets${CMAKE_EXECUTABLE_SUFFIX} )
2014-11-13 01:04:59 +02:00
set(KDE4_LIB_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
set(KDE4_INSTALLED_VERSION_OK TRUE)
else (_kdeBootStrapping)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib )
# These files contain information about the installed kdelibs, Alex
include(${kde_cmake_module_dir}/KDELibsDependencies.cmake)
include(${kde_cmake_module_dir}/KDEPlatformProfile.cmake)
# Check the version of KDE. It must be at least KDE_MIN_VERSION as set by the user.
# KDE_VERSION is set in KDELibsDependencies.cmake since KDE 4.0.x. Alex
# Support for the new-style (>= 2.6.0) support for requiring some version of a package:
if(NOT KDE_MIN_VERSION)
2014-11-13 01:04:59 +02:00
if (KDE4_FIND_VERSION_MAJOR)
set(KDE_MIN_VERSION "${KDE4_FIND_VERSION_MAJOR}.${KDE4_FIND_VERSION_MINOR}.${KDE4_FIND_VERSION_PATCH}")
else()
2014-12-12 04:34:53 +00:00
set(KDE_MIN_VERSION "4.14.3")
endif()
endif()
2014-11-13 01:04:59 +02:00
#message(FATAL_ERROR "KDE_MIN_VERSION=${KDE_MIN_VERSION} found ${KDE_VERSION} exact: -${KDE4_FIND_VERSION_EXACT}- version: -${KDE4_FIND_VERSION}-")
macro_ensure_version(${KDE_MIN_VERSION} ${KDE_VERSION} KDE4_INSTALLED_VERSION_OK)
2014-11-13 01:04:59 +02:00
# KDE4_LIB_INSTALL_DIR and KDE4_INCLUDE_INSTALL_DIR are set in KDELibsDependencies.cmake,
# use them to set the KDE4_LIB_DIR and KDE4_INCLUDE_DIR "public interface" variables
set(KDE4_LIB_DIR ${KDE4_LIB_INSTALL_DIR})
set(KDE4_INCLUDE_DIR ${KDE4_INCLUDE_INSTALL_DIR})
2014-11-13 01:04:59 +02:00
# Now include the file with the imported tools (executable targets).
# This export-file is generated and installed by the toplevel CMakeLists.txt of kdelibs.
# Having the libs and tools in two separate files should help with cross compiling.
include(${kde_cmake_module_dir}/KDELibs4ToolsTargets.cmake)
# get the build CONFIGURATIONS which were exported in this file, and use just the first
# of them to get the location of the installed executables
get_target_property(_importedConfigurations ${KDE4_TARGET_PREFIX}kconfig_compiler IMPORTED_CONFIGURATIONS )
list(GET _importedConfigurations 0 _firstConfig)
get_target_property(KDE4_KCFGC_EXECUTABLE ${KDE4_TARGET_PREFIX}kconfig_compiler LOCATION_${_firstConfig})
get_target_property(KDE4_MAKEKDEWIDGETS_EXECUTABLE ${KDE4_TARGET_PREFIX}makekdewidgets LOCATION_${_firstConfig})
# allow searching cmake modules in all given kde install locations (KDEDIRS based)
execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
file(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
foreach(dir ${_data_DIR})
set (apath "${dir}/cmake/modules")
if (EXISTS "${apath}")
set (included 0)
string(TOLOWER "${apath}" _apath)
# ignore already added pathes, case insensitive
foreach(adir ${CMAKE_MODULE_PATH})
string(TOLOWER "${adir}" _adir)
if ("${_adir}" STREQUAL "${_apath}")
set (included 1)
endif ("${_adir}" STREQUAL "${_apath}")
endforeach(adir)
if (NOT included)
message(STATUS "Adding ${apath} to CMAKE_MODULE_PATH")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${apath}")
endif (NOT included)
endif (EXISTS "${apath}")
endforeach(dir)
# This file contains the exported library target from kdelibs (new with cmake 2.6.x), e.g.
# the library target "kdeui" is exported as "KDE4__kdeui". The "KDE4__" is used as
# "namespace" to separate the imported targets from "normal" targets, it is stored in
# KDE4_TARGET_PREFIX, which is set in KDELibsDependencies.cmake .
# This export-file is generated and installed by the toplevel CMakeLists.txt of kdelibs.
# Include it to "import" the libraries from kdelibs into the current projects as targets.
# This makes setting the _LIBRARY and _LIBS variables actually a bit superfluos, since e.g.
# the kdeui library could now also be used just as "KDE4__kdeui" and still have all their
# dependent libraries handled correctly. But to keep compatibility and not to change
# behaviour we set all these variables anyway as seen below. Alex
include(${kde_cmake_module_dir}/KDELibs4LibraryTargets.cmake)
endif (_kdeBootStrapping)
# Set the various KDE4_FOO_LIBRARY/LIBS variables.
# In bootstrapping mode KDE4_TARGET_PREFIX is empty, so e.g. KDE4_KDECORE_LIBRARY
# will be simply set to "kdecore".
# Sorted by names:
_kde4_set_lib_variables(KCMUTILS kcmutils "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDECORE kdecore "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDEUI kdeui "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDEWEBKIT kdewebkit "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDNSSD kdnssd "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KEMOTICONS kemoticons "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KFILE kfile "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KIDLETIME kidletime "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KIO kio "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KNOTIFYCONFIG knotifyconfig "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KPARTS kparts "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KPRINTUTILS kprintutils "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KROSSCORE krosscore "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KROSSUI krossui "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KTEXTEDITOR ktexteditor "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KUNITCONVERSION kunitconversion "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(PLASMA plasma "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(SOLID solid "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(THREADWEAVER threadweaver "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDEFAKES kdefakes "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KDESU kdesu "${KDE4_TARGET_PREFIX}")
_kde4_set_lib_variables(KPTY kpty "${KDE4_TARGET_PREFIX}")
2014-11-13 01:04:59 +02:00
################### try to find Phonon ############################################
# we do this here instead of above together with the checks for Perl etc.
# since FindPhonon.cmake also uses ${KDE4_LIB_INSTALL_DIR} to check for Phonon,
# which helps with finding the phonon installed as part of kdesupport:
# only make Phonon REQUIRED if KDE4 itself is REQUIRED
2014-12-12 04:34:53 +00:00
find_package(Phonon 4.7.0 ${_REQ_STRING_KDE4})
2014-11-13 01:04:59 +02:00
set(KDE4_PHONON_LIBRARY ${PHONON_LIBRARY})
set(KDE4_PHONON_LIBS ${PHONON_LIBS})
set(KDE4_PHONON_INCLUDES ${PHONON_INCLUDES})
if(NOT PHONON_FOUND)
message(STATUS "KDE4 not found, because Phonon was not found")
return()
2014-11-13 01:04:59 +02:00
endif(NOT PHONON_FOUND)
##################### provide some options ##########################################
if(ENABLE_TESTING)
enable_testing()
endif()
2014-11-13 01:04:59 +02:00
set(KDE4_SERIALIZE_TOOL "" CACHE STRING "Tool to serialize resource-intensive commands in parallel builds")
# for CMake 2.6.3 or above, provide an option which should be used by other KDE
# packages whether to install a CMake FooConfig.cmake into lib/foo/cmake/ or
# /lib/cmake/foo/ (with 2.6.3 and above also lib/cmake/foo/ is supported):
option(KDE4_USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR
"Prefer to install the <package>Config.cmake files to lib/cmake/<package> instead to lib/<package>/cmake"
TRUE
)
2014-11-13 01:04:59 +02:00
# Position-Independent-Executable is a feature of Binutils, Libc, and GCC that creates an executable
# which is something between a shared library and a normal executable.
# Programs compiled with these features appear as ?shared object? with the file command.
option(KDE4_ENABLE_FPIE "Enable platform supports PIE linking")
##################### some more settings ##########################################
# If we are building ! kdelibs, check where kdelibs are installed.
# If they are installed in a directory which contains "lib64", we default to "64" for LIB_SUFFIX,
# so the current project will by default also go into lib64.
# The same for lib32. Alex
set(_Init_LIB_SUFFIX "")
if ("${KDE4_LIB_DIR}" MATCHES lib64)
set(_Init_LIB_SUFFIX 64)
endif ("${KDE4_LIB_DIR}" MATCHES lib64)
if ("${KDE4_LIB_DIR}" MATCHES lib32)
set(_Init_LIB_SUFFIX 32)
endif ("${KDE4_LIB_DIR}" MATCHES lib32)
set(LIB_SUFFIX "${_Init_LIB_SUFFIX}" CACHE STRING "Define suffix of directory name (32/64)" )
set(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
set(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin")
set(SBIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/sbin")
set(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
set(LIBEXEC_INSTALL_DIR "${LIB_INSTALL_DIR}/kde4/libexec")
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}/kde4")
set(IMPORTS_INSTALL_DIR "${PLUGIN_INSTALL_DIR}/imports")
set(CONFIG_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/config")
set(DATA_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/apps")
set(ICON_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/icons")
set(KCFG_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/config.kcfg")
set(LOCALE_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/locale")
set(MIME_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/mimelnk")
set(SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/kde4/services")
set(SERVICETYPES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/kde4/servicetypes")
set(SOUND_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/sounds")
set(TEMPLATES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/templates")
set(WALLPAPER_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/wallpapers")
set(DEMO_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/demos")
set(KCONF_UPDATE_INSTALL_DIR "${DATA_INSTALL_DIR}/kconf_update")
set(AUTOSTART_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/autostart")
set(XDG_APPS_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/applications/kde4")
set(XDG_DIRECTORY_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/desktop-directories")
set(XDG_MIME_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/mime/packages")
set(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
set(MAN_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/man")
set(INFO_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/info")
set(DBUS_INTERFACES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/interfaces")
set(DBUS_SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/services")
set(DBUS_SYSTEM_SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/system-services")
set(KAUTH_HELPER_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/helper")
set(KAUTH_BACKEND_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}/plugins/kauth/backend")
2014-11-13 01:04:59 +02:00
# For more documentation see above.
# Later on it will be possible to extend this for installing OSX frameworks
# The COMPONENT Devel argument has the effect that static libraries belong to the
# "Devel" install component. If we use this also for all install() commands
# for header files, it will be possible to install
# -everything: make install OR cmake -P cmake_install.cmake
# -only the development files: cmake -DCOMPONENT=Devel -P cmake_install.cmake
# -everything except the development files: cmake -DCOMPONENT=Unspecified -P cmake_install.cmake
# This can then also be used for packaging with cpack.
set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT Devel )
############## add some more default search paths ###############
#
# the KDE4_xxx_INSTALL_DIR variables are empty when building kdelibs itself
# and otherwise point to the kde4 install dirs
set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH}
"${KDE4_INCLUDE_INSTALL_DIR}")
set(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH}
"${KDE4_BIN_INSTALL_DIR}" )
set(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH}
"${KDE4_LIB_INSTALL_DIR}" )
######################################################
# and now the platform specific stuff
######################################################
2014-11-19 13:26:30 +00:00
if (WIN32 OR CYGWIN OR APPLE)
message(FATAL_ERROR "Windows/Cygwin/Apple is NOT supported.")
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
# setup default RPATH/install_name handling, it sets up to build with full
# RPATH. When installing, RPATH will be changed to the LIB_INSTALL_DIR
2014-11-13 01:04:59 +02:00
# and all link directories which are not inside the current build dir.
set(_KDE4_PLATFORM_INCLUDE_DIRS)
# add our LIB_INSTALL_DIR to the RPATH (but only when it is not one of the standard system link
# directories listed in CMAKE_{PLATFORM,C,CXX}_IMPLICIT_LINK_DIRECTORIES) and use the RPATH figured out by cmake when compiling
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" _isSystemPlatformLibDir)
list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" _isSystemCLibDir)
list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" _isSystemCxxLibDir)
if("${_isSystemPlatformLibDir}" STREQUAL "-1" AND "${_isSystemCLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
2015-09-01 21:22:19 +03:00
endif()
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(Q_WS_X11)
2014-11-13 01:04:59 +02:00
# Done by FindQt4.cmake already
#find_package(X11 REQUIRED)
# UNIX has already set _KDE4_PLATFORM_INCLUDE_DIRS, so append
set(_KDE4_PLATFORM_INCLUDE_DIRS ${_KDE4_PLATFORM_INCLUDE_DIRS} ${X11_INCLUDE_DIR} )
endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(_KDE4_PLATFORM_DEFINITIONS -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_EXE_LINKER_FLAGS}")
# we profile...
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
endif()
if(CMAKE_C_COMPILER MATCHES "icc")
set(_KDE4_PLATFORM_DEFINITIONS -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
endif()
2015-09-01 21:22:19 +03:00
set(_KDE4_PLATFORM_DEFINITIONS "${_KDE4_PLATFORM_DEFINITIONS} -D_LARGEFILE64_SOURCE")
2015-09-01 21:22:19 +03:00
check_cxx_source_compiles("
2014-11-13 01:04:59 +02:00
#include <sys/types.h>
/* Check that off_t can represent 2**63 - 1 correctly.
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
int main() { return 0; }
" _OFFT_IS_64BIT)
2015-09-01 21:22:19 +03:00
if(NOT _OFFT_IS_64BIT)
set(_KDE4_PLATFORM_DEFINITIONS "${_KDE4_PLATFORM_DEFINITIONS} -D_FILE_OFFSET_BITS=64")
endif()
2014-11-13 01:04:59 +02:00
############################################################
# compiler specific settings
############################################################
# This macro is for internal use only
# Return the directories present in gcc's include path.
macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _result)
set(${_result})
set(_gccOutput)
file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" )
execute_process(COMMAND ${CMAKE_C_COMPILER} -v -E -x ${_lang} -dD dummy
2014-11-13 01:04:59 +02:00
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
ERROR_VARIABLE _gccOutput
OUTPUT_VARIABLE _gccStdout )
file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy")
2014-11-13 01:04:59 +02:00
if("${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list")
SET(${_result} ${CMAKE_MATCH_1})
STRING(REPLACE "\n" " " ${_result} "${${_result}}")
SEPARATE_ARGUMENTS(${_result})
endif()
2014-11-13 01:04:59 +02:00
ENDMACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES Clang)
_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs)
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES} ${_dirs})
endif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES Clang)
if (CMAKE_COMPILER_IS_GNUCXX)
_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs)
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${_dirs})
set (KDE4_ENABLE_EXCEPTIONS "-fexceptions -UQT_NO_EXCEPTIONS")
# Select flags.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline")
set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline")
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
# As of Qt 4.6.x we need to override the new exception macros if we want compile with -fno-exceptions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS -fno-check-new -fno-common")
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
2014-11-13 01:04:59 +02:00
# This should not be needed, as it is also part of _KDE4_PLATFORM_DEFINITIONS below.
# It is kept here nonetheless both for backwards compatibility in case one does not use add_definitions(${KDE4_DEFINITIONS})
# and also because it is/was needed by glibc for snprintf to be available when building C files.
# See commit 4a44862b2d178c1d2e1eb4da90010d19a1e4a42c.
add_definitions (-D_DEFAULT_SOURCE -D_BSD_SOURCE)
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
if(CMAKE_SYSTEM_NAME STREQUAL GNU)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pthread")
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT)
if(KDE4_ENABLE_FPIE)
if(HAVE_FPIE_SUPPORT)
set (KDE4_CXX_FPIE_FLAGS "-fPIE")
set (KDE4_PIE_LDFLAGS "-pie")
else(HAVE_FPIE_SUPPORT)
message(STATUS "Your compiler doesn't support the PIE flag")
endif(HAVE_FPIE_SUPPORT)
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
check_cxx_compiler_flag(-Woverloaded-virtual __KDE_HAVE_W_OVERLOADED_VIRTUAL)
if(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
# visibility support
check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
set( __KDE_HAVE_GCC_VISIBILITY ${__KDE_HAVE_GCC_VISIBILITY} CACHE BOOL "GCC support for hidden visibility")
# get the gcc version
exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} --version OUTPUT_VARIABLE _gcc_version_info)
string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
# gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the patch level, handle this here:
if (NOT _gcc_version)
string (REGEX MATCH ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${gcc_on_macos}")
if (gcc_on_macos)
string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
endif (gcc_on_macos)
endif (NOT _gcc_version)
2015-09-01 21:22:19 +03:00
if(_gcc_version)
2014-11-13 01:04:59 +02:00
macro_ensure_version("4.1.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_1)
macro_ensure_version("4.2.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_2)
macro_ensure_version("4.3.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_3)
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
# save a little by making local statics not threadsafe
# ### do not enable it for older compilers, see
# ### http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31806
if (GCC_IS_NEWER_THAN_4_3)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
endif (GCC_IS_NEWER_THAN_4_3)
set(_GCC_COMPILED_WITH_BAD_ALLOCATOR FALSE)
if (GCC_IS_NEWER_THAN_4_1)
exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} -v OUTPUT_VARIABLE _gcc_alloc_info)
string(REGEX MATCH "(--enable-libstdcxx-allocator=mt)" _GCC_COMPILED_WITH_BAD_ALLOCATOR "${_gcc_alloc_info}")
endif (GCC_IS_NEWER_THAN_4_1)
if (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
set(_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES}")
# first check if we can compile a Qt application
set(_source "#include <QtCore/QtGlobal>\n int main() \n {\n return 0; \n } \n")
set(_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/check_qt_application.cpp)
file(WRITE "${_source_file}" "${_source}")
try_compile(_basic_compile_result ${CMAKE_BINARY_DIR} ${_source_file} CMAKE_FLAGS "${_include_dirs}" OUTPUT_VARIABLE _compile_output_var)
if(_basic_compile_result)
# now ready to check for visibility=hidden
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
set (KDE4_C_FLAGS "-fvisibility=hidden")
# check that Qt defines Q_DECL_EXPORT as __attribute__ ((visibility("default")))
# if it doesn't and KDE compiles with hidden default visibiltiy plugins will break
set(_source "#include <QtCore/QtGlobal>\n int main()\n {\n #ifndef QT_VISIBILITY_AVAILABLE \n #error QT_VISIBILITY_AVAILABLE is not available\n #endif \n }\n")
set(_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/check_qt_visibility.cpp)
file(WRITE "${_source_file}" "${_source}")
try_compile(_compile_result ${CMAKE_BINARY_DIR} ${_source_file} CMAKE_FLAGS "${_include_dirs}" OUTPUT_VARIABLE _compile_output_var)
if(NOT _compile_result)
message("${_compile_output_var}")
message(FATAL_ERROR "Qt compiled without support for -fvisibility=hidden. This will break plugins and linking of some applications. Please fix your Qt installation (try passing --reduce-exports to configure).")
endif(NOT _compile_result)
2015-09-01 21:22:19 +03:00
else()
2014-11-13 01:04:59 +02:00
message("${_compile_output_var}")
message(FATAL_ERROR "Unable to compile a basic Qt application. Qt has not been found correctly.")
2015-09-01 21:22:19 +03:00
endif()
2014-11-13 01:04:59 +02:00
if (GCC_IS_NEWER_THAN_4_2)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -fvisibility-inlines-hidden")
endif (GCC_IS_NEWER_THAN_4_2)
else (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
set (__KDE_HAVE_GCC_VISIBILITY 0)
endif (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
endif (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs)
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${_dirs})
# Note that exceptions are enabled by default when building with clang. That
# is, -fno-exceptions is not set in CMAKE_CXX_FLAGS below. This is because a
# lot of code in different KDE modules ends up including code that throws
# exceptions. Most (or all) of the occurrences are in template code that
# never gets instantiated. Contrary to GCC, ICC and MSVC, clang (most likely
# rightfully) complains about that. Trying to work around the issue by
# passing -fdelayed-template-parsing brings other problems, as noted in
# http://lists.kde.org/?l=kde-core-devel&m=138157459706783&w=2.
# The generated code will be slightly bigger, but there is no way to avoid
# it.
set(KDE4_ENABLE_EXCEPTIONS "-fexceptions -UQT_NO_EXCEPTIONS")
# Select flags.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-inline")
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline")
set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-inline")
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline")
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -fvisibility=hidden -Werror=return-type -fvisibility-inlines-hidden")
set(KDE4_C_FLAGS "-fvisibility=hidden")
# At least kdepim exports one function with C linkage that returns a
# QString in a plugin, but clang does not like that.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
set(KDE4_CXX_FPIE_FLAGS "-fPIE")
set(KDE4_PIE_LDFLAGS "-pie")
if (CMAKE_SYSTEM_NAME STREQUAL GNU)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pthread")
endif (CMAKE_SYSTEM_NAME STREQUAL GNU)
set(__KDE_HAVE_GCC_VISIBILITY TRUE)
# check that Qt defines Q_DECL_EXPORT as __attribute__ ((visibility("default")))
# if it doesn't and KDE compiles with hidden default visibiltiy plugins will break
set(_source "#include <QtCore/QtGlobal>\n int main()\n {\n #ifndef QT_VISIBILITY_AVAILABLE \n #error QT_VISIBILITY_AVAILABLE is not available\n #endif \n }\n")
set(_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/check_qt_visibility.cpp)
file(WRITE "${_source_file}" "${_source}")
set(_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES}")
try_compile(_compile_result ${CMAKE_BINARY_DIR} ${_source_file} CMAKE_FLAGS "${_include_dirs}" OUTPUT_VARIABLE _compile_output_var)
if(NOT _compile_result)
message("${_compile_output_var}")
message(FATAL_ERROR "Qt compiled without support for -fvisibility=hidden. This will break plugins and linking of some applications. Please fix your Qt installation (try passing --reduce-exports to configure).")
endif(NOT _compile_result)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_C_COMPILER MATCHES "icc")
set (KDE4_ENABLE_EXCEPTIONS -fexceptions)
# Select flags.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O2 -g -fno-inline -noalign")
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g -fno-inline -noalign")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "-O2 -g -fno-inline -noalign")
set(CMAKE_C_FLAGS_DEBUGFULL "-g -fno-inline -noalign")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -Wall -w1 -Wpointer-arith -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -w1 -Wpointer-arith -fno-exceptions -fno-common")
# visibility support
set(__KDE_HAVE_ICC_VISIBILITY)
# check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_ICC_VISIBILITY)
# if (__KDE_HAVE_ICC_VISIBILITY)
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
# endif (__KDE_HAVE_ICC_VISIBILITY)
endif (CMAKE_C_COMPILER MATCHES "icc")
########### end of platform specific stuff ##########################
# KDE4Macros.cmake contains all the KDE specific macros
include(${kde_cmake_module_dir}/KDE4Macros.cmake)
# decide whether KDE4 has been found
set(KDE4_FOUND FALSE)
if (KDE4_INCLUDE_DIR AND KDE4_LIB_DIR AND KDE4_KCFGC_EXECUTABLE AND KDE4_INSTALLED_VERSION_OK)
set(KDE4_FOUND TRUE)
set(KDE4Internal_FOUND TRUE) # for feature_summary
endif (KDE4_INCLUDE_DIR AND KDE4_LIB_DIR AND KDE4_KCFGC_EXECUTABLE AND KDE4_INSTALLED_VERSION_OK)
macro (KDE4_PRINT_RESULTS)
2014-11-21 00:52:02 +00:00
# inside kdelibs the include dir and lib dir are internal, not "found"
if (NOT _kdeBootStrapping)
if(KDE4_INCLUDE_DIR)
2015-07-13 13:52:34 +03:00
message(STATUS "Found KDE 4.17 include dir: ${KDE4_INCLUDE_DIR}")
2014-11-21 00:52:02 +00:00
else(KDE4_INCLUDE_DIR)
message(STATUS "ERROR: unable to find the KDE 4 headers")
endif(KDE4_INCLUDE_DIR)
if(KDE4_LIB_DIR)
2015-07-13 13:52:34 +03:00
message(STATUS "Found KDE 4.17 library dir: ${KDE4_LIB_DIR}")
2014-11-21 00:52:02 +00:00
else(KDE4_LIB_DIR)
message(STATUS "ERROR: unable to find the KDE 4 core library")
endif(KDE4_LIB_DIR)
endif (NOT _kdeBootStrapping)
if(KDE4_KCFGC_EXECUTABLE)
message(STATUS "Found the KDE4 kconfig_compiler preprocessor: ${KDE4_KCFGC_EXECUTABLE}")
else(KDE4_KCFGC_EXECUTABLE)
message(STATUS "Didn't find the KDE4 kconfig_compiler preprocessor")
endif(KDE4_KCFGC_EXECUTABLE)
2014-11-13 01:04:59 +02:00
endmacro (KDE4_PRINT_RESULTS)
if (KDE4Internal_FIND_REQUIRED AND NOT KDE4_FOUND)
#bail out if something wasn't found
kde4_print_results()
if (NOT KDE4_INSTALLED_VERSION_OK)
message(FATAL_ERROR "ERROR: the installed kdelibs version ${KDE_VERSION} is too old, at least version ${KDE_MIN_VERSION} is required")
endif (NOT KDE4_INSTALLED_VERSION_OK)
if (NOT KDE4_KCFGC_EXECUTABLE)
message(FATAL_ERROR "ERROR: could not detect a usable kconfig_compiler")
endif (NOT KDE4_KCFGC_EXECUTABLE)
message(FATAL_ERROR "ERROR: could NOT find everything required for compiling KDE 4 programs")
endif (KDE4Internal_FIND_REQUIRED AND NOT KDE4_FOUND)
if (NOT KDE4Internal_FIND_QUIETLY)
kde4_print_results()
endif (NOT KDE4Internal_FIND_QUIETLY)
#add the found Qt and KDE include directories to the current include path
#the ${KDE4_INCLUDE_DIR}/KDE directory is for forwarding includes, eg. #include <KMainWindow>
set(KDE4_INCLUDES
${KDE4_INCLUDE_DIR}
${KDE4_INCLUDE_DIR}/KDE
2014-11-13 01:04:59 +02:00
${KDE4_PHONON_INCLUDES}
${QT_INCLUDES}
${_KDE4_PLATFORM_INCLUDE_DIRS}
)
# Used by kdebug.h: the "toplevel dir" is one level above CMAKE_SOURCE_DIR
get_filename_component(_KDE4_CMAKE_TOPLEVEL_DIR "${CMAKE_SOURCE_DIR}/.." ABSOLUTE)
string(LENGTH "${_KDE4_CMAKE_TOPLEVEL_DIR}" _KDE4_CMAKE_TOPLEVEL_DIR_LENGTH)
set(KDE4_DEFINITIONS
${_KDE4_PLATFORM_DEFINITIONS}
-DQT_NO_STL
-DQT_NO_CAST_TO_ASCII
-D_REENTRANT
-DKDE_DEPRECATED_WARNINGS
-DKDE4_CMAKE_TOPLEVEL_DIR_LENGTH=${_KDE4_CMAKE_TOPLEVEL_DIR_LENGTH}
)
2014-11-13 01:04:59 +02:00
if(NOT _kde4_uninstall_rule_created)
2014-11-13 01:04:59 +02:00
set(_kde4_uninstall_rule_created TRUE)
configure_file("${kde_cmake_module_dir}/kde4_cmake_uninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
endif(NOT _kde4_uninstall_rule_created)
2014-11-13 01:04:59 +02:00
endif(NOT KDE4_FOUND)