<commit_before>project(TelepathyQt)

cmake_minimum_required(VERSION 2.8.12)

# Making releases:
#   set the new version number:
#     odd minor -> development series
#     even minor -> stable series
#     increment micro for each release within a series
#   set nano_version to 0
#   make the release, tag it
#   set nano_version to 1
set(TP_QT_MAJOR_VERSION 0)
set(TP_QT_MINOR_VERSION 9)
set(TP_QT_MICRO_VERSION 8)
set(TP_QT_NANO_VERSION  0)

set(PACKAGE_NAME telepathy-qt)

if (${TP_QT_NANO_VERSION} EQUAL 0)
    set(PACKAGE_VERSION ${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION})
else ()
    set(PACKAGE_VERSION ${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION}.${TP_QT_NANO_VERSION})
endif ()

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is
# checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

# Default build type is RelWithDebInfo for release versions and Debug for developement
# versions
if(NOT CMAKE_BUILD_TYPE)
    if(TP_QT_NANO_VERSION EQUAL 0)
        set(CMAKE_BUILD_TYPE RelWithDebInfo)
    else()
        set(CMAKE_BUILD_TYPE Debug)
    endif()
endif()

# This file contains all the needed initialization macros
include(TelepathyDefaults)

# This file contains all the tpqt macros used in the buildsystem
include(TpQtMacros)

include(MacroLogFeature)

# external dependencies

# Required dependencies
# Find qt4 version >= 4.6 or qt5 >= 5.0.0
set(QT4_MIN_VERSION "4.6.0")
set(QT4_MAX_VERSION "5.0.0")
set(QT5_MIN_VERSION "5.0.0")
set(QT5_MAX_VERSION "6.0.0")
find_package(Qt REQUIRED)

IF(QT_VERSION_MAJOR MATCHES 5)
    # It is QtCore for Qt4 but Qt5Core for Qt5 in pkg-config
    SET(QT_VERSION_PC 5)
ENDIF()

foreach(flag ${QT_CONFIG_FLAGS})
    if (${flag} MATCHES "reduce_relocations")
        set(TP_QT_EXECUTABLE_LINKER_FLAGS "-fPIE")
        set(TP_QT_LIBRARY_LINKER_FLAGS "-fPIC")
    endif ()
endforeach()

# This value contains the library's SOVERSION. This value is to be increased everytime an API/ABI break
# occurs, and will be used for the SOVERSION of the generated shared libraries.
if (${QT_VERSION_MAJOR} EQUAL 4)
    set(TP_QT_ABI_VERSION 2)
else ()
    set(TP_QT_ABI_VERSION 0)
endif ()

set(TP_QT_SERVICE_ABI_VERSION 1)

# This variable is used for the library's long version. It is generated dynamically, so don't change its
# value! Change TP_QT_ABI_VERSION and TP_QT_*_VERSION instead.
if (${TP_QT_NANO_VERSION} EQUAL 0)
    set(TP_QT_LIBRARY_VERSION ${TP_QT_ABI_VERSION}.${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION})
else ()
    set(TP_QT_LIBRARY_VERSION ${TP_QT_ABI_VERSION}.${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION}.${TP_QT_NANO_VERSION})
endif ()

# Add an option for compiling tp-qt-service
option(ENABLE_SERVICE_SUPPORT "Enable compilation of service side bindings for Telepathy-Qt" TRUE)
# Add an option to select type of service library
option(FORCE_STATIC_SERVICE_LIBRARY "Force Telepathy-Qt service to be a static library." FALSE)
# Add an option for compiling examples
option(ENABLE_EXAMPLES "Enable compilation of examples for Telepathy-Qt" TRUE)
# Add an option for compiling Farstream
option(ENABLE_FARSTREAM "Enable compilation of Farstream bindings" TRUE)
# Add an option for building tests
option(ENABLE_TESTS "Enable compilation of automated tests" TRUE)

# The doxygen macro requires Qt to have been looked up to enable crosslinking
include(Doxygen)

include_directories(${CMAKE_SOURCE_DIR}
                    ${CMAKE_BINARY_DIR}
                    ${QT_INCLUDES})

add_definitions(-DQT_NO_CAST_FROM_ASCII)

set(ENABLE_DEBUG_OUTPUT ON CACHE BOOL "If activated, compiles support for printing debug output to stderr")
if (ENABLE_DEBUG_OUTPUT)
    add_definitions(-DENABLE_DEBUG)
endif ()

