-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
121 lines (105 loc) · 3.67 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Based on https://github.com/mesosphere/serenity/blob/master/CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
project(mesos-journald-container-logger
VERSION 0.1.0
LANGUAGES CXX C)
enable_testing()
# Command line options.
set(WITH_MESOS "/usr" CACHE STRING "Mesos installation directory")
set(MESOS_INSTALLATION_DIR ${WITH_MESOS})
message("Mesos installation directory set to: " ${MESOS_INSTALLATION_DIR})
option(INTEGRATION_TESTS "Enable compilation of integration tests." OFF)
# Compiler things.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "Error: ${CMAKE_CXX_COMPILER} has no C++11 support")
endif()
# Some libs needs to be compiled position indepenedent.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
# Add gtest.
add_subdirectory (${MESOS_SRC_DIR}/build/3rdparty/gmock-1.7.0)
#include_directories(${gmock_SOURCE_DIR} include)
#include_directories(${gtest_SOURCE_DIR} include)
link_directories(
${MESOS_INSTALLATION_DIR}/lib/
${MESOS_INSTALLATION_DIR}/lib/mesos/3rdparty/lib)
include_directories(
./
${MESOS_SRC_DIR}/build/3rdparty/gmock-1.7.0/gtest/include
${MESOS_SRC_DIR}/build/3rdparty/gmock-1.7.0/include
${MESOS_SRC_DIR}/build/3rdparty/include/zookeeper
${MESOS_SRC_DIR}/build/3rdparty/include
${MESOS_SRC_DIR}/build/src
${MESOS_SRC_DIR}/src
${MESOS_INSTALLATION_DIR}/include/
${MESOS_INSTALLATION_DIR}/include/mesos
${MESOS_INSTALLATION_DIR}/lib/mesos/3rdparty/include
${CMAKE_BINARY_DIR}/
$(CMAKE_INCLUDE_PATH)
)
add_definitions(
-DSOURCE_DIR="${MESOS_SRC_DIR}/src"
-DBUILD_DIR="${MESOS_SRC_DIR}/build"
-DPKGMODULEDIR="nowhere"
-DLIBDIR="nowhere"
-DPKGLIBEXECDIR="nowhere"
-DTESTLIBEXECDIR="nowhere"
-DSBINDIR="nowhere"
-DPKGDATADIR="nowhere"
-DVERSION="1.0.1"
)
set(JOURNALD_CONTAINER_LOGGER_SOURCES
src/journald_container_logger.cpp
src/journald_container_logger.hpp
)
set(JOURNALD_CONTAINER_LOGGER_TEST_SOURCES
src/tests/journald_container_logger_tests.cpp
src/tests/main_test.cpp
${MESOS_SRC_DIR}/src/tests/cluster.cpp
${MESOS_SRC_DIR}/src/tests/containerizer.cpp
${MESOS_SRC_DIR}/src/tests/environment.cpp
${MESOS_SRC_DIR}/src/tests/flags.cpp
${MESOS_SRC_DIR}/src/tests/mesos.cpp
${MESOS_SRC_DIR}/src/tests/module.cpp
${MESOS_SRC_DIR}/src/tests/script.cpp
${MESOS_SRC_DIR}/src/tests/utils.cpp
${MESOS_SRC_DIR}/src/tests/containerizer/launcher.cpp
${MESOS_SRC_DIR}/src/tests/containerizer/memory_test_helper.cpp
)
# Module.
add_library(mesos_journald_container_logger-${PROJECT_VERSION}
SHARED
${JOURNALD_CONTAINER_LOGGER_SOURCES})
target_link_libraries(mesos_journald_container_logger-${PROJECT_VERSION}
systemd)
# Tests
add_executable(mesos-journald-container-logger-tests
${JOURNALD_CONTAINER_LOGGER_TEST_SOURCES}
)
target_link_libraries(mesos-journald-container-logger-tests
stdc++
m
dl
gmock
gmock_main
gtest
gtest_main
mesos
# Clang cannot compile it because of the error.
# Without glog this ends with segmentation fault(?)
glog
systemd
)
add_test(NAME mesos-journald-container-logger-tests
COMMAND mesos-journald-container-logger-tests)
set(WITH_SOURCE_MESOS "" CACHE STRING "Mesos source directory")
set(MESOS_SOURCE_DIR ${WITH_SOURCE_MESOS})