| 1 | project(Qt4-GUI) |
|---|
| 2 | cmake_minimum_required(VERSION 2.4.2) |
|---|
| 3 | include(CheckIncludeFile) |
|---|
| 4 | include(TestCXXAcceptsFlag) |
|---|
| 5 | include(CheckLibraryExists) |
|---|
| 6 | |
|---|
| 7 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
|---|
| 8 | |
|---|
| 9 | # Qt-GUI version |
|---|
| 10 | set(VERSION_MAJOR 1) |
|---|
| 11 | set(VERSION_MINOR 3) |
|---|
| 12 | set(VERSION_RELEASE 6) |
|---|
| 13 | |
|---|
| 14 | # Use KDE support |
|---|
| 15 | option(WITH_KDE "Compile with KDE support" OFF) |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | # Install dirs |
|---|
| 19 | set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH |
|---|
| 20 | "Directory to install the plugin to. A relative path is relative to CMAKE_INSTALL_PREFIX.") |
|---|
| 21 | mark_as_advanced(INSTALL_LIB_DIR) |
|---|
| 22 | |
|---|
| 23 | set(INSTALL_DATA_DIR share CACHE PATH |
|---|
| 24 | "Directory to install shared data to. A relative path is relative to CMAKE_INSTALL_PREFIX.") |
|---|
| 25 | mark_as_advanced(INSTALL_DATA_DIR) |
|---|
| 26 | |
|---|
| 27 | set(INSTALL_QTGUI_DIR qt4-gui CACHE PATH |
|---|
| 28 | "Icons etc. will be installed to INSTALL_DATA_DIR/licq/INSTALL_QTGUI_DIR.") |
|---|
| 29 | mark_as_advanced(INSTALL_QTGUI_DIR) |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | # Configure compiler flags |
|---|
| 33 | check_cxx_accepts_flag(-Wall CXX_ACCEPTS_WALL) |
|---|
| 34 | if (CXX_ACCEPTS_WALL) |
|---|
| 35 | add_definitions(-Wall) |
|---|
| 36 | endif (CXX_ACCEPTS_WALL) |
|---|
| 37 | |
|---|
| 38 | check_cxx_accepts_flag(-Wextra CXX_ACCEPTS_WEXTRA) |
|---|
| 39 | if (CXX_ACCEPTS_WEXTRA) |
|---|
| 40 | add_definitions(-Wextra) |
|---|
| 41 | endif (CXX_ACCEPTS_WEXTRA) |
|---|
| 42 | |
|---|
| 43 | check_cxx_accepts_flag(-fPIC CXX_ACCEPTS_FPIC) |
|---|
| 44 | if (CXX_ACCEPTS_FPIC) |
|---|
| 45 | add_definitions(-fPIC) |
|---|
| 46 | endif (CXX_ACCEPTS_FPIC) |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | # Holds all libraries we should link to |
|---|
| 50 | set(LIBRARIES) |
|---|
| 51 | |
|---|
| 52 | # Check for X11 and (optional) screensaver support |
|---|
| 53 | if (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}) |
|---|
| 67 | endif (NOT APPLE) |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | # Check for Qt4 |
|---|
| 71 | set(QT_MIN_VERSION "4.3.0") |
|---|
| 72 | |
|---|
| 73 | # Check for Qt unless WITH_KDE is requested |
|---|
| 74 | if (NOT WITH_KDE) |
|---|
| 75 | find_package(Qt4 REQUIRED) |
|---|
| 76 | else (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}) |
|---|
| 100 | endif (NOT WITH_KDE) |
|---|
| 101 | |
|---|
| 102 | include_directories(${QT_INCLUDE_DIR} |
|---|
| 103 | ${QT_QTCORE_INCLUDE_DIR} |
|---|
| 104 | ${QT_QTGUI_INCLUDE_DIR} |
|---|
| 105 | ${QT_QTXML_INCLUDE_DIR}) |
|---|
| 106 | set(LIBRARIES ${LIBRARIES} |
|---|
| 107 | ${QT_QTCORE_LIBRARY} |
|---|
| 108 | ${QT_QTGUI_LIBRARY} |
|---|
| 109 | ${QT_QTXML_LIBRARY}) |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | # Optional check for gpgme |
|---|
| 113 | find_package(gpgme) |
|---|
| 114 | if (GPGME_FOUND) |
|---|
| 115 | set(HAVE_LIBGPGME 1) |
|---|
| 116 | add_definitions(${GPGME_DEFINITIONS}) |
|---|
| 117 | include_directories(${GPGME_INCLUDE_DIRS}) |
|---|
| 118 | set(LIBRARIES ${LIBRARIES} ${GPGME_LIBRARIES}) |
|---|
| 119 | endif (GPGME_FOUND) |
|---|
| 120 | |
|---|
| 121 | # Check for boost, used in Licq includes so we must have it |
|---|
| 122 | find_package(Boost 1.31.1 COMPONENTS smart_ptr) |
|---|
| 123 | link_directories ( ${Boost_LIBRARY_DIRS} ) |
|---|
| 124 | include_directories ( ${Boost_INCLUDE_DIRS} ) |
|---|
| 125 | set(LIBRARIES ${LIBRARIES} ${Boost_LIBRARIES}) |
|---|
| 126 | |
|---|
| 127 | # Licq headers (see cmake --help-command find_path |
|---|
| 128 | # for the reason we call find_path twice) |
|---|
| 129 | find_path(LICQ_INCLUDE_DIR NAMES licq_icqd.h |
|---|
| 130 | PATHS ${CMAKE_SOURCE_DIR}/../../include |
|---|
| 131 | ${CMAKE_SOURCE_DIR}/../licq/include |
|---|
| 132 | NO_DEFAULT_PATHS) |
|---|
| 133 | find_path(LICQ_INCLUDE_DIR NAMES licq_icqd.h) |
|---|
| 134 | |
|---|
| 135 | if (NOT LICQ_INCLUDE_DIR) |
|---|
| 136 | message(FATAL_ERROR "Licq header files not found. Please specify the location with -DLICQ_INCLUDE_DIR") |
|---|
| 137 | endif (NOT LICQ_INCLUDE_DIR) |
|---|
| 138 | |
|---|
| 139 | message(STATUS "Found Licq include dir: ${LICQ_INCLUDE_DIR}") |
|---|
| 140 | include_directories(${LICQ_INCLUDE_DIR}) |
|---|
| 141 | |
|---|
| 142 | # Local includes |
|---|
| 143 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) |
|---|
| 144 | |
|---|
| 145 | # Misc headers |
|---|
| 146 | check_include_file(locale.h HAVE_LOCALE_H) |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | # To find config.h |
|---|
| 150 | include_directories(${CMAKE_BINARY_DIR}) |
|---|
| 151 | |
|---|
| 152 | # Generate config.h |
|---|
| 153 | configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h) |
|---|
| 154 | |
|---|
| 155 | add_subdirectory(doc) |
|---|
| 156 | add_subdirectory(po) |
|---|
| 157 | add_subdirectory(share) |
|---|
| 158 | add_subdirectory(src) |
|---|