Add USDT sample (#1229)
[platform/upstream/bcc.git] / examples / usdt_sample / usdt_sample_lib1 / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.0)
2 project(usdt_sample_lib1)
3
4 # Define variables.
5 set(USDT_SAMPLE_LIB1_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE STRING "USDT_SAMPLE_LIB1_INCLUDE_DIR" FORCE)
6 set(USDT_SAMPLE_LIB1_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src CACHE STRING "USDT_SAMPLE_LIB1_SRC_DIR" FORCE)
7 set(USDT_SAMPLE_LIB1_LINK_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "USDT_SAMPLE_LIB1_LINK_DIR" FORCE)
8 set(USDT_SAMPLE_LIB1_LIB ${PROJECT_NAME} CACHE STRING "USDT_SAMPLE_LIB1_LIB" FORCE)
9 set(USDT_SAMPLE_LIB1_GENERATED ${CMAKE_CURRENT_BINARY_DIR}/generated)
10
11 ## Start - N.B. Following section only relevant when using systemtap-sdt-devel.
12
13 # Create usdt header file.
14 # N.B. ${USDT_SAMPLE_LIB1_INCLUDE_DIR}/usdt_sample_lib1/lib1_sdt.h must be removed manually in order for it to be (re-)created.
15 #  i.e. after making changes to libt_sdt.d
16 #add_custom_command(
17 #    OUTPUT ${USDT_SAMPLE_LIB1_INCLUDE_DIR}/usdt_sample_lib1/lib1_sdt.h
18 #    PRE_BUILD
19 #    COMMAND dtrace -h -s ${USDT_SAMPLE_LIB1_SRC_DIR}/lib1_sdt.d -o ${USDT_SAMPLE_LIB1_INCLUDE_DIR}/usdt_sample_lib1/lib1_sdt.h
20 #    COMMENT "Create usdt probes header file"
21 #)
22
23 # Create usdt object file.
24 #file(MAKE_DIRECTORY ${USDT_SAMPLE_LIB1_GENERATED})
25 #add_custom_command(
26 #    OUTPUT ${USDT_SAMPLE_LIB1_GENERATED}/lib1_sdt.o
27 #    PRE_BUILD
28 #    COMMAND dtrace -G -s ${USDT_SAMPLE_LIB1_SRC_DIR}/lib1_sdt.d -o ${USDT_SAMPLE_LIB1_GENERATED}/lib1_sdt.o
29 #    COMMENT "Create usdt probes object file"
30 #)
31
32 ## End
33
34 include_directories(
35     ${USDT_SAMPLE_LIB1_INCLUDE_DIR}
36     # For folly StaticTracepoint.h:
37     ${CMAKE_CURRENT_SOURCE_DIR}/../../../tests/python/include
38 )
39
40 add_library( ${PROJECT_NAME} SHARED
41 ## Only relevant when using systemtap-sdt-devel
42 #    ${USDT_SAMPLE_LIB1_INCLUDE_DIR}/usdt_sample_lib1/lib1_sdt.h
43 #    ${USDT_SAMPLE_LIB1_GENERATED}/lib1_sdt.o
44     ${USDT_SAMPLE_LIB1_SRC_DIR}/lib1.cpp
45 )