1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Add option to build static tonlibjson and emulator (#1527)

* add option to build static tonlibjson and emulator

* do not export cmake project in case of static tonlibjson
This commit is contained in:
Marat 2025-02-23 13:01:33 +01:00 committed by GitHub
parent 3ff951c225
commit 1b70e48327
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)
endif()
option(EMULATOR_STATIC "Build emulator as static library" OFF)
set(EMULATOR_STATIC_SOURCE
transaction-emulator.cpp
@ -22,7 +20,7 @@ include(GenerateExportHeader)
add_library(emulator_static STATIC ${EMULATOR_STATIC_SOURCE})
target_link_libraries(emulator_static PUBLIC ton_crypto smc-envelope)
if (USE_EMSCRIPTEN)
if (EMULATOR_STATIC OR USE_EMSCRIPTEN)
add_library(emulator STATIC ${EMULATOR_SOURCE})
else()
add_library(emulator SHARED ${EMULATOR_SOURCE})
@ -35,7 +33,7 @@ else()
endif()
generate_export_header(emulator EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/emulator_export.h)
if (USE_EMSCRIPTEN)
if (EMULATOR_STATIC OR USE_EMSCRIPTEN)
target_compile_definitions(emulator PUBLIC EMULATOR_STATIC_DEFINE)
endif()
target_include_directories(emulator PUBLIC

View file

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
option(TONLIBJSON_STATIC "Build tonlibjson as static library" OFF)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL REQUIRED)
endif()
@ -90,7 +92,7 @@ set(TONLIB_JSON_HEADERS tonlib/tonlib_client_json.h)
set(TONLIB_JSON_SOURCE tonlib/tonlib_client_json.cpp)
include(GenerateExportHeader)
if (USE_EMSCRIPTEN)
if (TONLIBJSON_STATIC OR USE_EMSCRIPTEN)
add_library(tonlibjson STATIC ${TONLIB_JSON_SOURCE})
else()
add_library(tonlibjson SHARED ${TONLIB_JSON_SOURCE})
@ -103,7 +105,7 @@ else()
endif()
generate_export_header(tonlibjson EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/tonlib/tonlibjson_export.h)
if (USE_EMSCRIPTEN)
if (TONLIBJSON_STATIC OR USE_EMSCRIPTEN)
target_compile_definitions(tonlibjson PUBLIC TONLIBJSON_STATIC_DEFINE)
endif()
target_include_directories(tonlibjson PUBLIC
@ -157,7 +159,7 @@ endif()
install(FILES ${TONLIB_JSON_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/tonlib/tonlibjson_export.h DESTINATION include/tonlib/)
if (NOT USE_EMSCRIPTEN)
if (NOT USE_EMSCRIPTEN AND NOT TONLIBJSON_STATIC)
install(EXPORT Tonlib
FILE TonlibTargets.cmake
NAMESPACE Tonlib::