forked from MethanePowered/MethaneKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
102 lines (87 loc) · 2.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
set(TARGET MethaneInstrumentation)
include(MethaneModules)
get_module_dirs("Methane")
set(HEADERS
${INCLUDE_DIR}/Instrumentation.h
${INCLUDE_DIR}/IttApiHelper.h
${INCLUDE_DIR}/ScopeTimer.h
${INCLUDE_DIR}/ILogger.h
${INCLUDE_DIR}/TracyGpu.hpp
)
set(PLATFORM_SOURCES
${SOURCES_PLATFORM_DIR}/Instrumentation.${CPP_EXT}
)
set(SOURCES
${PLATFORM_SOURCES}
${SOURCES_DIR}/Instrumentation.cpp
${SOURCES_DIR}/ScopeTimer.cpp
$<$<BOOL:${METHANE_TRACY_PROFILING_ENABLED}>:${SOURCES_DIR}/InstrumentMemoryAllocations.cpp>
)
add_library(${TARGET} STATIC
${HEADERS}
${SOURCES}
)
target_include_directories(${TARGET}
PRIVATE
Sources
PUBLIC
Include
)
target_link_libraries(${TARGET}
PUBLIC
MethanePrimitives
$<$<BOOL:${METHANE_LOGGING_ENABLED}>:MethanePlatformUtils> # Logging functions
$<$<BOOL:${METHANE_ITT_INSTRUMENTATION_ENABLED}>:ittnotify>
$<$<BOOL:${METHANE_TRACY_PROFILING_ENABLED}>:Tracy::TracyClient>
nowide
PRIVATE
MethaneBuildOptions
)
if(APPLE)
target_link_libraries(${TARGET}
PRIVATE
"-framework Foundation"
)
endif()
target_compile_definitions(${TARGET}
PUBLIC
$<$<BOOL:${METHANE_SCOPE_TIMERS_ENABLED}>:METHANE_SCOPE_TIMERS_ENABLED>
$<$<BOOL:${METHANE_LOGGING_ENABLED}>:METHANE_LOGGING_ENABLED>
# Tracy configuration
$<$<BOOL:${METHANE_TRACY_PROFILING_ON_DEMAND}>:TRACY_ON_DEMAND>
$<$<BOOL:${METHANE_TRACY_PROFILING_ENABLED}>:TRACY_ENABLE>
$<$<AND:$<BOOL:${METHANE_TRACY_PROFILING_ENABLED}>,$<BOOL:${METHANE_GPU_INSTRUMENTATION_ENABLED}>>:TRACY_GPU_ENABLE>
)
# Tracy call stacks collection: enabled on Windows only, does not work on MacOS (reasons unknown)
# - it is mostly useful for memory profiling to know where each new/delete comes from
# - zone call stacks can be collected in sampling mode when client application is started under Administrator
if (WIN32 AND METHANE_TRACY_PROFILING_ENABLED)
target_compile_definitions(${TARGET}
PUBLIC
TRACY_MEMORY_CALL_STACK_DEPTH=16 # call stacks for memory new/delete
# TRACY_ZONE_CALL_STACK_DEPTH=16 # call stacks for each zone
)
endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES})
if (APPLE)
# Disable precompiled headers on MacOS for Objective-C files:
set_source_files_properties(
${PLATFORM_SOURCES}
PROPERTIES
COMPILE_FLAGS -fobjc-arc
SKIP_PRECOMPILE_HEADERS ON
)
endif()
set_target_properties(${TARGET}
PROPERTIES
FOLDER Modules/Common
PUBLIC_HEADER "${HEADERS}"
)
install(TARGETS ${TARGET}
PUBLIC_HEADER
DESTINATION ${INCLUDE_DIR}
COMPONENT Development
ARCHIVE
DESTINATION Lib
COMPONENT Development
)