Warning, /libdbusmenu-qt/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 project(dbusmenu-qt)
0002 cmake_minimum_required(VERSION 2.8.11)
0003 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
0004 
0005 # Build options
0006 option(WITH_DOC "Build documentation (requires Doxygen)" ON)
0007 
0008 # Versions
0009 ## Package version
0010 set(dbusmenu_qt_VERSION_MAJOR 0)
0011 set(dbusmenu_qt_VERSION_MINOR 9)
0012 set(dbusmenu_qt_VERSION_PATCH 2)
0013 set(dbusmenu_qt_VERSION ${dbusmenu_qt_VERSION_MAJOR}.${dbusmenu_qt_VERSION_MINOR}.${dbusmenu_qt_VERSION_PATCH})
0014 
0015 ## Lib version
0016 ### Bump this one when a binary-incompatible change is introduced
0017 set(dbusmenu_qt_lib_SOVERSION 2)
0018 
0019 ### Bump this one when the API is extended in a binary-compatible way
0020 set(dbusmenu_qt_lib_API_VERSION 6)
0021 
0022 ### Bump this one when changes do not extend the API
0023 set(dbusmenu_qt_lib_PATCH_VERSION 0)
0024 
0025 set(dbusmenu_qt_lib_VERSION ${dbusmenu_qt_lib_SOVERSION}.${dbusmenu_qt_lib_API_VERSION}.${dbusmenu_qt_lib_PATCH_VERSION})
0026 
0027 # Check if we want to explicitly select the Qt version to be used or autodetect
0028 if (NOT USE_QT4 AND NOT USE_QT5)
0029     # Autodetect, prefering Qt5
0030     message(STATUS "Autodetecting Qt version to use")
0031     find_package(Qt5Widgets QUIET)
0032     if (Qt5Widgets_FOUND)
0033         set(USE_QT5 TRUE)
0034     endif()
0035 endif()
0036 
0037 # Detect for which Qt version we're building
0038 if (USE_QT5)
0039     find_package(Qt5Widgets REQUIRED)
0040     find_package(Qt5DBus REQUIRED)
0041     include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
0042     find_package(Qt5Core REQUIRED)
0043     set(CMAKE_AUTOMOC ON)
0044     set(CMAKE_AUTOMOC_RELAXED_MODE ON)
0045     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
0046 
0047     set(QT_SUFFIX "qt5")
0048 else()
0049     find_package(Qt4 REQUIRED)
0050     include_directories(
0051       ${QT_INCLUDE_DIR}
0052       ${QT_QTCORE_INCLUDE_DIR}
0053       ${QT_QTDBUS_INCLUDE_DIR}
0054       ${QT_QTGUI_INCLUDE_DIR}
0055       )
0056 
0057     set(QT_SUFFIX "qt")
0058 endif()
0059 
0060 include (CheckCXXCompilerFlag)
0061 # Check some compiler flags
0062 check_cxx_compiler_flag(-fvisibility=hidden __DBUSMENU_HAVE_GCC_VISIBILITY)
0063 if (__DBUSMENU_HAVE_GCC_VISIBILITY AND NOT WIN32)
0064     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
0065 endif (__DBUSMENU_HAVE_GCC_VISIBILITY AND NOT WIN32)
0066 
0067 check_cxx_compiler_flag(-Woverloaded-virtual __DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
0068 if (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
0069     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
0070 endif (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
0071 
0072 check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)
0073 if (__DBUSMENU_HAVE_CXX11)
0074     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
0075 endif (__DBUSMENU_HAVE_CXX11)
0076 
0077 include(CMakePackageConfigHelpers)
0078 include(GNUInstallDirs)
0079 set(LIB_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
0080 set(CMAKECONFIG_INSTALL_DIR "${LIB_DESTINATION}/cmake/dbusmenu-${QT_SUFFIX}")
0081 set(INCLUDE_INSTALL_DIR "include/dbusmenu-${QT_SUFFIX}")
0082 
0083 # dist targets
0084 set(ARCHIVE_NAME libdbusmenu-${QT_SUFFIX}-${dbusmenu_qt_VERSION})
0085 add_custom_target(dist
0086     COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
0087     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
0088     )
0089 
0090 add_custom_target(distcheck
0091     COMMAND cd ${CMAKE_BINARY_DIR}
0092     && rm -rf ${ARCHIVE_NAME}
0093     && tar xf ${ARCHIVE_NAME}.tar.bz2
0094     && mkdir ${ARCHIVE_NAME}/build
0095     && cd ${ARCHIVE_NAME}/build
0096     && cmake -DCMAKE_INSTALL_PREFIX=../install ..
0097     && make
0098     && make install
0099     && make check
0100     )
0101 add_dependencies(distcheck dist)
0102 
0103 configure_file(dbusmenu-qt.pc.in ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc @ONLY)
0104 
0105 install(FILES ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc
0106         DESTINATION ${LIB_DESTINATION}/pkgconfig
0107     )
0108 
0109 add_subdirectory(src)
0110 add_subdirectory(tests)
0111 add_subdirectory(tools)
0112 
0113 if(WITH_DOC)
0114     configure_file(Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
0115 
0116     add_custom_target(doc ALL doxygen
0117         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0118         )
0119 
0120     install(DIRECTORY ${CMAKE_BINARY_DIR}/html/
0121         DESTINATION share/doc/libdbusmenu-${QT_SUFFIX}-doc
0122         )
0123 endif(WITH_DOC)
0124 
0125 # Generate dbusmenu-qt-config* files
0126 configure_package_config_file(
0127     dbusmenu-qt-config.cmake.in
0128     ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}-config.cmake
0129     INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
0130     PATH_VARS INCLUDE_INSTALL_DIR
0131     )
0132 
0133 write_basic_package_version_file(
0134     ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}-config-version.cmake
0135     VERSION ${dbusmenu_qt_VERSION}
0136     COMPATIBILITY SameMajorVersion
0137     )
0138 
0139 # Install dbusmenu-qt-config* files
0140 install(FILES
0141     ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}-config.cmake
0142     ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}-config-version.cmake
0143     DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0144     COMPONENT Devel
0145     )