-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
98 lines (79 loc) · 3.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.0.0)
project(caf-pp VERSION 0.1.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++17")
# add stdlib to clang++
# TODO: check that the libc++ is installed
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wsign-compare")
message(STATUS "is clang, libc++ added")
endif()
# find CAF
find_library(CAF_LIB caf_core_static)
find_path(CAF_INCLUDE caf/all.hpp)
if(NOT CAF_LIB OR NOT CAF_INCLUDE)
message(FATAL_ERROR "CAF library not found")
endif()
find_library(PTHREAD pthread)
# Find/Download Range-v3
# reference: https://foonathan.net/2016/07/cmake-dependency-handling/
find_path(RANGE_INCLUDE range/v3/all.hpp)
if(RANGE_INCLUDE)
add_library(range INTERFACE)
target_include_directories(range INTERFACE ${RANGE_INCLUDE})
else()
message("Unable to find 'range-v3', will be downloaded...")
execute_process(COMMAND git submodule update --init -- external/range-v3
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# set RANGE_INCLUDE properly
set(RANGE_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/external/range-v3/include)
# also install it
install(DIRECTORY ${RANGE_INCLUDE} DESTINATION .)
# for convenience setup a target
add_library(range INTERFACE)
target_include_directories(range INTERFACE
$<BUILD_INTERFACE:${RANGE_INCLUDE}>
$<INSTALL_INTERFACE:include>)
# need to export target as well
install(TARGETS range EXPORT my_export_set DESTINATION include)
endif()
if(${SIZED_QUEUE})
add_compile_definitions(SIZED_QUEUE)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
# Library
add_library(caf_pp src/patterns.cpp
src/next.cpp
src/pp_actor.cpp)
target_include_directories(caf_pp PUBLIC ./src ${CAF_INCLUDE} ${RANGE_INCLUDE})
target_link_libraries(caf_pp ${CAF_LIB} pthread)
# Targets
add_executable (pipe-of-farm examples/pipe-of-farm.cpp)
target_include_directories(pipe-of-farm PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(pipe-of-farm caf_pp ${CAF_LIB})
add_executable (pipe-of-map examples/pipe-of-map.cpp)
target_include_directories(pipe-of-map PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(pipe-of-map caf_pp ${CAF_LIB})
add_executable (quicksort examples/quicksort.cpp)
target_include_directories(quicksort PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(quicksort caf_pp ${CAF_LIB})
add_executable (recMM examples/recMM.cpp)
target_include_directories(recMM PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(recMM caf_pp ${CAF_LIB})
add_executable (routerfarm examples/routerfarm.cpp)
target_include_directories(routerfarm PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(routerfarm caf_pp ${CAF_LIB})
add_executable (pipe-of-farm2 examples/pipe-of-farm2.cpp)
target_include_directories(pipe-of-farm2 PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(pipe-of-farm2 caf_pp ${CAF_LIB})
if(${SIZED_QUEUE})
add_executable (max-rate-pipe examples/max-rate-pipe.cpp)
target_include_directories(max-rate-pipe PUBLIC ${CAF_INCLUDE} ${RANGE_INCLUDE} ./src)
target_link_libraries(max-rate-pipe caf_pp ${CAF_LIB})
endif()
# Install Library
install(TARGETS caf_pp DESTINATION lib)
install(DIRECTORY src/
DESTINATION include/caf-pp
FILES_MATCHING PATTERN "*.hpp")