-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
81 lines (66 loc) · 2.44 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
cmake_minimum_required(VERSION 2.8)
project(lutop C CXX)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
OPTION(TESTS "enable_testing" ON)
# Initialize FLAGS.
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
# Compiler-specific C++11 activation.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
# Setup boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package( Boost 1.48.0 COMPONENTS system filesystem program_options REQUIRED )
include_directories(${Boost_INCLUDE_DIRS})
# Threads
find_package(Threads REQUIRED)
# Lua staff
add_subdirectory(contrib)
include_directories(${LUAJIT_INCLUDE_DIRS})
include_directories(${MSGPACKCLEN_INCLUDE_DIRS})
# Msgpack for manager process
find_package(MsgPack REQUIRED)
include_directories(${MsgPack_INCLUDE_DIRS})
# Code
add_subdirectory(src)
# GTest magic
if(TESTS)
find_package(GTest)
message(STATUS "GTest include dir: ${GTEST_INCLUDE_DIR}")
include_directories(${GTEST_INCLUDE_DIR})
if(NOT GTEST_BOTH_LIBRARIES)
if(EXISTS /usr/src/gtest)
add_subdirectory( /usr/src/gtest ${PROJECT_BINARY_DIR}/gtest )
set(GTEST_BOTH_LIBRARIES gtest gtest_main)
else(EXISTS /usr/src/gtest)
message(FATAL_ERROR "GTest not found")
endif(EXISTS /usr/src/gtest)
endif(NOT GTEST_BOTH_LIBRARIES)
add_custom_target(test)
macro(run_test test_target)
add_custom_target(${test_target}_runtest
COMMAND ${test_target}
DEPENDS ${test_target}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
add_dependencies(test ${test_target}_runtest)
endmacro()
add_subdirectory(tests)
endif(TESTS)