source: trunk/src/3rdparty/phonon/CMakeLists.txt@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 13.1 KB
Line 
1project(Phonon)
2
3cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
4
5# CMP0002: we have multiple targets with the same name for the unit tests
6cmake_policy(SET CMP0002 OLD)
7
8# enable unit tests
9option(PHONON_BUILD_TESTS "Build the tests")
10option(PHONON_BUILD_EXAMPLES "Build the examples")
11
12if (PHONON_BUILD_TESTS)
13 enable_testing()
14endif (PHONON_BUILD_TESTS)
15
16set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
17
18include(PhononMacros)
19
20include(MacroLogFeature)
21include(MacroOptionalFindPackage)
22
23set(QT_MIN_VERSION 4.4.0)
24find_package(Qt4 REQUIRED)
25if (NOT QT_QTDBUS_FOUND)
26 message(STATUS "Warning: Phonon won't be compiled with DBus support.")
27endif(NOT QT_QTDBUS_FOUND)
28
29find_package(Automoc4 REQUIRED)
30include (CheckCXXCompilerFlag)
31include (MacroEnsureVersion)
32
33if (NOT AUTOMOC4_VERSION)
34 set(AUTOMOC4_VERSION "0.9.83")
35endif (NOT AUTOMOC4_VERSION)
36macro_ensure_version("0.9.86" "${AUTOMOC4_VERSION}" _automoc4_version_ok)
37if (NOT _automoc4_version_ok)
38 message(FATAL_ERROR "Your version of automoc4 is too old. You have ${AUTOMOC4_VERSION}, you need at least 0.9.86")
39endif (NOT _automoc4_version_ok)
40
41if (CMAKE_COMPILER_IS_GNUCXX)
42 set (KDE4_ENABLE_EXCEPTIONS -fexceptions)
43 # Select flags.
44 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
45 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
46 set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
47 set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline")
48 set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
49 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
50 set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
51 set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
52 set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline")
53 set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
54
55 if (CMAKE_SYSTEM_NAME MATCHES Linux)
56 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")
57 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")
58 add_definitions (-D_BSD_SOURCE)
59 endif (CMAKE_SYSTEM_NAME MATCHES Linux)
60
61 # gcc under Windows
62 if (MINGW)
63 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import")
64 set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import")
65
66 # we always link against the release version of QT with mingw
67 # (even for debug builds). So we need to define QT_NO_DEBUG
68 # or else QPluginLoader rejects plugins because it thinks
69 # they're built against the wrong QT.
70 add_definitions(-DQT_NO_DEBUG)
71 endif (MINGW)
72
73 check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT)
74 if(KDE4_ENABLE_FPIE)
75 if(HAVE_FPIE_SUPPORT)
76 set (KDE4_CXX_FPIE_FLAGS "-fPIE")
77 set (KDE4_PIE_LDFLAGS "-pie")
78 else(HAVE_FPIE_SUPPORT)
79 message(STATUS "Your compiler doesn't support PIE flag")
80 endif(HAVE_FPIE_SUPPORT)
81 endif(KDE4_ENABLE_FPIE)
82
83 check_cxx_compiler_flag(-Woverloaded-virtual __KDE_HAVE_W_OVERLOADED_VIRTUAL)
84 if(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
85 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
86 endif(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
87
88 # visibility support
89 check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
90 set( __KDE_HAVE_GCC_VISIBILITY ${__KDE_HAVE_GCC_VISIBILITY} CACHE BOOL "GCC support for hidden visibility")
91
92 # get the gcc version
93 exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
94
95 string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
96 # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the patch level, handle this here:
97 if (NOT _gcc_version)
98 string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
99 endif (NOT _gcc_version)