aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2024-10-21 12:58:06 +0300
committerlevlam <levlam@telegram.org>2024-10-21 12:58:06 +0300
commit6b799754f988b3a475be29ab894782c691583de6 (patch)
tree6122932decf03d823d1b098f16790efd10e4cf8c
parentb39769be86584c2f100b119d4d0704cc5556ce76 (diff)
Add separate TD_INSTALL_STATIC_LIBRARIES and TD_INSTALL_SHARED_LIBRARIES options.
-rw-r--r--CMake/GeneratePkgConfig.cmake6
-rw-r--r--CMakeLists.txt76
-rw-r--r--sqlite/CMakeLists.txt4
-rw-r--r--tdactor/CMakeLists.txt4
-rw-r--r--tddb/CMakeLists.txt4
-rw-r--r--tdnet/CMakeLists.txt4
-rw-r--r--tdutils/CMakeLists.txt7
7 files changed, 62 insertions, 43 deletions
diff --git a/CMake/GeneratePkgConfig.cmake b/CMake/GeneratePkgConfig.cmake
index 57e59ca74..54f46c326 100644
--- a/CMake/GeneratePkgConfig.cmake
+++ b/CMake/GeneratePkgConfig.cmake
@@ -93,9 +93,5 @@ ${REQUIRES}${LIBRARIES}")
if (NOT (LIBRARY_TYPE STREQUAL STATIC_LIBRARY OR LIBRARY_TYPE STREQUAL SHARED_LIBRARY))
message(FATAL_ERROR "Don't know how to handle ${TARGET} of type ${LIBRARY_TYPE}")
endif()
- if (NOT TD_ENABLE_FILTERED_INSTALL
- OR (LIBRARY_TYPE STREQUAL SHARED_LIBRARY AND BUILD_SHARED_LIBS)
- OR (LIBRARY_TYPE STREQUAL STATIC_LIBRARY AND NOT BUILD_SHARED_LIBS))
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
- endif()
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/${TARGET}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endfunction()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 818495b21..9adbea490 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,8 @@ endif()
include(PreventInSourceBuild)
prevent_in_source_build()
-option(TD_ENABLE_FILTERED_INSTALL "Use \"ON\" to limit installation to files (libraries, dev files) relevant for the chosen \"BUILD_SHARED_LIBS\" value." OFF)
+option(TD_INSTALL_STATIC_LIBRARIES "Enable installation of static libraries." ON)
+option(TD_INSTALL_SHARED_LIBRARIES "Enable installation of shared libraries." ON)
option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.")
option(TD_ENABLE_DOTNET "Use \"ON\" to enable generation of C++/CLI or C++/CX TDLib API bindings.")
if (NOT CMAKE_CROSSCOMPILING)
@@ -168,9 +169,10 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/td/telegram/GitCommitHash.cpp.in" "$
add_subdirectory(tdtl)
if (TD_GENERATE_SOURCE_FILES)
- set(TDUTILS_MIME_TYPE ON CACHE BOOL "")
- set(TDUTILS_USE_EXTERNAL_DEPENDENCIES OFF CACHE BOOL "")
+ set(TDUTILS_MIME_TYPE ON CACHE BOOL "" FORCE)
+ set(TDUTILS_USE_EXTERNAL_DEPENDENCIES OFF CACHE BOOL "" FORCE)
endif()
+set(TDUTILS_ENABLE_INSTALL ${TD_INSTALL_STATIC_LIBRARIES} CACHE BOOL "" FORCE)
add_subdirectory(tdutils)
add_subdirectory(td/generate)
@@ -213,12 +215,16 @@ if (NOT TDUTILS_MIME_TYPE OR NOT TDUTILS_USE_EXTERNAL_DEPENDENCIES)
return()
endif()
+set(TDACTOR_ENABLE_INSTALL ${TD_INSTALL_STATIC_LIBRARIES} CACHE BOOL "" FORCE)
add_subdirectory(tdactor)
+set(TDNET_ENABLE_INSTALL ${TD_INSTALL_STATIC_LIBRARIES} CACHE BOOL "" FORCE)
add_subdirectory(tdnet)
+set(TDSQLITE_ENABLE_INSTALL ${TD_INSTALL_STATIC_LIBRARIES} CACHE BOOL "" FORCE)
add_subdirectory(sqlite)
+set(TDDB_ENABLE_INSTALL ${TD_INSTALL_STATIC_LIBRARIES} CACHE BOOL "" FORCE)
add_subdirectory(tddb)
if (BUILD_TESTING)
@@ -1311,7 +1317,7 @@ add_library(Td::TdJsonStatic ALIAS TdJsonStatic)
set(INSTALL_TARGETS tdjson TdJson)
set(INSTALL_STATIC_TARGETS tdjson_static TdJsonStatic tdjson_private "${TD_CORE_PART_TARGETS}" tdcore tdmtproto tdclient TdStatic tdapi)
-if (NOT TD_ENABLE_FILTERED_INSTALL OR BUILD_SHARED_LIBS)
+if (TD_INSTALL_SHARED_LIBRARIES)
install(TARGETS ${INSTALL_TARGETS} EXPORT TdTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@@ -1320,7 +1326,7 @@ if (NOT TD_ENABLE_FILTERED_INSTALL OR BUILD_SHARED_LIBS)
)
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TD_INSTALL_STATIC_LIBRARIES)
install(TARGETS ${INSTALL_STATIC_TARGETS} EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@@ -1331,27 +1337,31 @@ endif()
# generate pkg-config files
include(GeneratePkgConfig)
-generate_pkgconfig(tdutils "Telegram Library - Utils")
-generate_pkgconfig(tdactor "Telegram Library - Actor")
-generate_pkgconfig(tdnet "Telegram Library - Net")
-generate_pkgconfig(tdsqlite "Telegram Library - SQLite")
-generate_pkgconfig(tddb "Telegram Library - Database")
-if (MEMPROF)
- # generate_pkgconfig(memprof "memprof - simple library for memory usage profiling")
+if (TD_INSTALL_STATIC_LIBRARIES)
+ generate_pkgconfig(tdutils "Telegram Library - Utils")
+ generate_pkgconfig(tdactor "Telegram Library - Actor")
+ generate_pkgconfig(tdnet "Telegram Library - Net")
+ generate_pkgconfig(tdsqlite "Telegram Library - SQLite")
+ generate_pkgconfig(tddb "Telegram Library - Database")
+ if (MEMPROF)
+ # generate_pkgconfig(memprof "memprof - simple library for memory usage profiling")
+ endif()
+ generate_pkgconfig(tdmtproto "Telegram Library - MTProto implementation")
+ generate_pkgconfig(tdcore "Telegram Library - Core")
+ generate_pkgconfig(tdclient "Telegram Library - C++ Interface")
+ if (TD_ENABLE_DOTNET)
+ # generate_pkgconfig(tddotnet "Telegram Library - C# Interface")
+ endif()
+ # generate_pkgconfig(tdc "Telegram Library - C interface")
+ generate_pkgconfig(tdapi "Telegram Library - API")
+ generate_pkgconfig(tdjson_private "Telegram Library - JSON interface (private)")
+ generate_pkgconfig(tdjson_static "Telegram Library - JSON interface (static)")
endif()
-generate_pkgconfig(tdmtproto "Telegram Library - MTProto implementation")
-generate_pkgconfig(tdcore "Telegram Library - Core")
-generate_pkgconfig(tdclient "Telegram Library - C++ Interface")
-if (TD_ENABLE_DOTNET)
- # generate_pkgconfig(tddotnet "Telegram Library - C# Interface")
+if (TD_INSTALL_SHARED_LIBRARIES)
+ generate_pkgconfig(tdjson "Telegram Library - JSON interface (shared)")
endif()
-# generate_pkgconfig(tdc "Telegram Library - C interface")
-generate_pkgconfig(tdapi "Telegram Library - API")
-generate_pkgconfig(tdjson_private "Telegram Library - JSON interface (private)")
-generate_pkgconfig(tdjson "Telegram Library - JSON interface (shared)")
-generate_pkgconfig(tdjson_static "Telegram Library - JSON interface (static)")
-if (NOT TD_ENABLE_FILTERED_INSTALL OR BUILD_SHARED_LIBS)
+if (TD_INSTALL_SHARED_LIBRARIES)
install(EXPORT TdTargets
FILE TdTargets.cmake
NAMESPACE Td::
@@ -1359,7 +1369,7 @@ if (NOT TD_ENABLE_FILTERED_INSTALL OR BUILD_SHARED_LIBS)
)
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TD_INSTALL_STATIC_LIBRARIES)
install(EXPORT TdStaticTargets
FILE TdStaticTargets.cmake
NAMESPACE Td::
@@ -1367,13 +1377,17 @@ if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
)
endif()
-# Install tdjson/tdjson_static:
-install(FILES ${TD_JSON_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/td/telegram/tdjson_export.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
-# Install tdclient:
-install(FILES td/telegram/Client.h td/telegram/Log.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
-# Install tdapi:
-install(FILES td/tl/TlObject.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/tl")
-install(FILES "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.h" "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.hpp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
+if (TD_INSTALL_SHARED_LIBRARIES OR TD_INSTALL_STATIC_LIBRARIES)
+ # Install tdjson/tdjson_static:
+ install(FILES ${TD_JSON_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/td/telegram/tdjson_export.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
+endif()
+if (TD_INSTALL_STATIC_LIBRARIES)
+ # Install tdclient:
+ install(FILES td/telegram/Client.h td/telegram/Log.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
+ # Install tdapi:
+ install(FILES td/tl/TlObject.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/tl")
+ install(FILES "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.h" "${TL_TD_AUTO_INCLUDE_DIR}/td/telegram/td_api.hpp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/telegram")
+endif()
if (TD_ENABLE_JNI)
install(FILES td/tl/tl_jni_object.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/td/tl")
endif()
diff --git a/sqlite/CMakeLists.txt b/sqlite/CMakeLists.txt
index 539eb631e..497cbe15e 100644
--- a/sqlite/CMakeLists.txt
+++ b/sqlite/CMakeLists.txt
@@ -2,6 +2,8 @@ if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
message(FATAL_ERROR "CMake >= 3.0.2 is required")
endif()
+option(TDSQLITE_ENABLE_INSTALL "Enable installation of the library." ON)
+
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
@@ -70,7 +72,7 @@ elseif (MSVC)
target_compile_options(tdsqlite PRIVATE /wd4996)
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TDSQLITE_ENABLE_INSTALL)
install(TARGETS tdsqlite EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
diff --git a/tdactor/CMakeLists.txt b/tdactor/CMakeLists.txt
index 0b0ecd1db..735f7a518 100644
--- a/tdactor/CMakeLists.txt
+++ b/tdactor/CMakeLists.txt
@@ -2,6 +2,8 @@ if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
message(FATAL_ERROR "CMake >= 3.0.2 is required")
endif()
+option(TDACTOR_ENABLE_INSTALL "Enable installation of the library." ON)
+
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
@@ -51,7 +53,7 @@ if (NOT CMAKE_CROSSCOMPILING)
target_link_libraries(example PRIVATE tdactor)
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TDACTOR_ENABLE_INSTALL)
install(TARGETS tdactor EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
diff --git a/tddb/CMakeLists.txt b/tddb/CMakeLists.txt
index 7f9d40a84..423c93160 100644
--- a/tddb/CMakeLists.txt
+++ b/tddb/CMakeLists.txt
@@ -2,6 +2,8 @@ if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
message(FATAL_ERROR "CMake >= 3.0.2 is required")
endif()
+option(TDDB_ENABLE_INSTALL "Enable installation of the library." ON)
+
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
@@ -55,7 +57,7 @@ if (NOT CMAKE_CROSSCOMPILING)
target_link_libraries(binlog_dump PRIVATE tddb)
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TDDB_ENABLE_INSTALL)
install(TARGETS tddb EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
diff --git a/tdnet/CMakeLists.txt b/tdnet/CMakeLists.txt
index fead65f0b..f39c91fa2 100644
--- a/tdnet/CMakeLists.txt
+++ b/tdnet/CMakeLists.txt
@@ -2,6 +2,8 @@ if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
message(FATAL_ERROR "CMake >= 3.0.2 is required")
endif()
+option(TDNET_ENABLE_INSTALL "Enable installation of the library." ON)
+
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
@@ -80,7 +82,7 @@ if (APPLE_WATCH)
target_link_libraries(tdnet PRIVATE ${FOUNDATION_LIBRARY})
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TDNET_ENABLE_INSTALL)
install(TARGETS tdnet EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
diff --git a/tdutils/CMakeLists.txt b/tdutils/CMakeLists.txt
index 4b6ac1c2a..eed7980e4 100644
--- a/tdutils/CMakeLists.txt
+++ b/tdutils/CMakeLists.txt
@@ -2,8 +2,9 @@ if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
message(FATAL_ERROR "CMake >= 3.0.2 is required")
endif()
-option(TDUTILS_MIME_TYPE "Generate MIME types conversion; requires gperf" ON)
-option(TDUTILS_USE_EXTERNAL_DEPENDENCIES "Use external libraries if available" ON)
+option(TDUTILS_ENABLE_INSTALL "Enable installation of the library." ON)
+option(TDUTILS_MIME_TYPE "Generate MIME types conversion; requires gperf." ON)
+option(TDUTILS_USE_EXTERNAL_DEPENDENCIES "Use external libraries if available." ON)
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
@@ -409,7 +410,7 @@ if (ATOMICS_LIBRARIES)
target_link_libraries(tdutils PUBLIC "${ATOMICS_LIBRARIES}")
endif()
-if (NOT TD_ENABLE_FILTERED_INSTALL OR NOT BUILD_SHARED_LIBS)
+if (TDUTILS_ENABLE_INSTALL)
install(TARGETS tdutils EXPORT TdStaticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"