# Check for Qt Glib support
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
set(CMAKE_REQUIRED_DEFINITIONS "")
# set the flags (-fPIE) here so that CHECK_CXX_SOURCE_COMPILES works properly if qt5 was built with
# -reduce-locations
set(CMAKE_REQUIRED_FLAGS "${TP_QT_EXECUTABLE_LINKER_FLAGS}")

CHECK_CXX_SOURCE_COMPILES("
#include <QtCore/QtGlobal>
int main()
{
#if defined(QT_NO_GLIB)
#error \"Qt was compiled with Glib disabled\"
#endif
return 0;
}"
QT_GLIB_SUPPORT)
macro_log_feature(QT_GLIB_SUPPORT "Qt Glib Support"
                  "QtCore library using Glib's main event loop"
                  "http://qt.nokia.com/" FALSE ""
                  "Needed, together with Telepathy-Glib, to build most of the unit tests")

# reset flags
set(CMAKE_REQUIRED_FLAGS "")

# Find python version >= 2.7
set(REQUIRED_PY 2.7)
find_package(PythonLibrary ${REQUIRED_PY} REQUIRED)
if(${PYTHON_SHORT_VERSION} VERSION_GREATER ${REQUIRED_PY} OR ${PYTHON_SHORT_VERSION} VERSION_EQUAL ${REQUIRED_PY})
    message(STATUS "Python ${PYTHON_SHORT_VERSION} found")
else()
    message(SEND_ERROR "Python >= ${REQUIRED_PY} is required")
endif()

# Check for dbus-python
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import dbus.mainloop.glib"
                RESULT_VARIABLE PYTHON_DBUS_RESULT)
if(PYTHON_DBUS_RESULT EQUAL 0)
    set(HAVE_TEST_PYTHON 1)
else()
    set(HAVE_TEST_PYTHON 0)
endif()
macro_log_feature(HAVE_TEST_PYTHON "dbus-python"
                  "GLib-based Python DBus support"
                  "http://www.python.org/" FALSE ""
                  "Needed to build some additional unit tests")

