CMakeLists.txt 4.69 KB
Newer Older
1
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
2

3
4
cmake_policy(SET CMP0057 NEW)

5
# KDE Application Version, managed by release script
6
set (RELEASE_SERVICE_VERSION_MAJOR "22")
7
8
set (RELEASE_SERVICE_VERSION_MINOR "08")
set (RELEASE_SERVICE_VERSION_MICRO "0")
9
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
Andrius Štikonas's avatar
Andrius Štikonas committed
10

11
12
13
14

set(Boost_MIN_VERSION "1.71.0")
set(LibGMP_MIN_VERSION "6.0.0")
set(LibGcrypt_MIN_VERSION "1.4.5")
15
set(KF5_MIN_VERSION "5.85")
16
17
set(QT_MIN_VERSION "5.15.0")

18
set (SOVERSION 6)
Andrius Štikonas's avatar
Andrius Štikonas committed
19

20
project(LIBKTORRENT VERSION ${RELEASE_SERVICE_VERSION})
21

22
23
24
# set some default settings
enable_testing()

25
find_package(ECM ${KF5_MIN_VERSION} NO_MODULE)
26
27

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
28
29
30
31
32
33
34
35

#
# checks for functions and stuff
#
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckTypeSize) #XFS

36
37
include(KDEInstallDirs)
include(KDECMakeSettings)
38
39
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
include(KDECompilerSettings NO_POLICY_SCOPE)
40
41
42
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMMarkAsTest)
43
include(ECMSetupVersion)
Alexander Lohnau's avatar
Alexander Lohnau committed
44
include(KDEClangFormat)
45
include(KDEGitCommitHooks)
46
include(CMakePackageConfigHelpers)
47

48
set(CMAKE_CXX_STANDARD 17)
49
50
set(CMAKE_CXX_STANDARD_REQUIRED ON)

51
ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX LIBKTORRENT
52
                        VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/libktorrent_version.h"
53
                        PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5TorrentConfigVersion.cmake"
Andrius Štikonas's avatar
Andrius Štikonas committed
54
                        SOVERSION "${SOVERSION}")
55

56
find_package(Qt${QT_MAJOR_VERSION} "${QT_MIN_VERSION}" CONFIG REQUIRED COMPONENTS
57
58
59
60
    Core
    Network
    Xml
    Test
61
62
63
)

# Load the frameworks we need
64
find_package(KF5 "${KF5_MIN_VERSION}" REQUIRED COMPONENTS
65
66
67
68
69
    Archive
    Crash
    I18n
    KIO
    Solid
70
)
71

72
find_package(Boost "${Boost_MIN_VERSION}" MODULE REQUIRED)
73
74
find_package(LibGMP "${LibGMP_MIN_VERSION}" REQUIRED)
find_package(LibGcrypt "${LibGcrypt_MIN_VERSION}" REQUIRED)
75
find_package(Qca-qt${QT_MAJOR_VERSION} CONFIG REQUIRED)
76

77
kde_enable_exceptions()
78
79
80
81
82
83
84
85
add_definitions(
  -DQT_USE_QSTRINGBUILDER
  -DQT_NO_CAST_TO_ASCII
#   -DQT_NO_CAST_FROM_ASCII
  -DQT_STRICT_ITERATORS
  -DQT_NO_URL_CAST_FROM_STRING
  -DQT_NO_CAST_FROM_BYTEARRAY
  -DQT_NO_CAST_TO_BYTEARRAY
86
  -DQT_NO_KEYWORDS
87
88
  -DQT_USE_FAST_OPERATOR_PLUS
)
89
add_definitions(-DTRANSLATION_DOMAIN="libktorrent5")
90

91
#XFS prealloc
92
93
94
95
96
97
98
check_include_files(xfs/xfs.h HAVE_XFS_XFS_H)
if(HAVE_XFS_XFS_H)
    set(CMAKE_EXTRA_INCLUDE_FILES xfs/xfs.h)
    check_type_size(__u64 HAVE___U64)
    check_type_size(__s64 HAVE___S64)
    set(CMAKE_EXTRA_INCLUDE_FILES)
endif()
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

# check for 64 bit file I/O functions
check_function_exists(fopen64 HAVE_FOPEN64)
check_function_exists(fseeko64 HAVE_FSEEKO64)
check_function_exists(fseeko HAVE_FSEEKO)
check_function_exists(ftello64 HAVE_FTELLO64)
check_function_exists(ftello HAVE_FTELLO)
check_function_exists(fstat64 HAVE_FSTAT64)
check_function_exists(stat64 HAVE_STAT64)
check_function_exists(ftruncate64 HAVE_FTRUNCATE64)
check_function_exists(lseek64 HAVE_LSEEK64)
check_function_exists(mmap64 HAVE_MMAP64)
check_function_exists(munmap64 HAVE_MUNMAP64)
check_function_exists(posix_fallocate64 HAVE_POSIX_FALLOCATE64)
check_function_exists(posix_fallocate HAVE_POSIX_FALLOCATE)
114
check_function_exists(fallocate HAVE_FALLOCATE)
115
116
117
118
check_function_exists(statvfs HAVE_STATVFS)
check_function_exists(statvfs64 HAVE_STATVFS64)

add_subdirectory(src)
119
120
121
if(BUILD_TESTING)
    add_subdirectory(testlib)
endif()
Joris Guisson's avatar
Joris Guisson committed
122
add_subdirectory(examples)
123
add_subdirectory(doc)
124

125
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Torrent")
126

127
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KF5TorrentConfig.cmake.in"
128
                              "${CMAKE_CURRENT_BINARY_DIR}/KF5TorrentConfig.cmake"
129
                              INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
130
                              PATH_VARS KDE_INSTALL_INCLUDEDIR
131
132
                              )

133
# Install the CMake modules needed to use libktorrent
134
add_subdirectory(cmake)
135

136
137
install(FILES  "${CMAKE_CURRENT_BINARY_DIR}/KF5TorrentConfig.cmake"
               "${CMAKE_CURRENT_BINARY_DIR}/KF5TorrentConfigVersion.cmake"
138
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
139
        COMPONENT Devel)
140

141
install(EXPORT KF5TorrentTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5TorrentTargets.cmake NAMESPACE KF5:: )
142

Albert Astals Cid's avatar
Albert Astals Cid committed
143
144
ki18n_install(po)

Alexander Lohnau's avatar
Alexander Lohnau committed
145
146
147
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
148
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
Alexander Lohnau's avatar
Alexander Lohnau committed
149

150
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
151