2020-09-11 18:43:56 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2017-10-30 13:35:34 +00:00
|
|
|
|
2020-12-20 03:14:50 +00:00
|
|
|
# Please note that cmake support is very preliminary. Autotools-based
|
|
|
|
# build is the only fully supported build for now.
|
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
# Based on configure.ac
|
|
|
|
|
2024-01-05 17:23:30 +00:00
|
|
|
project(gperftools VERSION 2.15 LANGUAGES C CXX
|
2020-09-11 18:43:56 +00:00
|
|
|
DESCRIPTION "Performance tools for C++"
|
2023-07-31 18:28:58 +00:00
|
|
|
HOMEPAGE_URL https://github.com/gperftools/gperftools)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
# Update this value for every release!
|
2024-01-05 17:23:30 +00:00
|
|
|
set(TCMALLOC_SO_VERSION 9.16.5)
|
|
|
|
set(PROFILER_SO_VERSION 5.11.5)
|
|
|
|
set(TCMALLOC_AND_PROFILER_SO_VERSION 10.11.6)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
# The user can choose not to compile in the heap-profiler, the
|
|
|
|
# heap-checker, or the cpu-profiler. There's also the possibility
|
|
|
|
# for a 'fully minimal' compile, which leaves out the stacktrace
|
|
|
|
# code as well. By default, we include all of these that the
|
|
|
|
# target system supports.
|
|
|
|
set(DEFAULT_BUILD_CPU_PROFILER ON)
|
|
|
|
set(DEFAULT_BUILD_HEAP_PROFILER ON)
|
2023-06-21 14:39:25 +00:00
|
|
|
set(DEFAULT_BUILD_HEAP_CHECKER OFF)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(DEFAULT_BUILD_DEBUGALLOC ON)
|
|
|
|
set(DEFAULT_BUILD_MINIMAL OFF)
|
|
|
|
|
|
|
|
set(DEFAULT_TCMALLOC_ALIGNMENT 16)
|
|
|
|
|
|
|
|
set(HOST string(TOLOWER "${CMAKE_SYSTEM_NAME}"))
|
|
|
|
|
|
|
|
if(MINGW OR MSVC)
|
|
|
|
set(DEFAULT_BUILD_MINIMAL ON)
|
|
|
|
set(DEFAULT_BUILD_DEBUGALLOC OFF)
|
2017-11-03 00:07:29 +00:00
|
|
|
elseif(CYGWIN)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(DEFAULT_BUILD_CPU_PROFILER OFF)
|
2023-06-21 14:39:25 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Heap checker is Linux-only (and deprecated).
|
|
|
|
if(CMAKE_SYSTEM MATCHES Linux)
|
|
|
|
set(DEFAULT_BUILD_HEAP_CHECKER ON)
|
2017-10-30 13:35:34 +00:00
|
|
|
endif()
|
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
include(CheckCCompilerFlag)
|
2023-09-21 02:31:29 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
2017-11-05 17:23:42 +00:00
|
|
|
include(CheckCSourceCompiles)
|
2017-11-01 13:52:02 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
2017-10-31 02:26:13 +00:00
|
|
|
include(CheckFunctionExists)
|
2017-11-05 17:23:42 +00:00
|
|
|
include(CheckIncludeFile)
|
2017-11-01 13:52:02 +00:00
|
|
|
include(CheckLibraryExists)
|
2017-11-05 17:23:42 +00:00
|
|
|
include(CheckSymbolExists)
|
2017-10-31 02:26:13 +00:00
|
|
|
include(CheckTypeSize)
|
2017-11-01 13:52:02 +00:00
|
|
|
include(CheckVariableExists)
|
2017-11-08 12:24:08 +00:00
|
|
|
include(CMakeDependentOption)
|
|
|
|
include(CTest)
|
2024-02-26 21:40:11 +00:00
|
|
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
2017-11-01 13:52:02 +00:00
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2017-11-03 13:10:27 +00:00
|
|
|
include(DefineTargetVariables)
|
2017-10-31 02:26:13 +00:00
|
|
|
|
2017-11-03 13:10:27 +00:00
|
|
|
define_target_variables()
|
2017-11-03 00:07:29 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
# Currently only backtrace works on s390.
|
2021-03-01 01:52:17 +00:00
|
|
|
if(s390 OR OSX)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_enable_libunwind OFF)
|
|
|
|
set(default_enable_backtrace ON)
|
2017-10-31 02:26:13 +00:00
|
|
|
else()
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_enable_libunwind ON)
|
|
|
|
set(default_enable_backtrace OFF)
|
2017-10-31 02:26:13 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
# Disable libunwind linking on ppc64 by default.
|
2017-10-31 02:26:13 +00:00
|
|
|
if(PPC64)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_enable_libunwind OFF)
|
|
|
|
set(default_tcmalloc_pagesize 64)
|
2017-10-31 02:26:13 +00:00
|
|
|
else()
|
2023-11-25 07:39:35 +00:00
|
|
|
if(PPC)
|
|
|
|
set(default_enable_libunwind OFF)
|
|
|
|
else()
|
|
|
|
set(default_enable_libunwind ON)
|
|
|
|
endif()
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_tcmalloc_pagesize 8)
|
2017-10-31 02:26:13 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
cmake_dependent_option(
|
2020-09-11 18:43:56 +00:00
|
|
|
GPERFTOOLS_BUILD_CPU_PROFILER "Build cpu-profiler" ${DEFAULT_BUILD_CPU_PROFILER}
|
2017-11-08 12:24:08 +00:00
|
|
|
"NOT gperftools_build_minimal" OFF)
|
2017-10-31 02:26:13 +00:00
|
|
|
cmake_dependent_option(
|
2020-09-11 18:43:56 +00:00
|
|
|
GPERFTOOLS_BUILD_HEAP_PROFILER "Build heap-profiler" ${DEFAULT_BUILD_HEAP_PROFILER}
|
2017-11-08 12:24:08 +00:00
|
|
|
"NOT gperftools_build_minimal" OFF)
|
2017-10-31 02:26:13 +00:00
|
|
|
cmake_dependent_option(
|
2020-09-11 18:43:56 +00:00
|
|
|
GPERFTOOLS_BUILD_HEAP_CHECKER "Build heap-checker" ${DEFAULT_BUILD_HEAP_CHECKER}
|
2017-11-08 12:24:08 +00:00
|
|
|
"NOT gperftools_build_minimal" OFF)
|
2017-10-31 02:26:13 +00:00
|
|
|
cmake_dependent_option(
|
2020-09-11 18:43:56 +00:00
|
|
|
GPERFTOOLS_BUILD_DEBUGALLOC "Build debugalloc" ${DEFAULT_BUILD_DEBUGALLOC}
|
2017-11-08 12:24:08 +00:00
|
|
|
"NOT gperftools_build_minimal" OFF)
|
2020-09-11 18:43:56 +00:00
|
|
|
option(
|
|
|
|
gperftools_build_minimal
|
|
|
|
"Build only tcmalloc-minimal (and maybe tcmalloc-minimal-debug)"
|
|
|
|
${DEFAULT_BUILD_MINIMAL})
|
|
|
|
if(gperftools_build_minimal)
|
|
|
|
set(GPERFTOOLS_BUILD_CPU_PROFILER OFF)
|
|
|
|
set(GPERFTOOLS_BUILD_HEAP_PROFILER OFF)
|
|
|
|
set(GPERFTOOLS_BUILD_HEAP_CHECKER OFF)
|
|
|
|
endif()
|
2017-10-31 02:26:13 +00:00
|
|
|
|
2017-11-07 18:26:10 +00:00
|
|
|
cmake_dependent_option(
|
2020-09-11 18:43:56 +00:00
|
|
|
gperftools_build_benchmark "Build benchmark" ON "NOT MINGW AND NOT MSVC" OFF)
|
2017-11-07 18:26:10 +00:00
|
|
|
|
2017-11-03 13:10:27 +00:00
|
|
|
option(gperftools_enable_stacktrace_via_backtrace
|
2017-10-31 02:26:13 +00:00
|
|
|
"Enable use of backtrace() for stacktrace capturing (may deadlock)"
|
|
|
|
${default_enable_backtrace})
|
|
|
|
option(gperftools_enable_libunwind
|
|
|
|
"Enable libunwind linking"
|
|
|
|
${default_enable_libunwind})
|
|
|
|
|
2017-11-03 13:10:27 +00:00
|
|
|
set(enable_backtrace ${gperftools_enable_stacktrace_via_backtrace})
|
|
|
|
set(enable_libunwind ${gperftools_enable_libunwind})
|
|
|
|
|
2023-12-24 01:38:59 +00:00
|
|
|
option(gperftools_enable_libgcc_unwinder_by_default
|
|
|
|
"Prefer libgcc's _Unwind_Backtrace as default stacktrace capturing method"
|
|
|
|
OFF)
|
|
|
|
set(PREFER_LIBGCC_UNWINDER ${gperftools_enable_libgcc_unwinder_by_default})
|
|
|
|
|
2017-10-31 02:26:13 +00:00
|
|
|
set(gperftools_tcmalloc_pagesize ${default_tcmalloc_pagesize}
|
2017-11-05 17:23:42 +00:00
|
|
|
CACHE STRING "Set the tcmalloc internal page size")
|
2023-12-24 00:51:00 +00:00
|
|
|
set(allowed_page_sizes LIST "4;8;16;32;64;128;256")
|
|
|
|
set_property(CACHE gperftools_tcmalloc_pagesize PROPERTY STRINGS ${allowed_page_sizes})
|
|
|
|
if(NOT gperftools_tcmalloc_pagesize IN_LIST allowed_page_sizes)
|
2017-11-05 17:23:42 +00:00
|
|
|
message(WARNING
|
|
|
|
"Invalid gperftools_tcmalloc_pagesize (${gperftools_tcmalloc_pagesize}), "
|
|
|
|
"setting to default value (${default_tcmalloc_pagesize})")
|
|
|
|
set(gperftools_tcmalloc_pagesize ${default_tcmalloc_pagesize})
|
2017-10-31 02:26:13 +00:00
|
|
|
endif()
|
2023-12-24 00:51:00 +00:00
|
|
|
if (gperftools_tcmalloc_pagesize EQUAL 4)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 12)
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 8)
|
|
|
|
# default page size
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 16)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 14)
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 32)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 15)
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 64)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 16)
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 128)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 17)
|
|
|
|
elseif(gperftools_tcmalloc_pagesize EQUAL 256)
|
|
|
|
set(TCMALLOC_PAGE_SIZE_SHIFT 18)
|
|
|
|
else()
|
|
|
|
message(WARNING
|
|
|
|
"${gperftools_tcmalloc_pagesize}K size not supported, using default tcmalloc page size.")
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
2017-10-31 02:26:13 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
set(gperftools_tcmalloc_alignment ${DEFAULT_TCMALLOC_ALIGNMENT}
|
2017-11-05 17:23:42 +00:00
|
|
|
CACHE STRING "Set the tcmalloc allocation alignment")
|
2017-10-31 02:26:13 +00:00
|
|
|
set_property(CACHE gperftools_tcmalloc_alignment PROPERTY STRINGS "8" "16")
|
2017-11-01 13:52:02 +00:00
|
|
|
if(NOT gperftools_tcmalloc_alignment STREQUAL "8" AND
|
|
|
|
NOT gperftools_tcmalloc_alignment STREQUAL "16")
|
2017-11-05 17:23:42 +00:00
|
|
|
message(WARNING
|
|
|
|
"Invalid gperftools_tcmalloc_alignment (${gperftools_tcmalloc_alignment}), "
|
2020-09-11 18:43:56 +00:00
|
|
|
"setting to default value (${DEFAULT_TCMALLOC_ALIGNMENT})")
|
|
|
|
set(gperftools_tcmalloc_alignment ${DEFAULT_TCMALLOC_ALIGNMENT})
|
2017-10-31 02:26:13 +00:00
|
|
|
endif()
|
2017-11-03 13:10:27 +00:00
|
|
|
if(gperftools_tcmalloc_alignment STREQUAL "8")
|
2017-11-05 17:23:42 +00:00
|
|
|
set(TCMALLOC_ALIGN_8BYTES ON)
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
2017-10-31 02:26:13 +00:00
|
|
|
|
2024-01-30 19:44:06 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS ON)
|
|
|
|
|
|
|
|
# AX_C___ATTRIBUTE__
|
|
|
|
check_c_source_compiles("#include <stdlib.h>
|
|
|
|
static void foo(void) __attribute__ ((unused));
|
|
|
|
void foo(void) { exit(1); }
|
|
|
|
int main() { return 0; }"
|
|
|
|
HAVE___ATTRIBUTE__)
|
2017-10-31 02:26:13 +00:00
|
|
|
|
2023-12-25 00:38:09 +00:00
|
|
|
check_c_source_compiles("#include <stdlib.h>
|
|
|
|
void foo(void) __attribute__((aligned(128)));
|
|
|
|
void foo(void) { exit(1); }
|
|
|
|
int main() { return 0; }"
|
|
|
|
HAVE___ATTRIBUTE__ALIGNED_FN)
|
|
|
|
|
2017-10-31 02:26:13 +00:00
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES "malloc.h")
|
2017-11-01 13:52:02 +00:00
|
|
|
check_type_size("struct mallinfo" STRUCT_MALLINFO LANGUAGE CXX)
|
2023-12-07 13:10:51 +00:00
|
|
|
check_type_size("struct mallinfo2" STRUCT_MALLINFO2 LANGUAGE CXX)
|
2020-09-11 18:43:56 +00:00
|
|
|
check_function_exists("sbrk" HAVE_SBRK) # for tcmalloc to get memory
|
2023-07-21 01:53:54 +00:00
|
|
|
check_function_exists("__sbrk" HAVE___SBRK) # for tcmalloc to get memory
|
2020-09-11 18:43:56 +00:00
|
|
|
check_function_exists("geteuid" HAVE_GETEUID) # for turning off services when run as root
|
|
|
|
check_include_file("features.h" HAVE_FEATURES_H) # for vdso_support.h, Where __GLIBC__ is defined
|
|
|
|
check_include_file("malloc.h" HAVE_MALLOC_H) # some systems define stuff there, others not
|
|
|
|
check_include_file("glob.h" HAVE_GLOB_H) # for heap-profile-table (cleaning up profiles)
|
|
|
|
check_include_file("execinfo.h" HAVE_EXECINFO_H) # for stacktrace? and heapchecker_unittest
|
|
|
|
check_include_file("unwind.h" HAVE_UNWIND_H) # for stacktrace
|
|
|
|
check_include_file("sched.h" HAVE_SCHED_H) # for being nice in our spinlock code
|
2017-11-05 17:23:42 +00:00
|
|
|
check_include_file("sys/syscall.h" HAVE_SYS_SYSCALL_H)
|
2020-09-11 18:43:56 +00:00
|
|
|
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H) # optional; for forking out to symbolizer
|
|
|
|
check_include_file("sys/wait.h" HAVE_SYS_WAIT_H) # optional; for forking out to symbolizer
|
|
|
|
check_include_file("poll.h" HAVE_POLL_H) # optional; for forking out to symbolizer
|
|
|
|
check_include_file("fcntl.h" HAVE_FCNTL_H) # for tcmalloc_unittest
|
|
|
|
check_include_file("sys/cdefs.h" HAVE_SYS_CDEFS_H) # Where glibc defines __THROW
|
2023-12-25 00:46:40 +00:00
|
|
|
|
2023-11-27 04:43:24 +00:00
|
|
|
check_include_file("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
|
2023-12-25 00:46:40 +00:00
|
|
|
check_include_file("ucontext.h" HAVE_UCONTEXT_H)
|
|
|
|
check_include_file("cygwin/signal.h" HAVE_CYGWIN_SIGNAL_H) # ucontext on cywgin
|
|
|
|
check_include_file("asm/ptrace.h" HAVE_ASM_PTRACE_H) # get ptrace macros, e.g. PT_NIP
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
|
|
|
# We also need <ucontext.h>/<sys/ucontext.h>, but we get those from
|
|
|
|
# AC_PC_FROM_UCONTEXT, below.
|
|
|
|
|
|
|
|
# We override a lot of memory allocation routines, not all of which are
|
|
|
|
# standard. For those the system doesn't declare, we'll declare ourselves.
|
2017-11-01 13:52:02 +00:00
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=600)
|
2017-11-05 17:23:42 +00:00
|
|
|
check_symbol_exists("cfree" "stdlib.h;malloc.h" HAVE_DECL_CFREE)
|
|
|
|
check_symbol_exists("posix_memalign" "stdlib.h;malloc.h" HAVE_DECL_POSIX_MEMALIGN)
|
|
|
|
check_symbol_exists("memalign" "stdlib.h;malloc.h" HAVE_DECL_MEMALIGN)
|
|
|
|
check_symbol_exists("valloc" "stdlib.h;malloc.h" HAVE_DECL_VALLOC)
|
|
|
|
check_symbol_exists("pvalloc" "stdlib.h;malloc.h" HAVE_DECL_PVALLOC)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
2017-11-03 13:10:27 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(HAVE_STRUCT_MALLINFO)
|
|
|
|
set(HAVE_STRUCT_MALLINFO 1)
|
2017-11-03 13:10:27 +00:00
|
|
|
else()
|
2020-09-11 18:43:56 +00:00
|
|
|
set(HAVE_STRUCT_MALLINFO 0)
|
|
|
|
endif()
|
|
|
|
|
2023-12-07 13:10:51 +00:00
|
|
|
if(HAVE_STRUCT_MALLINFO2)
|
|
|
|
set(HAVE_STRUCT_MALLINFO2 1)
|
|
|
|
else()
|
|
|
|
set(HAVE_STRUCT_MALLINFO2 0)
|
|
|
|
endif()
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
# We hardcode HAVE_MMAP to 1. There are no interesting systems anymore
|
|
|
|
# without functional mmap. And our windows (except mingw) builds
|
|
|
|
# aren't using autoconf. So we keep HAVE_MMAP define, but only to
|
|
|
|
# distingush windows and rest.
|
|
|
|
if(NOT WIN32)
|
|
|
|
set(HAVE_MMAP 1)
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
|
|
|
|
2017-11-01 13:52:02 +00:00
|
|
|
if(gperftools_enable_libunwind)
|
2017-11-05 17:23:42 +00:00
|
|
|
check_include_file("libunwind.h" HAVE_LIBUNWIND_H)
|
2017-11-08 12:24:08 +00:00
|
|
|
if(HAVE_LIBUNWIND_H)
|
|
|
|
find_library(libunwind_location NAMES unwind)
|
|
|
|
if(libunwind_location)
|
|
|
|
check_library_exists(
|
|
|
|
unwind backtrace ${libunwind_location} have_libunwind)
|
|
|
|
endif()
|
|
|
|
if(have_libunwind)
|
2017-11-08 16:20:25 +00:00
|
|
|
set(unwind_libs ${libunwind_location})
|
2017-11-08 12:24:08 +00:00
|
|
|
set(will_use_libunwind ON)
|
2023-06-21 14:38:31 +00:00
|
|
|
set(USE_LIBUNWIND 1)
|
2017-11-08 12:24:08 +00:00
|
|
|
endif()
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-07-02 23:35:46 +00:00
|
|
|
check_c_compiler_flag("-fno-omit-frame-pointer -momit-leaf-frame-pointer" have_omit_leaf_fp)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#if !(__i386__ || __x86_64__ || __riscv || __aarch64__)
|
|
|
|
#error unsupported arch
|
|
|
|
#endif
|
|
|
|
int main() { return 0; }
|
|
|
|
"
|
|
|
|
use_omit_leaf_fp)
|
|
|
|
|
|
|
|
if (use_omit_leaf_fp)
|
|
|
|
add_compile_options(-fno-omit-frame-pointer -momit-leaf-frame-pointer)
|
|
|
|
endif()
|
|
|
|
|
2017-11-01 13:52:02 +00:00
|
|
|
option(gperftools_dynamic_sized_delete_support
|
|
|
|
"Try to build run-time switch for sized delete operator"
|
|
|
|
OFF)
|
|
|
|
if(gperftools_dynamic_sized_delete_support)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(ENABLE_DYNAMIC_SIZED_DELETE 1)
|
2017-11-01 13:52:02 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(gperftools_sized_delete "Build sized delete operator" OFF)
|
|
|
|
if(gperftools_sized_delete)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(ENABLE_SIZED_DELETE 1)
|
2017-11-01 13:52:02 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(NOT MSVC)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -fsized-deallocation)
|
|
|
|
check_cxx_source_compiles("
|
2017-11-05 17:23:42 +00:00
|
|
|
#include <new>
|
|
|
|
int main() { (::operator delete)(0, 256); return 0; }"
|
2020-09-11 18:43:56 +00:00
|
|
|
have_sized_deallocation)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS)
|
|
|
|
endif()
|
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <unwind.h>
|
|
|
|
int main()
|
|
|
|
{
|
2023-06-27 00:33:30 +00:00
|
|
|
#if __APPLE__ || __FreeBSD__
|
2021-03-01 01:52:17 +00:00
|
|
|
#error OSX _Unwind_Backtrace recurses back to malloc
|
|
|
|
#endif
|
2017-11-05 17:23:42 +00:00
|
|
|
&_Unwind_Backtrace;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE_UNWIND_BACKTRACE)
|
2017-11-01 13:52:02 +00:00
|
|
|
|
|
|
|
if(enable_backtrace)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_emergency_malloc ON)
|
2017-11-01 13:52:02 +00:00
|
|
|
else()
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_emergency_malloc OFF)
|
2017-11-01 13:52:02 +00:00
|
|
|
endif()
|
|
|
|
|
2017-11-03 13:10:27 +00:00
|
|
|
if(will_use_libunwind AND ARM)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(default_emergency_malloc ON)
|
2017-11-01 13:52:02 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(gperftools_emergency_malloc
|
|
|
|
"Build emergency malloc"
|
|
|
|
${default_emergency_malloc})
|
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
check_c_source_compiles(
|
|
|
|
"int main() { return __builtin_expect(main != 0, 1); }"
|
|
|
|
HAVE_BUILTIN_EXPECT)
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <unistd.h>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
char** env = __environ;
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
HAVE___ENVIRON)
|
|
|
|
|
2017-11-03 13:10:27 +00:00
|
|
|
if(enable_backtrace)
|
2017-11-05 17:23:42 +00:00
|
|
|
check_symbol_exists("backtrace" "execinfo.h" HAVE_DECL_BACKTRACE)
|
|
|
|
check_function_exists("backtrace" backtrace_exists)
|
|
|
|
if(NOT backtrace_exists)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES execinfo)
|
2017-11-03 13:10:27 +00:00
|
|
|
check_function_exists("backtrace" backtrace_exists)
|
2017-11-05 17:23:42 +00:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
if(backtrace_exists)
|
|
|
|
list(INSERT unwind_libs 0 execinfo)
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
2024-02-26 21:40:11 +00:00
|
|
|
link_libraries(Threads::Threads)
|
2017-11-03 13:10:27 +00:00
|
|
|
|
2017-11-03 00:07:29 +00:00
|
|
|
check_variable_exists("program_invocation_name" HAVE_PROGRAM_INVOCATION_NAME)
|
|
|
|
|
|
|
|
if(MINGW)
|
2017-11-05 17:23:42 +00:00
|
|
|
check_symbol_exists("sleep" "unistd.h" HAVE_DECL_SLEEP)
|
|
|
|
check_symbol_exists("nanosleep" "time.h" HAVE_DECL_NANOSLEEP)
|
2017-11-03 00:07:29 +00:00
|
|
|
endif()
|
2017-11-03 13:10:27 +00:00
|
|
|
|
|
|
|
if(LINUX)
|
2017-11-05 17:23:42 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
|
|
|
int main() { return SIGEV_THREAD_ID || CLOCK_THREAD_CPUTIME_ID; }"
|
|
|
|
HAVE_LINUX_SIGEV_THREAD_ID)
|
2017-11-03 13:10:27 +00:00
|
|
|
endif()
|
|
|
|
|
2023-12-25 01:04:33 +00:00
|
|
|
# Disable large allocation report by default.
|
|
|
|
option(gperftools_enable_large_alloc_report
|
|
|
|
"Report very large allocations to stderr"
|
|
|
|
OFF)
|
|
|
|
set(ENABLE_LARGE_ALLOC_REPORT ${gperftools_enable_large_alloc_report})
|
|
|
|
|
2023-12-25 01:10:00 +00:00
|
|
|
# Enable aggressive decommit by default
|
|
|
|
option(gperftools_enable_aggressive_decommit_by_default
|
|
|
|
"Enable aggressive decommit by default"
|
|
|
|
OFF)
|
|
|
|
set(ENABLE_AGGRESSIVE_DECOMMIT_BY_DEFAULT ${gperftools_enable_aggressive_decommit_by_default})
|
|
|
|
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
configure_file(cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
|
2017-11-05 17:23:42 +00:00
|
|
|
configure_file(cmake/tcmalloc.h.in
|
2020-09-11 18:43:56 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/gperftools/tcmalloc.h
|
2017-11-05 17:23:42 +00:00
|
|
|
@ONLY)
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(GPERFTOOLS_BUILD_CPU_PROFILER OR
|
|
|
|
GPERFTOOLS_BUILD_HEAP_PROFILER OR
|
|
|
|
GPERFTOOLS_BUILD_HEAP_CHECKER)
|
|
|
|
set(WITH_STACK_TRACE ON)
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Based on Makefile.am
|
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2020-09-11 18:43:56 +00:00
|
|
|
# This is so we can #include <gperftools/foo>
|
|
|
|
include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
|
2017-11-05 17:23:42 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(NOT WITH_STACK_TRACE)
|
|
|
|
add_compile_definitions(NO_TCMALLOC_SAMPLES)
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
# These are good warnings to turn on by default.
|
2017-11-05 17:23:42 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2020-09-11 18:43:56 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare")
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(have_sized_deallocation)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsized-deallocation")
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
2021-02-06 21:21:12 +00:00
|
|
|
option(
|
|
|
|
gperftools_enable_frame_pointers
|
|
|
|
"Compile with -fno-omit-frame-pointer (see INSTALL)"
|
|
|
|
OFF)
|
|
|
|
|
|
|
|
if(gperftools_enable_frame_pointers)
|
2023-07-02 23:35:46 +00:00
|
|
|
add_compile_options(-fno-omit-frame-pointer -DFORCED_FRAME_POINTERS)
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
# On windows when building static library, due to patching, we need to
|
|
|
|
# force "core" of tcmalloc to be linked in to activate patching etc. We
|
|
|
|
# achieve that by telling linker to assume __tcmalloc is not defined.
|
2020-09-11 18:43:56 +00:00
|
|
|
set(TCMALLOC_FLAGS)
|
|
|
|
if(MINGW)
|
|
|
|
list(APPEND TCMALLOC_FLAGS "-Wl,-u__tcmalloc")
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
2024-02-26 21:40:11 +00:00
|
|
|
if(MSVC)
|
|
|
|
list(APPEND TCMALLOC_FLAGS "/INCLUDE:__tcmalloc")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(common
|
|
|
|
STATIC
|
|
|
|
src/base/logging.cc
|
|
|
|
src/base/generic_writer.cc
|
|
|
|
src/base/sysinfo.cc
|
|
|
|
src/base/proc_maps_iterator.cc
|
|
|
|
src/base/dynamic_annotations.cc
|
|
|
|
src/base/spinlock.cc
|
|
|
|
src/base/spinlock_internal.cc)
|
|
|
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set_property(TARGET common
|
|
|
|
PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
|
|
else()
|
|
|
|
# windows needs this. Doesn't hurt others.
|
|
|
|
#
|
|
|
|
# TODO: make sure we do something with headers. If/when someone uses
|
|
|
|
# statically built tcmalloc_minimal.lib downstream, they need to see
|
|
|
|
# PERFTOOLS_DLL_DECL set to nothing as well.
|
|
|
|
add_compile_definitions(PERFTOOLS_DLL_DECL= )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SYSTEM_ALLOC_CC src/system-alloc.cc)
|
|
|
|
set(TCMALLOC_CC src/tcmalloc.cc)
|
2017-11-05 17:23:42 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(MINGW OR MSVC)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_sources(common PRIVATE
|
|
|
|
src/windows/port.cc
|
|
|
|
src/windows/ia32_modrm_map.cc
|
|
|
|
src/windows/ia32_opcode_map.cc
|
|
|
|
src/windows/mini_disassembler.cc
|
|
|
|
src/windows/preamble_patcher.cc
|
|
|
|
src/windows/preamble_patcher_with_stub.cc)
|
2024-01-29 02:40:39 +00:00
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
set(SYSTEM_ALLOC_CC src/windows/system-alloc.cc)
|
|
|
|
set(TCMALLOC_CC src/windows/patch_functions.cc)
|
|
|
|
|
|
|
|
# patch_function uses -lpsapi and spinlock bits use -synchronization
|
|
|
|
# and -lshlwapi
|
|
|
|
link_libraries(psapi synchronization shlwapi)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_library(gtest STATIC vendor/googletest/googletest/src/gtest_main.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-assertion-result.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-death-test.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-filepath.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-matchers.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-port.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-printers.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-test-part.cc
|
|
|
|
vendor/googletest/googletest/src/gtest-typed-test.cc
|
|
|
|
vendor/googletest/googletest/src/gtest.cc)
|
|
|
|
target_include_directories(gtest PRIVATE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/googletest/googletest>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/googletest/googletest/include>)
|
|
|
|
|
|
|
|
target_include_directories(gtest INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/googletest/googletest/include>)
|
|
|
|
|
|
|
|
add_executable(low_level_alloc_unittest src/base/low_level_alloc.cc
|
2020-09-11 18:43:56 +00:00
|
|
|
src/malloc_hook.cc
|
2023-07-21 18:18:12 +00:00
|
|
|
src/mmap_hook.cc
|
2024-02-26 21:40:11 +00:00
|
|
|
src/tests/low_level_alloc_unittest.cc)
|
|
|
|
target_compile_definitions(low_level_alloc_unittest PRIVATE NO_TCMALLOC_SAMPLES PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(low_level_alloc_unittest common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(low_level_alloc_unittest low_level_alloc_unittest)
|
2017-11-05 17:23:42 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
### ------- stack trace
|
|
|
|
|
|
|
|
if(WITH_STACK_TRACE)
|
|
|
|
### Making the library
|
2024-02-26 21:40:11 +00:00
|
|
|
add_library(stacktrace STATIC
|
|
|
|
src/stacktrace.cc
|
|
|
|
src/base/elf_mem_image.cc
|
|
|
|
src/base/vdso_support.cc)
|
|
|
|
target_link_libraries(stacktrace PRIVATE ${unwind_libs})
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set_property(TARGET stacktrace
|
|
|
|
PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
2020-09-11 18:43:56 +00:00
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(stacktrace_unittest
|
|
|
|
src/tests/stacktrace_unittest.cc
|
|
|
|
src/stacktrace.cc
|
|
|
|
src/base/elf_mem_image.cc
|
|
|
|
src/base/vdso_support.cc)
|
|
|
|
target_link_libraries(stacktrace_unittest ${unwind_libs} common gtest)
|
|
|
|
target_compile_definitions(stacktrace_unittest PRIVATE STACKTRACE_IS_TESTED PERFTOOLS_DLL_DECL= )
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(stacktrace_unittest stacktrace_unittest)
|
2023-09-08 23:47:17 +00:00
|
|
|
|
2024-02-18 02:21:13 +00:00
|
|
|
add_executable(check_address_test src/tests/check_address_test.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(check_address_test common gtest)
|
2024-02-18 02:21:13 +00:00
|
|
|
add_test(check_address_test check_address_test)
|
2017-11-08 02:25:34 +00:00
|
|
|
endif()
|
2020-09-11 18:43:56 +00:00
|
|
|
|
2017-11-08 02:25:34 +00:00
|
|
|
endif()
|
2017-11-07 18:26:10 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
### ------- tcmalloc_minimal (thread-caching malloc)
|
|
|
|
|
|
|
|
### Making the library
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
set(MINIMAL_MALLOC_SRC
|
|
|
|
src/common.cc
|
|
|
|
src/internal_logging.cc
|
|
|
|
${SYSTEM_ALLOC_CC}
|
|
|
|
src/memfs_malloc.cc
|
|
|
|
src/safe_strerror.cc
|
|
|
|
src/central_freelist.cc
|
|
|
|
src/page_heap.cc
|
|
|
|
src/sampler.cc
|
|
|
|
src/span.cc
|
|
|
|
src/stack_trace_table.cc
|
|
|
|
src/static_vars.cc
|
|
|
|
src/symbolize.cc
|
|
|
|
src/thread_cache.cc
|
|
|
|
src/thread_cache_ptr.cc
|
|
|
|
src/malloc_hook.cc
|
|
|
|
src/malloc_extension.cc)
|
|
|
|
|
|
|
|
add_library(tcmalloc_minimal ${TCMALLOC_CC} ${MINIMAL_MALLOC_SRC})
|
|
|
|
target_compile_definitions(tcmalloc_minimal PRIVATE NO_TCMALLOC_SAMPLES NO_HEAP_CHECK)
|
|
|
|
target_link_options(tcmalloc_minimal INTERFACE ${TCMALLOC_FLAGS})
|
|
|
|
target_link_libraries(tcmalloc_minimal PRIVATE common)
|
2017-11-08 12:24:08 +00:00
|
|
|
|
2017-11-05 17:23:42 +00:00
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(tcmalloc_minimal_unittest
|
|
|
|
src/tests/tcmalloc_unittest.cc
|
|
|
|
src/tests/testutil.cc)
|
2024-03-11 16:50:25 +00:00
|
|
|
target_link_libraries(tcmalloc_minimal_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_minimal_unittest tcmalloc_minimal_unittest)
|
|
|
|
|
2017-11-05 17:53:07 +00:00
|
|
|
add_executable(tcmalloc_minimal_large_unittest
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/tcmalloc_large_unittest.cc
|
2024-02-26 21:40:11 +00:00
|
|
|
src/tests/testutil.cc)
|
|
|
|
target_link_libraries(tcmalloc_minimal_large_unittest tcmalloc_minimal)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_minimal_large_unittest tcmalloc_minimal_large_unittest)
|
2017-11-05 17:53:07 +00:00
|
|
|
|
|
|
|
add_executable(tcmalloc_minimal_large_heap_fragmentation_unittest
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/large_heap_fragmentation_unittest.cc)
|
2017-11-05 17:53:07 +00:00
|
|
|
target_link_libraries(
|
2024-03-20 04:27:10 +00:00
|
|
|
tcmalloc_minimal_large_heap_fragmentation_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_minimal_large_heap_fragmentation_unittest tcmalloc_minimal_large_heap_fragmentation_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(addressmap_unittest
|
2024-02-26 21:40:11 +00:00
|
|
|
src/tests/addressmap_unittest.cc)
|
|
|
|
target_link_libraries(addressmap_unittest common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(addressmap_unittest addressmap_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
2024-03-17 19:35:09 +00:00
|
|
|
add_executable(system_alloc_unittest src/tests/system-alloc_unittest.cc)
|
|
|
|
target_link_libraries(system_alloc_unittest tcmalloc_minimal gtest)
|
|
|
|
add_test(system_alloc_unittest system_alloc_unittest)
|
2023-08-09 17:18:59 +00:00
|
|
|
|
2024-03-17 19:35:09 +00:00
|
|
|
if(NOT MINGW AND NOT MSVC)
|
2023-08-09 17:18:59 +00:00
|
|
|
add_executable(unique_path_unittest src/tests/unique_path_unittest.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(unique_path_unittest common gtest)
|
2023-08-09 17:18:59 +00:00
|
|
|
add_test(unique_path_unittest unique_path_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
endif()
|
|
|
|
|
2024-02-25 23:09:28 +00:00
|
|
|
add_executable(packed_cache_test src/tests/packed-cache_test.cc src/internal_logging.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_compile_definitions(packed_cache_test PRIVATE PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(packed_cache_test common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(packed_cache_test packed_cache_test)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(frag_unittest src/tests/frag_unittest.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(frag_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(frag_unittest frag_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(markidle_unittest
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/markidle_unittest.cc
|
|
|
|
src/tests/testutil.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(markidle_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(markidle_unittest markidle_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(current_allocated_bytes_test
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/current_allocated_bytes_test.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(current_allocated_bytes_test tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(current_allocated_bytes_test current_allocated_bytes_test)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(malloc_hook_test
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/malloc_hook_test.cc
|
2024-02-26 21:40:11 +00:00
|
|
|
src/malloc_hook.cc
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/testutil.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_compile_definitions(malloc_hook_test PRIVATE NO_TCMALLOC_SAMPLES PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(malloc_hook_test common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(malloc_hook_test malloc_hook_test)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
if(NOT MINGW AND NOT MSVC)
|
|
|
|
add_executable(mmap_hook_test
|
|
|
|
src/tests/mmap_hook_test.cc
|
|
|
|
src/mmap_hook.cc)
|
|
|
|
target_link_libraries(mmap_hook_test common gtest)
|
|
|
|
add_test(mmap_hook_test mmap_hook_test)
|
2023-09-19 06:47:46 +00:00
|
|
|
endif()
|
2024-02-26 21:40:11 +00:00
|
|
|
|
|
|
|
add_executable(malloc_extension_test src/tests/malloc_extension_test.cc)
|
|
|
|
target_link_libraries(malloc_extension_test tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(malloc_extension_test malloc_extension_test)
|
|
|
|
|
2024-03-17 16:39:57 +00:00
|
|
|
add_executable(malloc_extension_c_test src/tests/malloc_extension_c_test.cc)
|
|
|
|
target_link_libraries(malloc_extension_c_test tcmalloc_minimal gtest)
|
|
|
|
add_test(malloc_extension_c_test malloc_extension_c_test)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(NOT MINGW AND NOT MSVC AND NOT APPLE)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(memalign_unittest src/tests/memalign_unittest.cc src/tests/testutil.cc)
|
|
|
|
target_link_libraries(memalign_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(memalign_unittest memalign_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
endif()
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
# page heap test is somewhat special it compiles and links entirety
|
|
|
|
# of tcmalloc statically. We'll eventually make it right.
|
|
|
|
add_executable(page_heap_test src/tests/page_heap_test.cc ${TCMALLOC_CC} ${MINIMAL_MALLOC_SRC})
|
|
|
|
target_compile_definitions(page_heap_test PRIVATE NO_HEAP_CHECK NO_TCMALLOC_SAMPLES PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(page_heap_test common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(page_heap_test page_heap_test)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
2024-02-18 02:17:37 +00:00
|
|
|
add_executable(pagemap_unittest src/tests/pagemap_unittest.cc src/internal_logging.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_compile_definitions(pagemap_unittest PRIVATE PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(pagemap_unittest common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(pagemap_unittest pagemap_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
2023-07-03 21:36:47 +00:00
|
|
|
add_executable(safe_strerror_test src/tests/safe_strerror_test.cc src/safe_strerror.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(safe_strerror_test common gtest)
|
2023-07-03 21:36:47 +00:00
|
|
|
add_test(safe_strerror_test safe_strerror_test)
|
|
|
|
|
2024-02-21 22:53:45 +00:00
|
|
|
add_executable(cleanup_test src/tests/cleanup_test.cc)
|
|
|
|
target_link_libraries(cleanup_test gtest)
|
|
|
|
add_test(cleanup_test cleanup_test)
|
|
|
|
|
2024-02-22 02:56:45 +00:00
|
|
|
add_executable(function_ref_test src/tests/function_ref_test.cc)
|
|
|
|
target_link_libraries(function_ref_test gtest)
|
|
|
|
add_test(function_ref_test function_ref_test)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(generic_writer_test src/tests/generic_writer_test.cc)
|
|
|
|
target_link_libraries(generic_writer_test common gtest)
|
2024-01-23 21:53:17 +00:00
|
|
|
add_test(generic_writer_test generic_writer_test)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(proc_maps_iterator_test src/tests/proc_maps_iterator_test.cc)
|
|
|
|
target_link_libraries(proc_maps_iterator_test common gtest)
|
2024-01-28 00:05:38 +00:00
|
|
|
add_test(proc_maps_iterator_test proc_maps_iterator_test)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(realloc_unittest src/tests/realloc_unittest.cc)
|
2024-03-17 17:38:14 +00:00
|
|
|
target_link_libraries(realloc_unittest tcmalloc_minimal gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(realloc_unittest realloc_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(stack_trace_table_test
|
|
|
|
src/tests/stack_trace_table_test.cc
|
|
|
|
src/stack_trace_table.cc
|
|
|
|
src/internal_logging.cc)
|
|
|
|
target_compile_definitions(stack_trace_table_test PRIVATE STACK_TRACE_TABLE_IS_TESTED PERFTOOLS_DLL_DECL= )
|
|
|
|
target_link_libraries(stack_trace_table_test common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(stack_trace_table_test stack_trace_table_test)
|
2017-11-05 21:53:28 +00:00
|
|
|
|
|
|
|
add_executable(thread_dealloc_unittest
|
2020-09-11 18:43:56 +00:00
|
|
|
src/tests/thread_dealloc_unittest.cc
|
|
|
|
src/tests/testutil.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(thread_dealloc_unittest tcmalloc_minimal)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(thread_dealloc_unittest thread_dealloc_unittest)
|
2017-11-05 21:53:28 +00:00
|
|
|
endif()
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
### ------- tcmalloc_minimal_debug (thread-caching malloc with debugallocation)
|
|
|
|
|
|
|
|
if(GPERFTOOLS_BUILD_DEBUGALLOC)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_library(tcmalloc_minimal_debug src/debugallocation.cc ${MINIMAL_MALLOC_SRC})
|
|
|
|
target_compile_definitions(tcmalloc_minimal_debug PRIVATE NO_TCMALLOC_SAMPLES NO_HEAP_CHECK)
|
|
|
|
target_link_libraries(tcmalloc_minimal_debug PRIVATE common)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
### Unittests
|
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(tcmalloc_minimal_debug_unittest src/tests/tcmalloc_unittest.cc src/tests/testutil.cc)
|
2024-03-11 16:50:25 +00:00
|
|
|
target_link_libraries(tcmalloc_minimal_debug_unittest tcmalloc_minimal_debug gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_minimal_debug_unittest tcmalloc_minimal_debug_unittest)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(malloc_extension_debug_test src/tests/malloc_extension_test.cc)
|
2024-03-17 16:32:53 +00:00
|
|
|
target_link_libraries(malloc_extension_debug_test tcmalloc_minimal_debug gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(malloc_extension_debug_test malloc_extension_debug_test)
|
|
|
|
|
|
|
|
if(NOT MINGW AND NOT APPLE)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(memalign_debug_unittest src/tests/memalign_unittest.cc src/tests/testutil.cc)
|
2020-09-11 18:43:56 +00:00
|
|
|
target_link_libraries(memalign_debug_unittest
|
2024-02-25 22:52:51 +00:00
|
|
|
tcmalloc_minimal_debug gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(memalign_debug_unittest memalign_debug_unittest)
|
|
|
|
endif()
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(realloc_debug_unittest src/tests/realloc_unittest.cc)
|
2024-03-17 17:38:14 +00:00
|
|
|
target_link_libraries(realloc_debug_unittest PUBLIC tcmalloc_minimal_debug gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(realloc_debug_unittest realloc_debug_unittest)
|
|
|
|
|
|
|
|
if(WITH_STACK_TRACE)
|
|
|
|
add_executable(debugallocation_test src/tests/debugallocation_test.cc)
|
2024-03-14 16:39:19 +00:00
|
|
|
target_link_libraries(debugallocation_test tcmalloc_debug gtest)
|
|
|
|
add_test(debugallocation_test debugallocation_test)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT MINGW AND NOT MSVC)
|
|
|
|
if(gperftools_build_benchmark)
|
2023-06-26 18:28:02 +00:00
|
|
|
add_library(run_benchmark benchmark/run_benchmark.cc)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
add_executable(malloc_bench benchmark/malloc_bench.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(malloc_bench tcmalloc_minimal run_benchmark)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
|
|
|
|
add_executable(malloc_bench_shared_full benchmark/malloc_bench.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(malloc_bench_shared_full run_benchmark tcmalloc)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(binary_trees benchmark/binary_trees.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(binary_trees tcmalloc_minimal)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_executable(binary_trees_shared benchmark/binary_trees.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(binary_trees_shared tcmalloc_minimal)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### ------- tcmalloc (thread-caching malloc + heap profiler + heap checker)
|
|
|
|
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
|
|
|
|
if(gperftools_emergency_malloc)
|
2024-02-26 21:40:11 +00:00
|
|
|
set(EMERGENCY_MALLOC_CC src/emergency_malloc.cc)
|
2020-09-11 18:43:56 +00:00
|
|
|
set(EMERGENCY_MALLOC_DEFINE ENABLE_EMERGENCY_MALLOC)
|
|
|
|
else()
|
2024-02-05 15:30:22 +00:00
|
|
|
set(EMERGENCY_MALLOC_CC )
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
### Making the library
|
|
|
|
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER)
|
2024-02-26 21:40:11 +00:00
|
|
|
set(HEAP_CHECKER_SRC src/base/linuxthreads.cc
|
2024-04-06 19:05:57 +00:00
|
|
|
src/heap-checker.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
set(HEAP_CHECKER_DEFINE )
|
2020-09-11 18:43:56 +00:00
|
|
|
else()
|
2024-02-26 21:40:11 +00:00
|
|
|
set(HEAP_CHECKER_SRC )
|
|
|
|
set(HEAP_CHECKER_DEFINE NO_HEAP_CHECK)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
set(FULL_MALLOC_SRC
|
|
|
|
${HEAP_CHECKER_SRC}
|
|
|
|
${MINIMAL_MALLOC_SRC}
|
|
|
|
src/base/low_level_alloc.cc
|
|
|
|
src/heap-profile-table.cc
|
|
|
|
src/heap-profiler.cc
|
|
|
|
${EMERGENCY_MALLOC_CC}
|
2024-04-26 20:50:04 +00:00
|
|
|
src/malloc_backtrace.cc
|
2024-02-26 21:40:11 +00:00
|
|
|
src/mmap_hook.cc
|
|
|
|
src/memory_region_map.cc)
|
|
|
|
add_library(tcmalloc ${TCMALLOC_CC} ${FULL_MALLOC_SRC})
|
|
|
|
target_compile_definitions(tcmalloc PRIVATE ${HEAP_CHECKER_DEFINE} ${EMERGENCY_MALLOC_DEFINE})
|
|
|
|
target_link_libraries(tcmalloc PRIVATE stacktrace common)
|
|
|
|
target_link_options(tcmalloc INTERFACE ${TCMALLOC_FLAGS})
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
### Unittests
|
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(tcmalloc_unittest src/tests/tcmalloc_unittest.cc src/tests/testutil.cc)
|
2024-03-11 16:50:25 +00:00
|
|
|
target_link_libraries(tcmalloc_unittest tcmalloc gtest)
|
|
|
|
add_test(tcmalloc_unittest tcmalloc_unittest)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
add_executable(tcmalloc_large_unittest src/tests/tcmalloc_large_unittest.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(tcmalloc_large_unittest tcmalloc)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_large_unittest tcmalloc_large_unittest)
|
|
|
|
|
|
|
|
add_executable(tcmalloc_large_heap_fragmentation_unittest src/tests/large_heap_fragmentation_unittest.cc)
|
2024-03-20 04:27:10 +00:00
|
|
|
target_link_libraries(tcmalloc_large_heap_fragmentation_unittest tcmalloc gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_large_heap_fragmentation_unittest tcmalloc_large_heap_fragmentation_unittest)
|
|
|
|
|
2024-03-14 16:39:19 +00:00
|
|
|
list(APPEND TESTS_ENVIRONMENT PPROF_PATH=${CMAKE_CURRENT_SOURCE_DIR}/src/pprof)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
2024-02-18 02:22:11 +00:00
|
|
|
add_executable(sampler_test src/tests/sampler_test.cc src/sampler.cc)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(sampler_test gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(sampler_test sampler_test)
|
|
|
|
|
|
|
|
# These unittests often need to run binaries. They're in the current dir
|
|
|
|
list(APPEND TESTS_ENVIRONMENT BINDIR=. TMPDIR=/tmp/perftools)
|
2024-02-26 21:40:11 +00:00
|
|
|
set(sampling_test_SOURCES src/tests/sampling_test.cc)
|
|
|
|
add_executable(sampling_test src/tests/sampling_test.cc)
|
2024-03-17 19:09:01 +00:00
|
|
|
target_compile_definitions(sampling_test PRIVATE PPROF_PATH=${CMAKE_CURRENT_SOURCE_DIR}/src/pprof)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(sampling_test tcmalloc)
|
2024-03-17 19:09:01 +00:00
|
|
|
add_test(sampling_test sampling_test)
|
2024-02-26 21:40:11 +00:00
|
|
|
|
2020-09-11 18:43:56 +00:00
|
|
|
if(GPERFTOOLS_BUILD_HEAP_PROFILER)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(heap_profiler_unittest src/tests/heap-profiler_unittest.cc)
|
|
|
|
target_link_libraries(heap_profiler_unittest tcmalloc)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(NAME heap-profiler_unittest.sh
|
|
|
|
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/heap-profiler_unittest.sh" heap-profiler_unittest)
|
|
|
|
endif()
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(heap_checker_unittest src/tests/heap-checker_unittest.cc)
|
|
|
|
target_link_libraries(heap_checker_unittest tcmalloc common)
|
2023-06-21 14:39:35 +00:00
|
|
|
add_test(heap-checker_unittest heap_checker_unittest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(NAME heap-checker-death_unittest.sh
|
|
|
|
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/heap-checker-death_unittest.sh")
|
2024-02-26 21:40:11 +00:00
|
|
|
endif()
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### ------- tcmalloc with debugallocation
|
|
|
|
if(GPERFTOOLS_BUILD_DEBUGALLOC)
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_library(tcmalloc_debug src/debugallocation.cc ${FULL_MALLOC_SRC})
|
|
|
|
target_compile_definitions(tcmalloc_debug PRIVATE ${HEAP_CHECKER_DEFINE} ${EMERGENCY_MALLOC_DEFINE})
|
|
|
|
target_link_libraries(tcmalloc_debug PRIVATE stacktrace common)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
### Unittests
|
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(tcmalloc_debug_unittest src/tests/tcmalloc_unittest.cc src/tests/testutil.cc)
|
2024-03-11 16:50:25 +00:00
|
|
|
target_link_libraries(tcmalloc_debug_unittest tcmalloc_debug gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(tcmalloc_debug_unittest tcmalloc_debug_unittest)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(sampling_debug_test src/tests/sampling_test.cc)
|
2024-03-17 19:09:01 +00:00
|
|
|
target_compile_definitions(sampling_debug_test PRIVATE PPROF_PATH=${CMAKE_CURRENT_SOURCE_DIR}/src/pprof)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(sampling_debug_test tcmalloc_debug)
|
2024-03-17 19:09:01 +00:00
|
|
|
add_test(sampling_debug_test sampling_debug_test)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_PROFILER)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(heap_profiler_debug_unittest src/tests/heap-profiler_unittest.cc)
|
|
|
|
target_link_libraries(heap_profiler_debug_unittest tcmalloc_debug)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(heap-profiler_debug_unittest.sh "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/heap-profiler_unittest.sh" heap-profiler_debug_unittest)
|
|
|
|
endif()
|
|
|
|
if(GPERFTOOLS_BUILD_HEAP_CHECKER)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(heap_checker_debug_unittest src/tests/heap-checker_unittest.cc)
|
|
|
|
target_link_libraries(heap_checker_debug_unittest tcmalloc_debug common)
|
2023-06-21 14:39:35 +00:00
|
|
|
add_test(heap_checker_debug_unittest heap_checker_debug_unittest)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### ------- CPU profiler
|
|
|
|
if(GPERFTOOLS_BUILD_CPU_PROFILER)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_library(profiler
|
|
|
|
src/profiler.cc
|
|
|
|
src/profile-handler.cc
|
|
|
|
src/profiledata.cc)
|
|
|
|
target_link_libraries(profiler PRIVATE stacktrace common)
|
2020-09-11 18:43:56 +00:00
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(getpc_test src/tests/getpc_test.cc)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(getpc_test getpc_test)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(profiledata_unittest
|
|
|
|
src/tests/profiledata_unittest.cc src/profiledata.cc)
|
|
|
|
target_link_libraries(profiledata_unittest stacktrace common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(profiledata_unittest profiledata_unittest)
|
|
|
|
|
2024-02-26 21:40:11 +00:00
|
|
|
add_executable(profile_handler_unittest
|
|
|
|
src/tests/profile-handler_unittest.cc src/profile-handler.cc)
|
|
|
|
target_link_libraries(profile_handler_unittest stacktrace common gtest)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_test(profile_handler_unittest profile_handler_unittest)
|
|
|
|
|
|
|
|
add_test(NAME profiler_unittest.sh
|
|
|
|
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/profiler_unittest.sh")
|
|
|
|
set(PROFILER_UNITTEST_SRCS src/tests/profiler_unittest.cc
|
2024-02-26 21:40:11 +00:00
|
|
|
src/tests/testutil.h src/tests/testutil.cc)
|
|
|
|
# TODO: get rid of the {1,2,3,4} multiplicity
|
2020-09-11 18:43:56 +00:00
|
|
|
add_executable(profiler1_unittest ${PROFILER_UNITTEST_SRCS})
|
|
|
|
target_compile_definitions(profiler1_unittest PRIVATE NO_THREADS)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(profiler1_unittest PRIVATE profiler)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_executable(profiler2_unittest ${PROFILER_UNITTEST_SRCS})
|
|
|
|
target_compile_definitions(profiler2_unittest PRIVATE NO_THREADS)
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(profiler2_unittest PRIVATE profiler)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_executable(profiler3_unittest ${PROFILER_UNITTEST_SRCS})
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(profiler3_unittest PRIVATE profiler)
|
2020-09-11 18:43:56 +00:00
|
|
|
add_executable(profiler4_unittest ${PROFILER_UNITTEST_SRCS})
|
2024-02-26 21:40:11 +00:00
|
|
|
target_link_libraries(profiler4_unittest PRIVATE stacktrace profiler)
|
2020-09-11 18:43:56 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_TESTING)
|
|
|
|
get_directory_property(tests TESTS)
|
|
|
|
message("TESTS_ENVIRONMENT:${TESTS_ENVIRONMENT}")
|
|
|
|
if(TESTS_ENVIRONMENT)
|
|
|
|
foreach(test IN LISTS tests)
|
|
|
|
set_tests_properties(${test} PROPERTIES ENVIRONMENT "${TESTS_ENVIRONMENT}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_subdirectory(src/windows)
|
|
|
|
endif()
|
|
|
|
|
2023-10-24 20:21:15 +00:00
|
|
|
message(WARNING "note: gperftools' cmake support is incomplete and is best-effort only")
|