forked from jvm-profiling-tools/honest-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
107 lines (82 loc) · 3.45 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
103
104
105
106
107
##########################################################
# CMake Configuration
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(honest_profiler)
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "build")
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckFunctionExists)
##########################################################
# Paths
set(SRC "src/main/cpp")
set(SRC_TEST "src/test/cpp")
set(BIN "build")
set(OUTPUT "lagent")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN})
##########################################################
# Libraries & Code
find_package(PkgConfig REQUIRED)
find_package(JNI REQUIRED)
include_directories(${JAVA_INCLUDE_PATH})
include_directories(${JAVA_INCLUDE_PATH2})
pkg_check_modules (unittest++ REQUIRED unittest++)
include_directories(${unittest++_INCLUDE_DIRS})
# include of gcc 4.8 headers specifically to work around
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729933
# equivalent in ubuntu 13.10
include_directories("/usr/include/i386-linux-gnu/c++/4.8/")
set(SOURCE_FILES
${SRC}/agent.cpp
${SRC}/circular_queue.cpp
${SRC}/circular_queue.h
${SRC}/globals.h
${SRC}/log_writer.cpp
${SRC}/log_writer.h
${SRC}/processor.cpp
${SRC}/processor.h
${SRC}/profiler.cpp
${SRC}/profiler.h
${SRC}/stacktraces.h)
set(TEST_FILES
${SRC_TEST}/fixtures.h
${SRC_TEST}/test_circular_queue.cpp
${SRC_TEST}/test.cpp
${SRC_TEST}/test_log_writer.cpp
${SRC_TEST}/test_agent.cpp)
##########################################################
# Compiler Options
set(GLOBAL_WARNINGS "-Wall -Wformat-security -Wno-char-subscripts")
set(GLOBAL_WARNINGS "${GLOBAL_WARNINGS} -Wno-sign-compare -Wno-strict-overflow -Wwrite-strings")
set(GLOBAL_WARNINGS "${GLOBAL_WARNINGS} -Wnon-virtual-dtor -Woverloaded-virtual")
set(GLOBAL_COPTS "-fdiagnostics-show-option -fno-omit-frame-pointer -fno-strict-aliasing")
set(GLOBAL_COPTS "${GLOBAL_COPTS} -funsigned-char -fno-asynchronous-unwind-tables -msse2 -g -D__STDC_FORMAT_MACROS -O2")
# Platform Specific
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(GLOBAL_COPTS "${GLOBAL_COPTS} -DTARGET_RT_MAC_CFM=0")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message("-- Detected 64 bit Mac")
set(GLOBAL_COPTS "${GLOBAL_COPTS} -D__LP64__=1")
endif()
endif()
# Compiler Specific
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("-- using Clang")
set(GLOBAL_WARNINGS, "${GLOBAL_WARNINGS} -Weverything -Wno-c++98-compat-pedantic -Wno-padded")
set(global_warNINGS, "${GLOBAL_WARNINGS} -Wno-missing-prototypes -Wno-weak-vtables -Wno-global-constructors")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("-- using GCC")
set(GLOBAL_COPTS "${GLOBAL_COPTS} -mfpmath=sse")
set(GLOBAL_WARNINGS, "${GLOBAL_WARNINGS} -Wframe-larger-than=16384 -Wno-unused-but-set-variable")
set(GLOBAL_WARNINGS, "${GLOBAL_WARNINGS} -Wunused-but-set-parameter -Wvla -Wno-conversion-null")
set(GLOBAL_WARNINGS, "${GLOBAL_WARNINGS} -Wno-unknown-pragmas -Wno-builtin-macro-redefined -Wl,-fatal_warnings")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GLOBAL_WARNINGS} ${GLOBAL_COPTS} -pthread -std=c++11")
##########################################################
# Build
add_library(${OUTPUT} SHARED ${SOURCE_FILES})
target_link_libraries(${OUTPUT} ${JNI_LIBRARIES} dl)
add_executable(unitTests ${TEST_FILES})
target_link_libraries(unitTests ${OUTPUT} ${unittest++_LIBRARIES})
# make test
add_test(unitTests ${BIN}/unitTests)