if(ENABLE_TESTS OR ENABLE_FARSTREAM)
    # Find telepathy-glib
    set(TELEPATHY_GLIB_MIN_VERSION 0.18.0)
    find_package(TelepathyGlib)
    macro_log_feature(TELEPATHYGLIB_FOUND "Telepathy-glib"<commit_msg>Update CMake Python version to 3<commit_after>project(TelepathyQt)

cmake_minimum_required(VERSION 2.8.12)

# Making releases:
#   set the new version number:
#     odd minor -> development series
#     even minor -> stable series
#     increment micro for each release within a series
#   set nano_version to 0
#   make the release, tag it
#   set nano_version to 1
set(TP_QT_MAJOR_VERSION 0)
set(TP_QT_MINOR_VERSION 9)
set(TP_QT_MICRO_VERSION 8)
set(TP_QT_NANO_VERSION  0)

set(PACKAGE_NAME telepathy-qt)

if (${TP_QT_NANO_VERSION} EQUAL 0)
    set(PACKAGE_VERSION ${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION})
else ()
    set(PACKAGE_VERSION ${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION}.${TP_QT_NANO_VERSION})
endif ()

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is
# checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

# Default build type is RelWithDebInfo for release versions and Debug for developement
# versions
if(NOT CMAKE_BUILD_TYPE)
    if(TP_QT_NANO_VERSION EQUAL 0)
        set(CMAKE_BUILD_TYPE RelWithDebInfo)
    else()
        set(CMAKE_BUILD_TYPE Debug)
    endif()
endif()

# This file contains all the needed initialization macros
include(TelepathyDefaults)

# This file contains all the tpqt macros used in the buildsystem
include(TpQtMacros)

include(MacroLogFeature)

# external dependencies

# Required dependencies
# Find qt4 version >= 4.6 or qt5 >= 5.0.0
set(QT4_MIN_VERSION "4.6.0")
set(QT4_MAX_VERSION "5.0.0")
set(QT5_MIN_VERSION "5.0.0")
set(QT5_MAX_VERSION "6.0.0")
find_package(Qt REQUIRED)

IF(QT_VERSION_MAJOR MATCHES 5)
    # It is QtCore for Qt4 but Qt5Core for Qt5 in pkg-config
    SET(QT_VERSION_PC 5)
ENDIF()

foreach(flag ${QT_CONFIG_FLAGS})
    if (${flag} MATCHES "reduce_relocations")
        set(TP_QT_EXECUTABLE_LINKER_FLAGS "-fPIE")
        set(TP_QT_LIBRARY_LINKER_FLAGS "-fPIC")
    endif ()
endforeach()

# This value contains the library's SOVERSION. This value is to be increased everytime an API/ABI break
# occurs, and will be used for the SOVERSION of the generated shared libraries.
if (${QT_VERSION_MAJOR} EQUAL 4)
    set(TP_QT_ABI_VERSION 2)
else ()
    set(TP_QT_ABI_VERSION 0)
endif ()

set(TP_QT_SERVICE_ABI_VERSION 1)

# This variable is used for the library's long version. It is generated dynamically, so don't change its
# value! Change TP_QT_ABI_VERSION and TP_QT_*_VERSION instead.
if (${TP_QT_NANO_VERSION} EQUAL 0)
    set(TP_QT_LIBRARY_VERSION ${TP_QT_ABI_VERSION}.${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION})
else ()
    set(TP_QT_LIBRARY_VERSION ${TP_QT_ABI_VERSION}.${TP_QT_MAJOR_VERSION}.${TP_QT_MINOR_VERSION}.${TP_QT_MICRO_VERSION}.${TP_QT_NANO_VERSION})
endif ()

# Add an option for compiling tp-qt-service
option(ENABLE_SERVICE_SUPPORT "Enable compilation of service side bindings for Telepathy-Qt" TRUE)
# Add an option to select type of service library
option(FORCE_STATIC_SERVICE_LIBRARY "Force Telepathy-Qt service to be a static library." FALSE)
# Add an option for compiling examples
option(ENABLE_EXAMPLES "Enable compilation of examples for Telepathy-Qt" TRUE)
# Add an option for compiling Farstream
option(ENABLE_FARSTREAM "Enable compilation of Farstream bindings" TRUE)
# Add an option for building tests
option(ENABLE_TESTS "Enable compilation of automated tests" TRUE)

# The doxygen macro requires Qt to have been looked up to enable crosslinking
include(Doxygen)

include_directories(${CMAKE_SOURCE_DIR}
                    ${CMAKE_BINARY_DIR}
                    ${QT_INCLUDES})

add_definitions(-DQT_NO_CAST_FROM_ASCII)

set(ENABLE_DEBUG_OUTPUT ON CACHE BOOL "If activated, compiles support for printing debug output to stderr")
if (ENABLE_DEBUG_OUTPUT)
    add_definitions(-DENABLE_DEBUG)
endif ()

# Check for Qt Glib support
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
set(CMAKE_REQUIRED_DEFINITIONS "")
# set the flags (-fPIE) here so that CHECK_CXX_SOURCE_COMPILES works properly if qt5 was built with
# -reduce-locations
set(CMAKE_REQUIRED_FLAGS "${TP_QT_EXECUTABLE_LINKER_FLAGS}")

CHECK_CXX_SOURCE_COMPILES("
#include <QtCore/QtGlobal>
int main()
{
#if defined(QT_NO_GLIB)
#error \"Qt was compiled with Glib disabled\"
#endif
return 0;
}"
QT_GLIB_SUPPORT)
macro_log_feature(QT_GLIB_SUPPORT "Qt Glib Support"
                  "QtCore library using Glib's main event loop"
                  "http://qt.nokia.com/" FALSE ""
                  "Needed, together with Telepathy-Glib, to build most of the unit tests")

# reset flags
set(CMAKE_REQUIRED_FLAGS "")

# Find python version >= 3
find_package(Python3 REQUIRED)

set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})

# Check for dbus-python
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import dbus.mainloop.glib"
                RESULT_VARIABLE PYTHON_DBUS_RESULT)
if(PYTHON_DBUS_RESULT EQUAL 0)
    set(HAVE_TEST_PYTHON 1)
else()
    set(HAVE_TEST_PYTHON 0)
endif()
macro_log_feature(HAVE_TEST_PYTHON "dbus-python"
                  "GLib-based Python DBus support"
                  "http://www.python.org/" FALSE ""
                  "Needed to build some additional unit tests")

if(ENABLE_TESTS OR ENABLE_FARSTREAM)
    # Find telepathy-glib
    set(TELEPATHY_GLIB_MIN_VERSION 0.18.0)
    find_package(TelepathyGlib)
    macro_log_feature(TELEPATHYGLIB_FOUND "Telepathy-glib"
{'fraction_non_alphanumeric': 0.08759654702407996, 'fraction_numerical': 0.010540663334847796, 'mean_word_length': 4.801792303637322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5673617', 'n_tokens_mistral': 4070, 'n_tokens_neox': 3776, 'n_words': 979}