3
cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
5
# CMP0002: we have multiple targets with the same name for the unit tests
6
cmake_policy(SET CMP0002 OLD)
9
option(PHONON_BUILD_TESTS "Build the tests")
11
# enable application tests
12
option(PHONON_BUILD_APP_TESTS "Build the application tests")
14
if (PHONON_BUILD_TESTS)
15
message(STATUS "Building tests.")
17
endif (PHONON_BUILD_TESTS)
19
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
23
include(MacroLogFeature)
24
include(MacroOptionalFindPackage)
26
set(QT_MIN_VERSION 4.6.0)
27
find_package(Qt4 REQUIRED)
28
if (NOT QT_QTDBUS_FOUND)
29
message(STATUS "Warning: Phonon won't be compiled with DBus support.")
30
endif(NOT QT_QTDBUS_FOUND)
32
find_package(Automoc4 REQUIRED)
33
include (CheckCXXCompilerFlag)
34
include (MacroEnsureVersion)
36
if (NOT AUTOMOC4_VERSION)
37
set(AUTOMOC4_VERSION "0.9.83")
38
endif (NOT AUTOMOC4_VERSION)
39
macro_ensure_version("0.9.86" "${AUTOMOC4_VERSION}" _automoc4_version_ok)
40
if (NOT _automoc4_version_ok)
41
message(FATAL_ERROR "Your version of automoc4 is too old. You have ${AUTOMOC4_VERSION}, you need at least 0.9.86")
42
endif (NOT _automoc4_version_ok)
44
if (CMAKE_COMPILER_IS_GNUCXX)
45
set (KDE4_ENABLE_EXCEPTIONS -fexceptions)
47
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
48
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
49
set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
50
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline")
51
set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
52
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
53
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
54
set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
55
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline")
56
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
58
if (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
59
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")
60
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common")
61
add_definitions (-D_BSD_SOURCE -DQT_NO_EXCEPTIONS)
62
endif (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
66
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import")
67
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import")
69
# we always link against the release version of QT with mingw
70
# (even for debug builds). So we need to define QT_NO_DEBUG
71
# or else QPluginLoader rejects plugins because it thinks
72
# they're built against the wrong QT.
73
add_definitions(-DQT_NO_DEBUG)
76
if (QT_USE_FRAMEWORKS)
77
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F${QT_LIBRARY_DIR}")
78
endif (QT_USE_FRAMEWORKS)
80
check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT)
83
set (KDE4_CXX_FPIE_FLAGS "-fPIE")
84
set (KDE4_PIE_LDFLAGS "-pie")
85
else(HAVE_FPIE_SUPPORT)
86
message(STATUS "Your compiler doesn't support PIE flag")
87
endif(HAVE_FPIE_SUPPORT)
88
endif(KDE4_ENABLE_FPIE)
90
check_cxx_compiler_flag(-Woverloaded-virtual __KDE_HAVE_W_OVERLOADED_VIRTUAL)
91
if(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
92
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
93
endif(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
96
check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
97
set( __KDE_HAVE_GCC_VISIBILITY ${__KDE_HAVE_GCC_VISIBILITY} CACHE BOOL "GCC support for hidden visibility")
100
exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} --version OUTPUT_VARIABLE _gcc_version_info)
102
string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
103
# gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the patch level, handle this here:
104
if (NOT _gcc_version)
105
string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
106
endif (NOT _gcc_version)
108
macro_ensure_version("4.1.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_1)
109
macro_ensure_version("4.2.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_2)
110
macro_ensure_version("4.3.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_3)
112
# save a little by making local statics not threadsafe
113
# ### do not enable it for older compilers, see
114
# ### http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31806
115
if (GCC_IS_NEWER_THAN_4_3)
116
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
117
endif (GCC_IS_NEWER_THAN_4_3)
119
set(_GCC_COMPILED_WITH_BAD_ALLOCATOR FALSE)
120
if (GCC_IS_NEWER_THAN_4_1)
121
exec_program(${CMAKE_C_COMPILER} ARGS -v OUTPUT_VARIABLE _gcc_alloc_info)
122
string(REGEX MATCH "(--enable-libstdcxx-allocator=mt)" _GCC_COMPILED_WITH_BAD_ALLOCATOR "${_gcc_alloc_info}")
123
endif (GCC_IS_NEWER_THAN_4_1)
125
if (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
126
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
127
set (KDE4_C_FLAGS "-fvisibility=hidden")
128
# check that Qt defines Q_DECL_EXPORT as __attribute__ ((visibility("default")))
129
# if it doesn't and KDE compiles with hidden default visibiltiy plugins will break
130
set(_source "#include <QtCore/QtGlobal>\n int main()\n {\n #ifdef QT_VISIBILITY_AVAILABLE \n return 0;\n #else \n return 1; \n #endif \n }\n")
131
set(_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/check_qt_visibility.cpp)
132
file(WRITE "${_source_file}" "${_source}")
133
set(_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES}")
135
try_run(_run_result _compile_result ${CMAKE_BINARY_DIR} ${_source_file} CMAKE_FLAGS "${_include_dirs}")
137
if(NOT _compile_result)
138
message(FATAL_ERROR "Could not compile simple test program:\n ${_source}")
139
endif(NOT _compile_result)
141
message(FATAL_ERROR "Qt compiled without support for -fvisibility=hidden. This will break plugins and linking of some applications. Please fix your Qt installation.")
144
if (GCC_IS_NEWER_THAN_4_2)
145
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
146
endif (GCC_IS_NEWER_THAN_4_2)
147
else (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
148
set (__KDE_HAVE_GCC_VISIBILITY 0)
149
endif (__KDE_HAVE_GCC_VISIBILITY AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
151
endif (CMAKE_COMPILER_IS_GNUCXX)
153
set(CMAKE_INCLUDE_CURRENT_DIR ON)
154
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
155
set(CMAKE_COLOR_MAKEFILE ON)
157
set(PHONON_LIB_MAJOR_VERSION "4")
158
set(PHONON_LIB_MINOR_VERSION "4")
159
set(PHONON_LIB_PATCH_VERSION "3")
160
set(PHONON_LIB_VERSION "${PHONON_LIB_MAJOR_VERSION}.4.0")
161
set(PHONON_LIB_SOVERSION ${PHONON_LIB_MAJOR_VERSION})
163
add_definitions(${QT_DEFINITIONS})
164
remove_definitions(-DQT3_SUPPORT_WARNINGS -DQT3_SUPPORT)
166
add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS )
169
# for including config.h and for includes like <kparts/foo.h>
170
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/includes ${CMAKE_CURRENT_SOURCE_DIR}/phonon ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/phonon)
172
macro(_SET_FANCY _var _value _comment)
173
if (KDESupport_SOURCE_DIR)
174
# when building inside kdesupport other subprojects write crap into our variables
175
set(${_var} "${_value}")
176
else (KDESupport_SOURCE_DIR)
177
if (NOT DEFINED ${_var})
178
set(${_var} "${_value}")
179
else (NOT DEFINED ${_var})
180
set(${_var} "${${_var}}" CACHE PATH "${_comment}")
181
endif (NOT DEFINED ${_var})
182
endif (KDESupport_SOURCE_DIR)
185
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
188
_set_fancy(EXEC_INSTALL_PREFIX "." "Base directory for executables and libraries")
190
_set_fancy(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" "Base directory for executables and libraries")
192
_set_fancy(SHARE_INSTALL_PREFIX "${EXEC_INSTALL_PREFIX}/share" "Base directory for files which go to share/")
193
_set_fancy(INCLUDE_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/include" "The subdirectory to the header prefix")
194
_set_fancy(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" "The install dir for executables (default ${EXEC_INSTALL_PREFIX}/bin)")
195
_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" "The subdirectory relative to the install prefix where libraries will be installed (default is ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX})")
196
_set_fancy(PLUGIN_INSTALL_DIR "${LIB_INSTALL_DIR}/kde4" "The subdirectory relative to the install prefix where plugins will be installed (default is ${LIB_INSTALL_DIR}/kde4)")
197
_set_fancy(ICON_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/icons" "The icon install dir (default ${SHARE_INSTALL_PREFIX}/share/icons/)")
198
_set_fancy(SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/kde4/services" "The install dir for service (desktop, protocol, ...) files")
199
_set_fancy(DBUS_INTERFACES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/interfaces" "The dbus interfaces install dir (default: ${SHARE_INSTALL_PREFIX}/dbus-1/interfaces)")
200
_set_fancy(DBUS_SERVICES_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/dbus-1/services" "The dbus services install dir (default: ${SHARE_INSTALL_PREFIX}/dbus-1/services)")
202
set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
203
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
204
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT Devel )
206
# on the Mac support an extra install directory for application bundles
208
set(INSTALL_TARGETS_DEFAULT_ARGS ${INSTALL_TARGETS_DEFAULT_ARGS}
209
BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" )
210
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined dynamic_lookup")
211
set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -flat_namespace -undefined dynamic_lookup")
214
if (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
215
if (CMAKE_COMPILER_IS_GNUCXX)
216
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
217
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
219
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_SHARED_LINKER_FLAGS}")
220
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_MODULE_LINKER_FLAGS}")
221
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags ${CMAKE_EXE_LINKER_FLAGS}")
224
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
225
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
226
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
227
endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
228
endif (CMAKE_COMPILER_IS_GNUCXX)
229
if (CMAKE_C_COMPILER MATCHES "icc")
230
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
231
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
232
endif (CMAKE_C_COMPILER MATCHES "icc")
233
endif (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
235
set(PHONON_LIBS phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
237
list(APPEND PHONON_LIBS phonon ${QT_QTDBUS_LIBRARY})
238
endif(QT_QTDBUS_FOUND)
240
set(PHONON_KDECORE_LIBS kdecore)
242
set(EXECUTABLE_OUTPUT_PATH ${Phonon_BINARY_DIR}/bin)
244
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
246
set(LIBRARY_OUTPUT_PATH ${Phonon_BINARY_DIR}/lib)
249
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")
250
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common")
251
endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")
254
set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
258
add_subdirectory(phonon)
259
add_subdirectory(includes)
260
if (Q_WS_MAC AND BUILD_PHONON_QT7)
261
add_subdirectory(qt7)
262
endif (Q_WS_MAC AND BUILD_PHONON_QT7)
264
add_subdirectory(ds9)
268
add_subdirectory(gstreamer)
269
add_subdirectory(xine)
272
if(NOT WIN32) # pkgconfig file
273
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/phonon.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/phonon.pc @ONLY)
274
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/phonon.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
277
install(FILES qt_phonon.pri DESTINATION ${QT_MKSPECS_DIR}/modules)
279
macro_display_feature_log()