@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
22
33project (TON VERSION 0.5 LANGUAGES C CXX)
44set (CMAKE_POSITION_INDEPENDENT_CODE ON )
5- #set(OPENSSL_USE_STATIC_LIBS TRUE)
65
76# Define the two required variables before including the source code for watching a git repository.
87set (PRE_CONFIGURE_FILE "git.cc.in" )
@@ -35,6 +34,16 @@ set(CMAKE_CXX_EXTENSIONS FALSE)
3534
3635set (CMAKE_COLOR_DIAGNOSTICS TRUE )
3736
37+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
38+ set (GCC 1)
39+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
40+ set (CLANG 1)
41+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
42+ set (INTEL 1)
43+ elseif (NOT MSVC )
44+ message (FATAL_ERROR "Compiler isn't supported" )
45+ endif ()
46+
3847#BEGIN internal
3948option (BUILD_SHARED_LIBS "Use \" ON\" to build shared libraries instead of static where it's not specified (not recommended)" OFF )
4049option (USE_EMSCRIPTEN "Use \" ON\" for config building wasm." OFF )
@@ -77,16 +86,29 @@ if ((ARCHITECTURE MATCHES "arm64") AND (CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND
7786endif ()
7887#END M1 support
7988
89+ if (CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "20" )
90+ add_compile_options (--warning-suppression-mappings=${CMAKE_SOURCE_DIR} /suppression_mappings.txt)
91+ endif ()
92+
93+ option (TON_WERROR_BUILD "Use -Werror" OFF )
94+
95+ # If we want to check -Werror build in CI, we want to use it for third party projects as well but we
96+ # don't want to force our warning options on them.
97+ if (TON_WERROR_BUILD)
98+ add_compile_options (-Werror)
99+ endif ()
100+
80101if (TON_USE_ABSEIL)
81102 message ("Add abseil-cpp" )
82- set (ABSL_PROPAGATE_CXX_STD TRUE )
83- add_subdirectory (third-party/abseil-cpp EXCLUDE_FROM_ALL )
103+ function (abseil_scope)
104+ set (ABSL_PROPAGATE_CXX_STD TRUE )
105+ set (CMAKE_POLICY_VERSION_MINIMUM "3.10" )
106+ add_subdirectory (third-party/abseil-cpp EXCLUDE_FROM_ALL )
107+ endfunction ()
108+ abseil_scope()
84109 set (ABSL_FOUND 1)
85110endif ()
86111
87- #add_subdirectory(third-party/libcuckoo EXCLUDE_FROM_ALL)
88- #add_subdirectory(third-party/junction EXCLUDE_FROM_ALL)
89-
90112if (WIN32 )
91113 message ("Add wingetopt" )
92114 function (wingetopt_scope)
@@ -166,16 +188,6 @@ else()
166188 message (STATUS "Could NOT find ccache" )
167189endif ()
168190
169- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
170- set (GCC 1)
171- elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
172- set (CLANG 1)
173- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
174- set (INTEL 1)
175- elseif (NOT MSVC )
176- message (FATAL_ERROR "Compiler isn't supported" )
177- endif ()
178-
179191include (CheckCXXCompilerFlag)
180192
181193set (CMAKE_THREAD_PREFER_PTHREAD ON )
@@ -282,33 +294,37 @@ set(TONLIB_COMPILE "0")
282294 set (TONLIB_COMPILE "1" )
283295#END tonlib
284296
285- include (AddCXXCompilerFlag)
286297if (MSVC )
287- add_cxx_compiler_flag("/experimental:external /external:anglebrackets /external:W0" )
288- endif ()
289- if (NOT MSVC )
290- add_cxx_compiler_flag("-Wall" )
291- add_cxx_compiler_flag("-Wextra" )
292- endif ()
293-
294- add_cxx_compiler_flag("-Wimplicit-fallthrough=2" )
295- add_cxx_compiler_flag("-Wpointer-arith" )
296- add_cxx_compiler_flag("-Wcast-qual" )
297- add_cxx_compiler_flag("-Wsign-compare" )
298- add_cxx_compiler_flag("-Wduplicated-branches" )
299- add_cxx_compiler_flag("-Wduplicated-cond" )
300- add_cxx_compiler_flag("-Walloc-zero" )
301- add_cxx_compiler_flag("-Wlogical-op" )
302- add_cxx_compiler_flag("-Wno-tautological-compare" )
303- add_cxx_compiler_flag("-Wpointer-arith" )
304- add_cxx_compiler_flag("-Wvla" )
305- add_cxx_compiler_flag("-Wnon-virtual-dtor" )
306- add_cxx_compiler_flag("-Wno-unused-parameter" )
307- add_cxx_compiler_flag("-Wconversion" )
308- add_cxx_compiler_flag("-Wno-sign-conversion" )
309- add_cxx_compiler_flag("-Qunused-arguments" )
310- add_cxx_compiler_flag("-Wno-unused-private-field" )
311- add_cxx_compiler_flag("-Wno-redundant-move" )
298+ add_compile_options (/experimental:external /external:anglebrackets /external:W0)
299+ endif ()
300+
301+ if (GCC OR CLANG)
302+ add_compile_options (-Wall)
303+ add_compile_options (-Wextra)
304+
305+ add_compile_options (-Wpointer-arith)
306+ add_compile_options (-Wcast-qual)
307+ add_compile_options (-Wsign-compare)
308+ add_compile_options (-Wpointer-arith)
309+ add_compile_options (-Wvla)
310+ add_compile_options (-Wnon-virtual-dtor)
311+ add_compile_options (-Wconversion)
312+
313+ # TODO: Either justify all of these or remove.
314+ add_compile_options (-Wno-tautological-compare)
315+ add_compile_options (-Wno-unused-parameter)
316+ add_compile_options (-Wno-sign-conversion)
317+ add_compile_options (-Wno-unused-private -field)
318+ add_compile_options (-Wno-redundant-move)
319+
320+ if (GCC)
321+ add_compile_options (-Wimplicit-fallthrough=2)
322+ add_compile_options (-Wduplicated-branches)
323+ add_compile_options (-Wduplicated-cond)
324+ add_compile_options (-Walloc-zero)
325+ add_compile_options (-Wlogical-op)
326+ endif ()
327+ endif ()
312328
313329if (GCC OR CLANG)
314330 if (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo" )
@@ -318,30 +334,19 @@ if (GCC OR CLANG)
318334 endif ()
319335endif ()
320336
321- #add_cxx_compiler_flag("-Wno-unused-function")
322- #add_cxx_compiler_flag("-Wno-unused-variable")
323- #add_cxx_compiler_flag("-Wno-shorten-64-to-32")
324- #add_cxx_compiler_flag("-Werror")
325-
326- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/c++/v1")
327- if (CLANG)
328- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
329- endif ()
330337if (TON_USE_ASAN)
331- add_cxx_compiler_flag("-fsanitize=address" )
338+ add_compile_options (-fsanitize=address)
339+ add_link_options (-fsanitize=address)
332340 add_definitions (-DTD_USE_ASAN=1)
333341endif ()
334342if (TON_USE_TSAN)
335- add_cxx_compiler_flag("-fsanitize=thread" )
343+ add_compile_options (-fsanitize=thread)
344+ add_link_options (-fsanitize=thread)
336345endif ()
337346if (TON_USE_UBSAN)
338- add_cxx_compiler_flag("-fsanitize=undefined" )
347+ add_compile_options (-fsanitize=undefined)
348+ add_link_options (-fsanitize=undefined)
339349endif ()
340- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
341- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
342- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
343- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
344- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finstrument-functions")
345350
346351#Compilation database
347352set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
@@ -451,10 +456,6 @@ target_link_libraries(test-fift PRIVATE fift-lib)
451456
452457add_executable (test -tdutils test /test -td-main.cpp ${TDUTILS_TEST_SOURCE} )
453458target_link_libraries (test -tdutils PRIVATE tdutils ${CMAKE_THREAD_LIBS_INIT} memprof ${JEMALLOC_LIBRARIES} )
454- #target_link_libraries_system(test-tdutils absl::base absl::container absl::hash )
455- #target_link_libraries_system(test-tdutils libcuckoo)
456- #target_include_directories(test-tdutils PRIVATE SYSTEM ${JUNCTION_ALL_INCLUDE_DIRS})
457- #target_link_libraries(test-tdutils PRIVATE ${JUNCTION_ALL_LIBRARIES})
458459
459460add_executable (test -tdactor test /test -td-main.cpp ${TDACTOR_TEST_SOURCE} )
460461target_link_libraries (test -tdactor PRIVATE tdactor ${CMAKE_THREAD_LIBS_INIT} )
@@ -535,7 +536,7 @@ if (HAS_PARENT)
535536 ${ED25519_TEST_SOURCE}
536537 ${TONDB_TEST_SOURCE}
537538 ${BIGNUM_TEST_SOURCE}
538- ${CELLS_TEST_SOURCE} # ${TONVM_TEST_SOURCE} ${FIFT_TEST_SOURCE} ${TONLIB_ONLINE_TEST_SOURCE}
539+ ${CELLS_TEST_SOURCE}
539540 PARENT_SCOPE)
540541endif ()
541542add_library (all_tests INTERFACE )
0 commit comments