-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·83 lines (70 loc) · 2.87 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
cmake_minimum_required(VERSION 2.6)
project(agere14 CXX)
set(AGERE14_VERSION_MAJOR 0)
set(AGERE14_VERSION_MINOR 1)
set(AGERE14_VERSION_PATCH 0)
# prohibit in-source builds
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed. Please use "
"./configure to choose a build directory and "
"initialize the build configuration.")
endif ()
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# check if the user provided CXXFLAGS on the command line
if (CMAKE_CXX_FLAGS)
set(CXXFLAGS_PROVIDED true)
endif ()
if (CXXFLAGS_PROVIDED)
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_MINSIZEREL "")
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
else ()
set(CMAKE_CXX_FLAGS "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-O4")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
endif ()
# check for g++ >= 4.7 or clang++ > = 3.2
try_run(ProgramResult
CompilationSucceeded
${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/get_compiler_version.cpp
RUN_OUTPUT_VARIABLE CompilerVersion)
if (NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0)
message(FATAL_ERROR "Cannot determine compiler version")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
if (CompilerVersion VERSION_GREATER 4.6)
message(STATUS "Found g++ version ${CompilerVersion}")
else ()
message(FATAL_ERROR "g++ >= 4.7 required (found: ${CompilerVersion}.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (CompilerVersion VERSION_GREATER 3.1)
message(STATUS "Found clang++ version ${CompilerVersion}")
else ()
message(FATAL_ERROR "clang++ >= 3.2 required (found: ${CompilerVersion}.")
endif ()
if (NOT CXXFLAGS_PROVIDED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
# set build type (evaluate ENABLE_DEBUG flag)
if (ENABLE_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLIBCAF_DEBUG")
else ()
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()
find_package(Libcaf COMPONENTS core io riac REQUIRED)
# set(LD_FLAGS ${LD_FLAGS} ${LIBCAF_LIBRARIES})
# set(INCLUDE_DIRS ${INCLUDE_DIRS} ${LIBCAF_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(. include ${CMAKE_BINARY_DIR} ${LIBCAF_INCLUDE_DIRS})
add_executable(ping_pong ./src/ping_pong.cpp)
target_link_libraries(ping_pong ${CMAKE_DL_LIBS} ${LIBCAF_LIBRARIES})
add_executable(probed_calculator ./src/probed_calculator.cpp)
target_link_libraries(probed_calculator ${CMAKE_DL_LIBS} ${LIBCAF_LIBRARIES})
add_executable(verbose_probe ./src/verbose_probe.cpp)
target_link_libraries(verbose_probe ${CMAKE_DL_LIBS} ${LIBCAF_LIBRARIES})