2020-11-03 17:34:10 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|
|
|
|
2021-06-13 04:51:38 +02:00
|
|
|
if (POLICY CMP0065)
|
|
|
|
# do not export symbols from executables
|
|
|
|
# affects compiler checks in project(), so must be set before it
|
|
|
|
cmake_policy(SET CMP0065 NEW)
|
|
|
|
endif()
|
|
|
|
|
2023-09-23 15:39:14 +02:00
|
|
|
project(TelegramBotApi VERSION 6.9.1 LANGUAGES CXX)
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-10 16:38:27 +02:00
|
|
|
if (POLICY CMP0069)
|
|
|
|
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
|
|
|
set(TD_ENABLE_LTO "${TELEGRAM_BOT_API_ENABLE_LTO}" CACHE STRING "Enable LTO" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
add_subdirectory(td EXCLUDE_FROM_ALL)
|
|
|
|
|
|
|
|
if (NOT DEFINED CMAKE_MODULE_PATH)
|
|
|
|
set(CMAKE_MODULE_PATH "")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/td/CMake" "${CMAKE_MODULE_PATH}")
|
|
|
|
|
|
|
|
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
|
|
|
set(CMAKE_INSTALL_BINDIR "bin")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (POLICY CMP0054)
|
|
|
|
# do not expand quoted arguments
|
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
endif()
|
|
|
|
if (POLICY CMP0060)
|
|
|
|
# link libraries by full path
|
|
|
|
cmake_policy(SET CMP0060 NEW)
|
|
|
|
endif()
|
2021-09-01 18:10:34 +02:00
|
|
|
if (POLICY CMP0074)
|
|
|
|
# use environment variables to find libraries
|
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
endif()
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
include(PreventInSourceBuild)
|
|
|
|
prevent_in_source_build()
|
|
|
|
|
2021-09-10 16:38:27 +02:00
|
|
|
if (POLICY CMP0069 AND TELEGRAM_BOT_API_ENABLE_LTO)
|
|
|
|
cmake_policy(SET CMP0069 NEW)
|
|
|
|
include(CheckIPOSupported)
|
|
|
|
check_ipo_supported(RESULT IPO_SUPPORTED LANGUAGES CXX)
|
|
|
|
if (IPO_SUPPORTED)
|
|
|
|
string(REPLACE ";" " " CXX_FLAGS_IPO "${CMAKE_CXX_COMPILE_OPTIONS_IPO}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_IPO}")
|
|
|
|
|
|
|
|
string(REPLACE ";" " " LINK_FLAGS_IPO "${CMAKE_CXX_LINK_OPTIONS_IPO}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINK_FLAGS_IPO}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
if (THREADS_HAVE_PTHREAD_ARG)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(TdSetUpCompiler)
|
|
|
|
td_set_up_compiler()
|
|
|
|
|
|
|
|
if (CLANG OR GCC)
|
|
|
|
if (MEMPROF)
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag(-no-pie CXX_NO_PIE_FLAG)
|
|
|
|
if (CXX_NO_PIE_FLAG)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
|
|
|
elseif (APPLE)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie")
|
|
|
|
endif()
|
2023-03-12 20:39:48 +01:00
|
|
|
include(AddCXXCompilerFlag)
|
|
|
|
add_cxx_compiler_flag("-static-libstdc++")
|
|
|
|
add_cxx_compiler_flag("-static-libgcc")
|
2020-11-03 17:34:10 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-11-08 12:01:44 +01:00
|
|
|
set(TELEGRAM_BOT_API_SOURCE
|
2020-11-03 17:34:10 +01:00
|
|
|
telegram-bot-api/telegram-bot-api.cpp
|
|
|
|
|
|
|
|
telegram-bot-api/Client.cpp
|
|
|
|
telegram-bot-api/ClientManager.cpp
|
|
|
|
telegram-bot-api/HttpConnection.cpp
|
|
|
|
telegram-bot-api/HttpStatConnection.cpp
|
|
|
|
telegram-bot-api/Query.cpp
|
|
|
|
telegram-bot-api/Stats.cpp
|
2022-08-22 01:26:36 +02:00
|
|
|
telegram-bot-api/Watchdog.cpp
|
2020-11-03 17:34:10 +01:00
|
|
|
telegram-bot-api/WebhookActor.cpp
|
|
|
|
|
|
|
|
telegram-bot-api/Client.h
|
|
|
|
telegram-bot-api/ClientManager.h
|
|
|
|
telegram-bot-api/ClientParameters.h
|
|
|
|
telegram-bot-api/HttpConnection.h
|
|
|
|
telegram-bot-api/HttpServer.h
|
|
|
|
telegram-bot-api/HttpStatConnection.h
|
|
|
|
telegram-bot-api/Query.h
|
|
|
|
telegram-bot-api/Stats.h
|
2022-08-22 01:26:36 +02:00
|
|
|
telegram-bot-api/Watchdog.h
|
2020-11-03 17:34:10 +01:00
|
|
|
telegram-bot-api/WebhookActor.h
|
|
|
|
)
|
|
|
|
|
2020-11-08 12:01:44 +01:00
|
|
|
add_executable(telegram-bot-api ${TELEGRAM_BOT_API_SOURCE})
|
2020-11-03 17:34:10 +01:00
|
|
|
target_include_directories(telegram-bot-api PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
|
|
|
target_link_libraries(telegram-bot-api PRIVATE memprof tdactor tdcore tddb tdnet tdutils)
|
|
|
|
|
|
|
|
install(TARGETS telegram-bot-api RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
if (MSVC AND VCPKG_TOOLCHAIN)
|
2020-11-16 20:41:06 +01:00
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/" DESTINATION "${CMAKE_INSTALL_BINDIR}" FILES_MATCHING PATTERN "*.dll" PATTERN "*.pdb")
|
2020-11-03 17:34:10 +01:00
|
|
|
endif()
|