1*6dbdd20aSAndroid Build Coastguard Worker# Copyright (C) 2020 The Android Open Source Project 2*6dbdd20aSAndroid Build Coastguard Worker# 3*6dbdd20aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*6dbdd20aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*6dbdd20aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*6dbdd20aSAndroid Build Coastguard Worker# 7*6dbdd20aSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*6dbdd20aSAndroid Build Coastguard Worker# 9*6dbdd20aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*6dbdd20aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*6dbdd20aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*6dbdd20aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*6dbdd20aSAndroid Build Coastguard Worker# limitations under the License. 14*6dbdd20aSAndroid Build Coastguard Worker 15*6dbdd20aSAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.13) 16*6dbdd20aSAndroid Build Coastguard Workerproject(perfetto-sdk-example) 17*6dbdd20aSAndroid Build Coastguard Worker 18*6dbdd20aSAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD 17) 19*6dbdd20aSAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD_REQUIRED ON) 20*6dbdd20aSAndroid Build Coastguard Worker 21*6dbdd20aSAndroid Build Coastguard Workerfind_package(Threads) 22*6dbdd20aSAndroid Build Coastguard Worker 23*6dbdd20aSAndroid Build Coastguard Worker# Define a static library for Perfetto. In this example, we expect the SDK 24*6dbdd20aSAndroid Build Coastguard Worker# (perfetto.cc and perfetto.h) to live in the top level sdk/ directory. 25*6dbdd20aSAndroid Build Coastguard Workerinclude_directories(../../sdk) 26*6dbdd20aSAndroid Build Coastguard Workeradd_library(perfetto STATIC ../../sdk/perfetto.cc) 27*6dbdd20aSAndroid Build Coastguard Worker 28*6dbdd20aSAndroid Build Coastguard Worker# Link the library to the main executables. 29*6dbdd20aSAndroid Build Coastguard Workeradd_executable(example example.cc trace_categories.cc) 30*6dbdd20aSAndroid Build Coastguard Workeradd_executable(example_system_wide example_system_wide.cc 31*6dbdd20aSAndroid Build Coastguard Worker trace_categories.cc) 32*6dbdd20aSAndroid Build Coastguard Workeradd_executable(example_custom_data_source example_custom_data_source.cc) 33*6dbdd20aSAndroid Build Coastguard Workeradd_executable(example_console example_console.cc trace_categories.cc) 34*6dbdd20aSAndroid Build Coastguard Workeradd_executable(example_startup_trace example_startup_trace.cc) 35*6dbdd20aSAndroid Build Coastguard Worker 36*6dbdd20aSAndroid Build Coastguard Workertarget_link_libraries(example perfetto 37*6dbdd20aSAndroid Build Coastguard Worker ${CMAKE_THREAD_LIBS_INIT}) 38*6dbdd20aSAndroid Build Coastguard Workertarget_link_libraries(example_system_wide perfetto 39*6dbdd20aSAndroid Build Coastguard Worker ${CMAKE_THREAD_LIBS_INIT}) 40*6dbdd20aSAndroid Build Coastguard Workertarget_link_libraries(example_custom_data_source perfetto 41*6dbdd20aSAndroid Build Coastguard Worker ${CMAKE_THREAD_LIBS_INIT}) 42*6dbdd20aSAndroid Build Coastguard Workertarget_link_libraries(example_console perfetto 43*6dbdd20aSAndroid Build Coastguard Worker ${CMAKE_THREAD_LIBS_INIT}) 44*6dbdd20aSAndroid Build Coastguard Workertarget_link_libraries(example_startup_trace perfetto 45*6dbdd20aSAndroid Build Coastguard Worker ${CMAKE_THREAD_LIBS_INIT}) 46*6dbdd20aSAndroid Build Coastguard Worker 47*6dbdd20aSAndroid Build Coastguard Worker# On Android we also need the logging library. 48*6dbdd20aSAndroid Build Coastguard Workerif (ANDROID) 49*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example log) 50*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_system_wide log) 51*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_custom_data_source log) 52*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_console log) 53*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_startup_trace log) 54*6dbdd20aSAndroid Build Coastguard Workerendif (ANDROID) 55*6dbdd20aSAndroid Build Coastguard Worker 56*6dbdd20aSAndroid Build Coastguard Workerif (WIN32) 57*6dbdd20aSAndroid Build Coastguard Worker # The perfetto library contains many symbols, so it needs the big object 58*6dbdd20aSAndroid Build Coastguard Worker # format. 59*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(perfetto PRIVATE "/bigobj") 60*6dbdd20aSAndroid Build Coastguard Worker # Disable legacy features in windows.h. 61*6dbdd20aSAndroid Build Coastguard Worker add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX) 62*6dbdd20aSAndroid Build Coastguard Worker # On Windows we should link to WinSock2. 63*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example ws2_32) 64*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_system_wide ws2_32) 65*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_custom_data_source ws2_32) 66*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_console ws2_32) 67*6dbdd20aSAndroid Build Coastguard Worker target_link_libraries(example_startup_trace ws2_32) 68*6dbdd20aSAndroid Build Coastguard Workerendif (WIN32) 69*6dbdd20aSAndroid Build Coastguard Worker 70*6dbdd20aSAndroid Build Coastguard Worker# Enable standards-compliant mode when using the Visual Studio compiler. 71*6dbdd20aSAndroid Build Coastguard Workerif (MSVC) 72*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(example PRIVATE "/permissive-") 73*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(example_system_wide PRIVATE "/permissive-") 74*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(example_custom_data_source PRIVATE "/permissive-") 75*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(example_console PRIVATE "/permissive-") 76*6dbdd20aSAndroid Build Coastguard Worker target_compile_options(example_startup_trace PRIVATE "/permissive-") 77*6dbdd20aSAndroid Build Coastguard Workerendif (MSVC) 78