CMakeLists.txt 1.79 KB
Newer Older
1
cmake_minimum_required(VERSION 3.4.1)
2
3
4
5
6
7
8
9
10
11
12
13

project(libxtrace)

include_directories( include )

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ")

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

find_package(Boost COMPONENTS system filesystem REQUIRED)

14
find_package(Protobuf 2 EXACT REQUIRED)
15
16
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS proto/xtrace.proto)
17
18
19
20
21
22
23
24

add_library (libxtrace SHARED 
	src/atomlayer.cpp
	src/thread_local_baggage.cpp
	src/pubsub.cpp
	src/xtrace.cpp
	src/xtrace_baggage.cpp
	src/lexvarint.cpp
25
	${PROTO_SRCS}
26
27
28
29
30
31
)
set_target_properties(libxtrace
	PROPERTIES
	OUTPUT_NAME "xtrace"
	PREFIX "lib"
)
32
target_link_libraries(libxtrace Threads::Threads ${Protobuf_LIBRARIES} ${Boost_LIBRARIES} )
33
34
35
36
37
38
39
40
41

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)



42
install(DIRECTORY "include/"
43
44
45
46
47
        DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/xtrace"
        FILES_MATCHING
        PATTERN "*.h")


Jonathan Mace's avatar
Jonathan Mace committed
48
install(TARGETS libxtrace DESTINATION "${CMAKE_INSTALL_LIBDIR}")
49

50
# Compile the Lua library
51

52
53
54
55
56
find_package(Lua51 REQUIRED)

add_library(luaxtrace SHARED
	src/luaxtrace.cpp
	src/module.cpp
57
	src/lua_baggage.cpp
58
59
60
61
62
63
64
)

target_include_directories(luaxtrace PRIVATE ${LUA_INCLUDE_DIR} /usr/local/include/xtrace)

set_target_properties(luaxtrace PROPERTIES PREFIX "")
set_target_properties(luaxtrace PROPERTIES SUFFIX ".so")

Vaastav Anand's avatar
Vaastav Anand committed
65
target_link_libraries(luaxtrace libxtrace Threads::Threads ${Protobuf_LIBRARIES} ${Boost_LIBRARIES} )
66
67
68
69

install(TARGETS luaxtrace DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Compile the main example program
70
add_executable (main src/main.cc )
71
72

target_include_directories(main PRIVATE /usr/local/include/xtrace)
73
target_link_libraries(main libxtrace Threads::Threads protobuf boost_system  )