2021-06-13 22:38:48 +02:00
|
|
|
if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
|
|
|
|
message(FATAL_ERROR "CMake >= 3.0.2 is required")
|
|
|
|
endif()
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-01-24 01:03:18 +01:00
|
|
|
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
|
|
|
set(CMAKE_INSTALL_BINDIR "bin")
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
file(MAKE_DIRECTORY auto/td/telegram)
|
|
|
|
file(MAKE_DIRECTORY auto/td/mtproto)
|
2021-03-03 23:41:09 +01:00
|
|
|
file(MAKE_DIRECTORY auto/tlo)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-01-24 01:05:58 +01:00
|
|
|
set(TL_TD_AUTO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auto PARENT_SCOPE)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-01-24 01:09:49 +01:00
|
|
|
set(TD_AUTO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auto/td)
|
|
|
|
|
2024-05-18 20:16:51 +02:00
|
|
|
set(TL_MTPROTO_AUTO_SOURCE
|
2020-01-24 01:09:49 +01:00
|
|
|
${TD_AUTO_INCLUDE_DIR}/mtproto/mtproto_api.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/mtproto/mtproto_api.h
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/mtproto/mtproto_api.hpp
|
2024-05-18 20:16:51 +02:00
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TL_TD_AUTO_SOURCE
|
2020-01-24 01:09:49 +01:00
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/telegram_api.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/telegram_api.h
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/telegram_api.hpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/secret_api.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/secret_api.h
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/secret_api.hpp
|
2018-12-31 20:04:05 +01:00
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
2020-02-24 00:00:43 +01:00
|
|
|
set(TL_TD_API_AUTO_SOURCE
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_api.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_api.h
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_api.hpp
|
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
2020-02-23 23:55:13 +01:00
|
|
|
set(TL_TD_JSON_AUTO_SOURCE
|
2020-01-24 01:09:49 +01:00
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_api_json.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_api_json.h
|
2018-12-31 20:04:05 +01:00
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
2020-02-23 23:55:13 +01:00
|
|
|
set(TL_C_AUTO_SOURCE
|
2020-01-24 01:09:49 +01:00
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_tdc_api.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_tdc_api.h
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/td_tdc_api_inner.h
|
2018-12-31 20:04:05 +01:00
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
2020-02-23 23:55:13 +01:00
|
|
|
set(TL_DOTNET_AUTO_SOURCE
|
2020-01-24 01:09:49 +01:00
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/TdDotNetApi.cpp
|
|
|
|
${TD_AUTO_INCLUDE_DIR}/telegram/TdDotNetApi.h
|
2018-02-26 19:08:47 +01:00
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
set(TL_GENERATE_COMMON_SOURCE
|
|
|
|
generate_common.cpp
|
|
|
|
|
|
|
|
tl_writer_cpp.cpp
|
|
|
|
tl_writer_h.cpp
|
|
|
|
tl_writer_hpp.cpp
|
|
|
|
tl_writer_jni_cpp.cpp
|
|
|
|
tl_writer_jni_h.cpp
|
|
|
|
tl_writer_td.cpp
|
|
|
|
|
|
|
|
tl_writer_cpp.h
|
|
|
|
tl_writer_h.h
|
|
|
|
tl_writer_hpp.h
|
|
|
|
tl_writer_jni_cpp.h
|
|
|
|
tl_writer_jni_h.h
|
|
|
|
tl_writer_td.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TL_GENERATE_C_SOURCE
|
|
|
|
generate_c.cpp
|
|
|
|
|
|
|
|
tl_writer_c.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TL_GENERATE_JAVA_SOURCE
|
|
|
|
generate_java.cpp
|
|
|
|
|
|
|
|
tl_writer_java.cpp
|
|
|
|
|
|
|
|
tl_writer_java.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TL_GENERATE_JSON_SOURCE
|
|
|
|
generate_json.cpp
|
|
|
|
|
|
|
|
tl_json_converter.cpp
|
|
|
|
|
|
|
|
tl_json_converter.h
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT CMAKE_CROSSCOMPILING)
|
|
|
|
find_program(PHP_EXECUTABLE php)
|
|
|
|
|
2020-02-29 14:15:52 +01:00
|
|
|
if ((CMAKE_SYSTEM_NAME MATCHES "FreeBSD") AND (CMAKE_SYSTEM_VERSION MATCHES "HBSD"))
|
|
|
|
set(PHP_EXECUTABLE "PHP_EXECUTABLE-NOTFOUND")
|
|
|
|
endif()
|
|
|
|
|
2018-03-15 17:25:51 +01:00
|
|
|
if (PHP_EXECUTABLE AND NOT TD_ENABLE_DOTNET)
|
2023-06-26 14:33:02 +02:00
|
|
|
set(GENERATE_COMMON_CMD generate_common && ${PHP_EXECUTABLE} ../DoxygenTlDocumentationGenerator.php ../scheme/td_api.tl td/telegram/td_api.h)
|
2018-12-31 20:04:05 +01:00
|
|
|
else()
|
|
|
|
set(GENERATE_COMMON_CMD generate_common)
|
|
|
|
endif()
|
|
|
|
|
2021-03-03 23:41:09 +01:00
|
|
|
add_subdirectory(tl-parser)
|
|
|
|
|
2021-03-05 21:15:52 +01:00
|
|
|
set(TLO_AUTO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auto/tlo)
|
2021-03-14 19:57:39 +01:00
|
|
|
set(TLO_FILES ${TLO_AUTO_INCLUDE_DIR}/mtproto_api.tlo ${TLO_AUTO_INCLUDE_DIR}/secret_api.tlo ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo ${TLO_AUTO_INCLUDE_DIR}/telegram_api.tlo)
|
|
|
|
set(TD_API_TLO_FILE ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo)
|
|
|
|
|
|
|
|
# Ninja generator uses relative paths and can't correctly handle these dependencies
|
|
|
|
# See https://gitlab.kitware.com/cmake/cmake/-/issues/13894
|
|
|
|
if (CMAKE_GENERATOR STREQUAL "Ninja")
|
|
|
|
set(TLO_FILES)
|
|
|
|
set(TD_API_TLO_FILE)
|
|
|
|
endif()
|
2021-03-05 21:15:52 +01:00
|
|
|
|
2021-03-03 23:41:09 +01:00
|
|
|
add_custom_target(tl_generate_tlo
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND tl-parser -e auto/tlo/mtproto_api.tlo scheme/mtproto_api.tl
|
|
|
|
COMMAND tl-parser -e auto/tlo/secret_api.tlo scheme/secret_api.tl
|
|
|
|
COMMAND tl-parser -e auto/tlo/td_api.tlo scheme/td_api.tl
|
|
|
|
COMMAND tl-parser -e auto/tlo/telegram_api.tlo scheme/telegram_api.tl
|
2021-03-05 21:15:52 +01:00
|
|
|
COMMENT "Generate TLO files"
|
|
|
|
DEPENDS tl-parser ${CMAKE_CURRENT_SOURCE_DIR}/scheme/mtproto_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/secret_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/telegram_api.tl
|
2021-03-03 23:41:09 +01:00
|
|
|
)
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
add_executable(generate_common ${TL_GENERATE_COMMON_SOURCE})
|
|
|
|
target_link_libraries(generate_common PRIVATE tdtl)
|
|
|
|
add_custom_target(tl_generate_common
|
2023-06-26 14:33:02 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
2018-02-28 02:22:17 +01:00
|
|
|
COMMAND ${GENERATE_COMMON_CMD}
|
2021-03-03 23:41:09 +01:00
|
|
|
COMMENT "Generate common TL source files"
|
2021-03-14 19:57:39 +01:00
|
|
|
DEPENDS generate_common tl_generate_tlo ${TLO_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenTlDocumentationGenerator.php
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|
2018-01-21 12:45:24 +01:00
|
|
|
if (TD_ENABLE_JNI)
|
|
|
|
target_compile_definitions(generate_common PRIVATE TD_ENABLE_JNI=1)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
2018-03-16 16:41:09 +01:00
|
|
|
if (TD_ENABLE_DOTNET)
|
|
|
|
target_compile_definitions(generate_common PRIVATE DISABLE_HPP_DOCUMENTATION=1)
|
|
|
|
endif()
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
add_executable(generate_c ${TL_GENERATE_C_SOURCE})
|
|
|
|
target_link_libraries(generate_c PRIVATE tdtl)
|
|
|
|
add_custom_target(tl_generate_c
|
2023-06-26 14:33:02 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
2018-12-31 20:04:05 +01:00
|
|
|
COMMAND generate_c
|
2021-03-03 23:41:09 +01:00
|
|
|
COMMENT "Generate C TL source files"
|
2021-03-14 19:57:39 +01:00
|
|
|
DEPENDS generate_c tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|
|
|
|
|
2018-01-21 14:06:54 +01:00
|
|
|
add_executable(td_generate_java_api ${TL_GENERATE_JAVA_SOURCE})
|
|
|
|
target_link_libraries(td_generate_java_api PRIVATE tdtl)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
add_executable(generate_json ${TL_GENERATE_JSON_SOURCE})
|
|
|
|
target_link_libraries(generate_json PRIVATE tdtl tdutils)
|
|
|
|
add_custom_target(tl_generate_json
|
2023-06-26 14:33:02 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
2018-12-31 20:04:05 +01:00
|
|
|
COMMAND generate_json
|
2021-03-03 23:41:09 +01:00
|
|
|
COMMENT "Generate JSON TL source files"
|
2021-03-14 19:57:39 +01:00
|
|
|
DEPENDS generate_json tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|
2018-01-21 12:45:24 +01:00
|
|
|
|
|
|
|
if (TD_ENABLE_JNI)
|
2020-01-24 01:03:18 +01:00
|
|
|
install(TARGETS td_generate_java_api RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
install(FILES JavadocTlDocumentationGenerator.php TlDocumentationGenerator.php DESTINATION "${CMAKE_INSTALL_BINDIR}/td/generate")
|
2021-03-05 21:15:52 +01:00
|
|
|
install(FILES ${TLO_AUTO_INCLUDE_DIR}/td_api.tlo scheme/td_api.tl DESTINATION "${CMAKE_INSTALL_BINDIR}/td/generate/scheme")
|
2018-01-21 12:45:24 +01:00
|
|
|
endif()
|
2018-02-28 11:25:07 +01:00
|
|
|
|
2018-02-28 00:09:23 +01:00
|
|
|
if (TD_ENABLE_DOTNET)
|
2018-03-16 22:26:27 +01:00
|
|
|
if (PHP_EXECUTABLE)
|
2023-06-26 14:33:02 +02:00
|
|
|
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE} && ${PHP_EXECUTABLE} ../DotnetTlDocumentationGenerator.php ../scheme/td_api.tl td/telegram/TdDotNetApi.h)
|
2018-03-16 22:26:27 +01:00
|
|
|
else()
|
2021-03-14 19:57:39 +01:00
|
|
|
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE})
|
2018-03-16 22:26:27 +01:00
|
|
|
endif()
|
|
|
|
|
2018-02-28 00:09:23 +01:00
|
|
|
add_executable(td_generate_dotnet_api generate_dotnet.cpp tl_writer_dotnet.h)
|
|
|
|
target_link_libraries(td_generate_dotnet_api PRIVATE tdtl)
|
|
|
|
add_custom_target(generate_dotnet_api
|
2023-06-26 14:33:02 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
2021-03-03 23:41:09 +01:00
|
|
|
COMMAND ${GENERATE_DOTNET_API_CMD}
|
2018-03-12 00:38:07 +01:00
|
|
|
COMMENT "Generate .NET API files"
|
2021-03-14 19:57:39 +01:00
|
|
|
DEPENDS td_generate_dotnet_api tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DotnetTlDocumentationGenerator.php
|
2018-02-28 00:09:23 +01:00
|
|
|
)
|
|
|
|
endif()
|
2018-03-16 16:29:16 +01:00
|
|
|
|
|
|
|
add_executable(remove_documentation remove_documentation.cpp)
|
|
|
|
target_link_libraries(remove_documentation PRIVATE tdtl)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|