Skip to content

Commit 1b70e48

Browse files
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
1 parent 3ff951c commit 1b70e48

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

emulator/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
22

3-
if (NOT OPENSSL_FOUND)
4-
find_package(OpenSSL REQUIRED)
5-
endif()
3+
option(EMULATOR_STATIC "Build emulator as static library" OFF)
64

75
set(EMULATOR_STATIC_SOURCE
86
transaction-emulator.cpp
@@ -22,7 +20,7 @@ include(GenerateExportHeader)
2220
add_library(emulator_static STATIC ${EMULATOR_STATIC_SOURCE})
2321
target_link_libraries(emulator_static PUBLIC ton_crypto smc-envelope)
2422

25-
if (USE_EMSCRIPTEN)
23+
if (EMULATOR_STATIC OR USE_EMSCRIPTEN)
2624
add_library(emulator STATIC ${EMULATOR_SOURCE})
2725
else()
2826
add_library(emulator SHARED ${EMULATOR_SOURCE})
@@ -35,7 +33,7 @@ else()
3533
endif()
3634

3735
generate_export_header(emulator EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/emulator_export.h)
38-
if (USE_EMSCRIPTEN)
36+
if (EMULATOR_STATIC OR USE_EMSCRIPTEN)
3937
target_compile_definitions(emulator PUBLIC EMULATOR_STATIC_DEFINE)
4038
endif()
4139
target_include_directories(emulator PUBLIC

tonlib/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
22

3+
option(TONLIBJSON_STATIC "Build tonlibjson as static library" OFF)
4+
35
if (NOT OPENSSL_FOUND)
46
find_package(OpenSSL REQUIRED)
57
endif()
@@ -90,7 +92,7 @@ set(TONLIB_JSON_HEADERS tonlib/tonlib_client_json.h)
9092
set(TONLIB_JSON_SOURCE tonlib/tonlib_client_json.cpp)
9193

9294
include(GenerateExportHeader)
93-
if (USE_EMSCRIPTEN)
95+
if (TONLIBJSON_STATIC OR USE_EMSCRIPTEN)
9496
add_library(tonlibjson STATIC ${TONLIB_JSON_SOURCE})
9597
else()
9698
add_library(tonlibjson SHARED ${TONLIB_JSON_SOURCE})
@@ -103,7 +105,7 @@ else()
103105
endif()
104106

105107
generate_export_header(tonlibjson EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/tonlib/tonlibjson_export.h)
106-
if (USE_EMSCRIPTEN)
108+
if (TONLIBJSON_STATIC OR USE_EMSCRIPTEN)
107109
target_compile_definitions(tonlibjson PUBLIC TONLIBJSON_STATIC_DEFINE)
108110
endif()
109111
target_include_directories(tonlibjson PUBLIC
@@ -157,7 +159,7 @@ endif()
157159

158160
install(FILES ${TONLIB_JSON_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/tonlib/tonlibjson_export.h DESTINATION include/tonlib/)
159161

160-
if (NOT USE_EMSCRIPTEN)
162+
if (NOT USE_EMSCRIPTEN AND NOT TONLIBJSON_STATIC)
161163
install(EXPORT Tonlib
162164
FILE TonlibTargets.cmake
163165
NAMESPACE Tonlib::

0 commit comments

Comments
 (0)