1# Copyright (C) 2020 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15cmake_minimum_required(VERSION 3.13) 16project(perfetto-sdk-example) 17 18set(CMAKE_CXX_STANDARD 11) 19set(CMAKE_CXX_STANDARD_REQUIRED ON) 20 21find_package(Threads) 22 23# Define a static library for Perfetto. In this example, we expect the SDK 24# (perfetto.cc and perfetto.h) to live in the top level sdk/ directory. 25include_directories(../../sdk) 26add_library(perfetto STATIC ../../sdk/perfetto.cc) 27 28# Link the library to the main executables. 29add_executable(example example.cc trace_categories.cc) 30add_executable(example_system_wide example_system_wide.cc 31 trace_categories.cc) 32add_executable(example_custom_data_source example_custom_data_source.cc) 33 34target_link_libraries(example perfetto 35 ${CMAKE_THREAD_LIBS_INIT}) 36target_link_libraries(example_system_wide perfetto 37 ${CMAKE_THREAD_LIBS_INIT}) 38target_link_libraries(example_custom_data_source perfetto 39 ${CMAKE_THREAD_LIBS_INIT}) 40 41# On Android we also need the logging library. 42if (ANDROID) 43 target_link_libraries(example log) 44 target_link_libraries(example_system_wide log) 45 target_link_libraries(example_custom_data_source log) 46endif (ANDROID)