1- cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
1+ cmake_minimum_required (VERSION 3.16 FATAL_ERROR)
22
33project (TON VERSION 0.5 LANGUAGES C CXX)
44set (CMAKE_POSITION_INDEPENDENT_CODE ON )
@@ -159,6 +159,9 @@ if (TON_USE_ROCKSDB)
159159 set (FAIL_ON_WARNINGS OFF CACHE BOOL "fail on warnings" )
160160 message ("Add rocksdb" )
161161 add_subdirectory (third-party/rocksdb EXCLUDE_FROM_ALL )
162+ # Broken CMake in rocksdb alters properties it has no business changing.
163+ set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE )
164+ set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK )
162165endif ()
163166
164167option (USE_COROUTINES "experimental support of coroutines" OFF )
@@ -188,11 +191,12 @@ include(BuildSECP256K1)
188191
189192# Configure CCache if available
190193find_program (CCACHE_FOUND ccache)
191- #set(CCACHE_FOUND 0)
192194if (CCACHE_FOUND)
193- message (STATUS "Found ccache" )
194- set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
195- set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
195+ if (NOT DEFINED CMAKE_C_COMPILER_LAUNCHER AND NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
196+ message (STATUS "Using ccache" )
197+ set (CMAKE_C_COMPILER_LAUNCHER ccache)
198+ set (CMAKE_CXX_COMPILER_LAUNCHER ccache)
199+ endif ()
196200else ()
197201 message (STATUS "Could NOT find ccache" )
198202endif ()
@@ -341,6 +345,14 @@ add_cxx_compiler_flag("-Qunused-arguments")
341345add_cxx_compiler_flag("-Wno-unused-private-field" )
342346add_cxx_compiler_flag("-Wno-redundant-move" )
343347
348+ if (GCC OR CLANG)
349+ if (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo" )
350+ # For historical reasons, CMake falls back to -O2 optimization level when CMAKE_BUILD_TYPE is
351+ # set to RelWithDebInfo.
352+ add_compile_options (-O3)
353+ endif ()
354+ endif ()
355+
344356#add_cxx_compiler_flag("-Wno-unused-function")
345357#add_cxx_compiler_flag("-Wno-unused-variable")
346358#add_cxx_compiler_flag("-Wno-shorten-64-to-32")
@@ -351,22 +363,13 @@ if (CLANG)
351363 #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
352364endif ()
353365if (TON_USE_ASAN)
354- if (CLANG)
355- add_cxx_compiler_flag("-stdlib=libc++" )
356- endif ()
357366 add_cxx_compiler_flag("-fsanitize=address" )
358367 add_definitions (-DTD_USE_ASAN=1)
359368endif ()
360369if (TON_USE_TSAN)
361- if (CLANG)
362- add_cxx_compiler_flag("-stdlib=libc++" )
363- endif ()
364370 add_cxx_compiler_flag("-fsanitize=thread" )
365371endif ()
366372if (TON_USE_UBSAN)
367- if (CLANG)
368- add_cxx_compiler_flag("-stdlib=libc++" )
369- endif ()
370373 add_cxx_compiler_flag("-fsanitize=undefined" )
371374endif ()
372375#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
0 commit comments