-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
67 lines (56 loc) · 2.76 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cmake_minimum_required(VERSION 3.10)
project(tgbotxx VERSION "1.0.6.9" DESCRIPTION "Telegram Bot C++ Library" LANGUAGES C CXX)
# Note: tgbotxx version's patch & build is based on Telegram Bot Api version for compatibility. See https://core.telegram.org/bots/api-changelog
# <OurMajorVersion>.<OurMinorVersion>.<TelegramBotApiMajorVersion>.<TelegramBotApiMinorVersion>
################# Options ###########################
option(ENABLE_TESTS "Enable/Disable building of tests" OFF)
option(BUILD_DOCS "Build doxygen API documentation" OFF)
option(BUILD_SHARED_LIBS "Build tgbotxx as a shared/static library." OFF)
#####################################################
################## Libraries ##########################
## libcpr curl
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpr)
######################################################
################# Main project ######################
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/**.cpp")
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/tgbotxx/**.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) # Todo: allow building tgbotxx as a shared library
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/json/include> # nlohmann json (single include)
${CPR_INCLUDE_DIRS} # libcpr includes
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${CPR_LIBRARIES})
add_compile_definitions(TGBOTXX_VERSION="${PROJECT_VERSION}")
#if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)
#elseif (MSVC)
# target_compile_options(${PROJECT_NAME} PRIVATE /W4)
#endif()
###### Installation ######
include(cmake/install.cmake)
############################
###### Doxygen Documentation ######
if (BUILD_DOCS)
message(STATUS "Building Doxygen docs is enabled")
find_package(Doxygen REQUIRED)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
add_custom_target(build_docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating Doxygen API documentation..."
VERBATIM
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs/html/ TYPE DOC)
endif ()
###################################
###### Tests ######
if (ENABLE_TESTS)
message(STATUS "Building tests is enabled")
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif ()
####################