-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
102 lines (85 loc) · 3.11 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
cmake_minimum_required(VERSION 2.8)
project(meteor)
# Project options
option(WithTests "Specifies whether to build tests" ON)
option(UseStaticBoost "Forces Boost static libraries usage" OFF)
option(MtTests "Enables pthreads usage for gtest" OFF)
set(METEOR_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(SIMULATOR_ROOT ${METEOR_ROOT}/tools/simulator)
set(TESTS_DIR ${METEOR_ROOT}/tests)
set(THIRD_PARTY_DIR ${METEOR_ROOT}/3rdparty)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${METEOR_ROOT}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${METEOR_ROOT}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${METEOR_ROOT}/bin)
# Check compiler and configure options
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else ()
message(STATUS
"The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. "
"Please use a different C++ compiler."
)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Supported compiler used: GCC")
add_definitions("${CMAKE_CXX_FLAGS}")
add_definitions("-Wall -Wextra -Werror -pedantic -pedantic-errors")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Supported compiler used: Clang")
add_definitions("${CMAKE_CXX_FLAGS}")
add_definitions("-Wall -Wextra -Werror -pedantic -pedantic-errors")
else ()
message("Unsupported compiler used: ${CMAKE_CXX_COMPILER_ID}")
endif ()
# Find Boost
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.50.0 COMPONENTS
REQUIRED regex
)
include_directories(${Boost_INCLUDE_DIRS})
# Sources
set(METEOR_SRCS
${METEOR_ROOT}/src/cluster/node.h
${METEOR_ROOT}/src/cluster/resource.h
${METEOR_ROOT}/src/cluster/resources_config_reader.h
${METEOR_ROOT}/src/cluster/resources_config_reader.cpp
${METEOR_ROOT}/src/cluster/resources_tracker.h
${METEOR_ROOT}/src/cluster/resources_tracker.cpp
${METEOR_ROOT}/src/scheduler/event.h
${METEOR_ROOT}/src/scheduler/fcfs_scheduler.h
${METEOR_ROOT}/src/scheduler/fcfs_scheduler.cpp
${METEOR_ROOT}/src/scheduler/job.h
${METEOR_ROOT}/src/scheduler/scheduler.h
${METEOR_ROOT}/src/scheduler/scheduler.cpp
${METEOR_ROOT}/src/scheduler/stat_scheduler.h
${METEOR_ROOT}/src/scheduler/stat_scheduler.cpp
${METEOR_ROOT}/src/scheduler/time.h
)
# Compile the library
add_library(meteor
${METEOR_SRCS}
)
include_directories(${METEOR_ROOT}/src)
# Add dependencies
target_link_libraries(meteor
${Boost_LIBRARIES}
)
# Debug binaries will have 'd' postfix
set_target_properties(meteor PROPERTIES DEBUG_POSTFIX "d")
# Build tests on-demand
if (WithTests)
if (NOT MtTests)
set(gtest_disable_pthreads ON)
endif ()
add_subdirectory(${THIRD_PARTY_DIR}/gtest-1.7.0)
set(GTest_INCLUDE_DIRS ${THIRD_PARTY_DIR}/gtest-1.7.0/include)
set(GTest_LIBRARIES gtest gtest_main)
add_subdirectory(${TESTS_DIR})
endif ()
# Build simulator
add_subdirectory(${SIMULATOR_ROOT})