root/trunk/qt4-gui/CMakeLists.txt

Revision 6538, 4.4 kB (checked in by flynd, 6 weeks ago)

Append LIB_SUFFIX in lib path to help build systems for some distributions as suggested in #1649.

Line 
1project(Qt4-GUI)
2cmake_minimum_required(VERSION 2.4.2)
3include(CheckIncludeFile)
4include(TestCXXAcceptsFlag)
5include(CheckLibraryExists)
6
7set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
8
9# Qt-GUI version
10set(VERSION_MAJOR 1)
11set(VERSION_MINOR 3)
12set(VERSION_RELEASE 6)
13
14# Use KDE support
15option(WITH_KDE "Compile with KDE support" OFF)
16
17
18# Install dirs
19set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH
20  "Directory to install the plugin to. A relative path is relative to CMAKE_INSTALL_PREFIX.")
21mark_as_advanced(INSTALL_LIB_DIR)
22
23set(INSTALL_DATA_DIR share CACHE PATH
24  "Directory to install shared data to. A relative path is relative to CMAKE_INSTALL_PREFIX.")
25mark_as_advanced(INSTALL_DATA_DIR)
26
27set(INSTALL_QTGUI_DIR qt4-gui CACHE PATH
28  "Icons etc. will be installed to INSTALL_DATA_DIR/licq/INSTALL_QTGUI_DIR.")
29mark_as_advanced(INSTALL_QTGUI_DIR)
30
31
32# Configure compiler flags
33check_cxx_accepts_flag(-Wall CXX_ACCEPTS_WALL)
34if (CXX_ACCEPTS_WALL)
35  add_definitions(-Wall)
36endif (CXX_ACCEPTS_WALL)
37
38check_cxx_accepts_flag(-Wextra CXX_ACCEPTS_WEXTRA)
39if (CXX_ACCEPTS_WEXTRA)
40  add_definitions(-Wextra)
41endif (CXX_ACCEPTS_WEXTRA)
42
43check_cxx_accepts_flag(-fPIC CXX_ACCEPTS_FPIC)
44if (CXX_ACCEPTS_FPIC)
45  add_definitions(-fPIC)
46endif (CXX_ACCEPTS_FPIC)
47
48
49# Holds all libraries we should link to
50set(LIBRARIES)
51
52# Check for X11 and (optional) screensaver support
53if (NOT APPLE)
54  find_package(X11 REQUIRED)
55  include_directories(${X11_INCLUDE_DIR})
56
57  set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES})
58  check_library_exists(Xss XScreenSaverRegister "" HAVE_LIBXSS)
59  check_include_file(X11/extensions/scrnsaver.h HAVE_SCRNSAVER_H)
60  set(CMAKE_REQUIRED_LIBRARIES)
61
62  if (HAVE_SCRNSAVER_H AND HAVE_LIBXSS)
63    set(X11_LIBRARIES ${X11_LIBRARIES} Xss)
64    set(USE_SCRNSAVER 1)
65  endif (HAVE_SCRNSAVER_H AND HAVE_LIBXSS)
66  set(LIBRARIES ${LIBRARIES} ${X11_LIBRARIES})
67endif (NOT APPLE)
68
69
70# Check for Qt4
71set(QT_MIN_VERSION "4.3.0")
72
73# Check for Qt unless WITH_KDE is requested
74if (NOT WITH_KDE)
75  find_package(Qt4 REQUIRED)
76else (NOT WITH_KDE)
77  find_package(KDE4 REQUIRED)
78  set(USE_KDE ${KDE4_FOUND})
79
80  # FindKDE4Internal adds "-Wl,--no-undefined" to the linker command
81  # line. This doesn't work for use, since all symbols from the daemon
82  # are undefined. So we remove it.
83  string(REPLACE "-Wl,--no-undefined" ""
84    CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
85
86  # FindKDE4Internal adds "-fvisibility=hidden" to the compiler
87  # command line. This hides symbols in the plugin that the daemon
88  # looks for. So we remove it.
89  string(REPLACE "-fvisibility=hidden" ""
90    CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
91
92  add_definitions(${KDE4_DEFINITIONS})
93  link_directories(${KDE4_LIB_DIR})
94
95  include_directories(${KDE4_INCLUDE_DIR})
96  set(LIBRARIES ${LIBRARIES}
97    ${KDE4_KDECORE_LIBS}
98    ${KDE4_KDEUI_LIBS}
99    ${KDE4_KIO_LIBS})
100endif (NOT WITH_KDE)
101
102include_directories(${QT_INCLUDE_DIR}
103  ${QT_QTCORE_INCLUDE_DIR}
104  ${QT_QTGUI_INCLUDE_DIR}
105  ${QT_QTXML_INCLUDE_DIR})
106set(LIBRARIES ${LIBRARIES}
107  ${QT_QTCORE_LIBRARY}
108  ${QT_QTGUI_LIBRARY}
109  ${QT_QTXML_LIBRARY})
110
111
112# Optional check for gpgme
113find_package(gpgme)
114if (GPGME_FOUND)
115  set(HAVE_LIBGPGME 1)
116  add_definitions(${GPGME_DEFINITIONS})
117  include_directories(${GPGME_INCLUDE_DIRS})
118  set(LIBRARIES ${LIBRARIES} ${GPGME_LIBRARIES})
119endif (GPGME_FOUND)
120
121# Check for boost, used in Licq includes so we must have it
122find_package(Boost 1.31.1 COMPONENTS smart_ptr)
123link_directories ( ${Boost_LIBRARY_DIRS} )
124include_directories ( ${Boost_INCLUDE_DIRS} )
125set(LIBRARIES ${LIBRARIES} ${Boost_LIBRARIES})
126
127# Licq headers (see cmake --help-command find_path
128# for the reason we call find_path twice)
129find_path(LICQ_INCLUDE_DIR NAMES licq_icqd.h
130          PATHS ${CMAKE_SOURCE_DIR}/../../include
131                ${CMAKE_SOURCE_DIR}/../licq/include
132          NO_DEFAULT_PATHS)
133find_path(LICQ_INCLUDE_DIR NAMES licq_icqd.h)
134
135if (NOT LICQ_INCLUDE_DIR)
136  message(FATAL_ERROR "Licq header files not found. Please specify the location with -DLICQ_INCLUDE_DIR")
137endif (NOT LICQ_INCLUDE_DIR)
138
139message(STATUS "Found Licq include dir: ${LICQ_INCLUDE_DIR}")
140include_directories(${LICQ_INCLUDE_DIR})
141
142# Local includes
143include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
144
145# Misc headers
146check_include_file(locale.h HAVE_LOCALE_H)
147
148
149# To find config.h
150include_directories(${CMAKE_BINARY_DIR})
151
152# Generate config.h
153configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
154
155add_subdirectory(doc)
156add_subdirectory(po)
157add_subdirectory(share)
158add_subdirectory(src)
Note: See TracBrowser for help on using the browser.