Skip to content

Commit ca4c914

Browse files
committed
cmake support
1 parent f7e88b5 commit ca4c914

File tree

6 files changed

+359
-0
lines changed

6 files changed

+359
-0
lines changed

CMakeLists.txt

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
cmake_minimum_required(VERSION 2.4)
2+
project(cppa)
3+
4+
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
5+
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wextra -Wall -Werror -pedantic")
7+
8+
set(LIBCPPA_SRC
9+
src/abstract_event_based_actor.cpp
10+
src/abstract_tuple.cpp
11+
src/actor.cpp
12+
src/actor_count.cpp
13+
src/actor_proxy.cpp
14+
src/actor_proxy_cache.cpp
15+
src/actor_registry.cpp
16+
src/addressed_message.cpp
17+
src/any_tuple.cpp
18+
src/atom.cpp
19+
src/attachable.cpp
20+
src/binary_deserializer.cpp
21+
src/binary_serializer.cpp
22+
src/channel.cpp
23+
src/converted_thread_context.cpp
24+
src/cppa.cpp
25+
src/demangle.cpp
26+
src/deserializer.cpp
27+
src/duration.cpp
28+
src/empty_tuple.cpp
29+
src/event_based_actor.cpp
30+
src/exception.cpp
31+
src/fiber.cpp
32+
src/group.cpp
33+
src/group_manager.cpp
34+
src/invokable.cpp
35+
src/local_actor.cpp
36+
src/mailman.cpp
37+
src/mock_scheduler.cpp
38+
src/native_socket.cpp
39+
src/network_manager.cpp
40+
src/object.cpp
41+
src/object_array.cpp
42+
src/partial_function.cpp
43+
src/pattern.cpp
44+
src/post_office.cpp
45+
src/primitive_variant.cpp
46+
src/process_information.cpp
47+
src/receive.cpp
48+
src/ripemd_160.cpp
49+
src/scheduled_actor.cpp
50+
src/scheduled_actor_dummy.cpp
51+
src/scheduler.cpp
52+
src/self.cpp
53+
src/serializer.cpp
54+
src/shared_spinlock.cpp
55+
src/singleton_manager.cpp
56+
src/stacked_event_based_actor.cpp
57+
src/string_serialization.cpp
58+
src/thread_pool_scheduler.cpp
59+
src/to_uniform_name.cpp
60+
src/unicast_network.cpp
61+
src/uniform_type_info.cpp
62+
src/yield_interface.cpp
63+
src/yielding_actor.cpp
64+
)
65+
66+
find_package(Boost COMPONENTS thread REQUIRED)
67+
68+
link_directories(${Boost_LIBRARY_DIRS})
69+
include_directories(. ${Boost_INCLUDE_DIRS})
70+
71+
add_library(libcppa SHARED ${LIBCPPA_SRC})
72+
73+
target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})
74+
75+
set(LIBCPPA_VERSION_MAJOR 0)
76+
set(LIBCPPA_VERSION_MINOR 2)
77+
set(LIBCPPA_VERSION_PATCH 0)
78+
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
79+
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
80+
81+
set_target_properties(libcppa PROPERTIES SOVERSION ${LIBRARY_SOVERSION} VERSION ${LIBRARY_VERSION} OUTPUT_NAME cppa)
82+
install(TARGETS libcppa LIBRARY DESTINATION lib)
83+
84+
# install includes
85+
install(DIRECTORY cppa/ DESTINATION include/cppa
86+
FILES_MATCHING PATTERN "*.hpp")
87+
# uninstall target
88+
configure_file(
89+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
90+
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
91+
IMMEDIATE @ONLY)
92+
93+
add_custom_target(uninstall
94+
COMMAND ${CMAKE_COMMAND} -P
95+
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
96+
97+
set (CPPA_BINARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
98+
set (CPPA_LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
99+
# setting path to cppa headers and libcppa
100+
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
101+
set (CPPA_LIBRARY_PATH ${CPPA_LIBRARY_OUTPUT_PATH})
102+
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
103+
if (APPLE)
104+
set (CPPA_LIBRARY ${CPPA_LIBRARY_PATH}/libcppa.dylib)
105+
elseif (UNIX)
106+
set (CPPA_LIBRARY ${CPPA_LIBRARY_PATH}/libcppa.so)
107+
else ()
108+
message (SEND_FATAL "Host platform not supported ...")
109+
endif ()
110+
111+
set (LIBRARY_OUTPUT_PATH ${CPPA_LIBRARY_OUTPUT_PATH}
112+
CACHE PATH "Single directory for all libraries")
113+
set (EXECUTABLE_OUTPUT_PATH ${CPPA_BINARY_OUTPUT_PATH}
114+
CACHE PATH "Single directory for all executables")
115+
116+
add_subdirectory(unit_testing)
117+
add_subdirectory(examples)
118+
#add_subdirectory(benchmarks)
119+
#add_dependencies(unit_tests libcppa)
120+
#add_dependencies(benchmarks libcppa)
121+
add_dependencies(announce_example_1 libcppa)
122+
add_dependencies(announce_example_2 libcppa)
123+
add_dependencies(announce_example_3 libcppa)
124+
add_dependencies(announce_example_4 libcppa)
125+
add_dependencies(announce_example_5 libcppa)
126+
add_dependencies(dancing_kirby libcppa)
127+
add_dependencies(dining_philosophers libcppa)
128+
add_dependencies(hello_world_example libcppa)
129+
add_dependencies(math_actor_example libcppa)
130+
add_dependencies(unit_tests libcppa)
131+

cmake_uninstall.cmake.in

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
2+
message(FATAL_ERROR "Cannot find install manifest:
3+
\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
4+
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
5+
6+
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
7+
string(REGEX REPLACE "\n" ";" files "${files}")
8+
list(REVERSE files)
9+
foreach (file ${files})
10+
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
11+
if (EXISTS "$ENV{DESTDIR}${file}")
12+
execute_process(
13+
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
14+
OUTPUT_VARIABLE rm_out
15+
RESULT_VARIABLE rm_retval
16+
)
17+
if(NOT ${rm_retval} EQUAL 0)
18+
message(FATAL_ERROR "Problem when removing
19+
\"$ENV{DESTDIR}${file}\"")
20+
endif (NOT ${rm_retval} EQUAL 0)
21+
else (EXISTS "$ENV{DESTDIR}${file}")
22+
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
23+
endif (EXISTS "$ENV{DESTDIR}${file}")
24+
endforeach(file)

examples/CMakeLists.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
project(cppa_examples)
3+
4+
# Set up environment paths to cmake modules and libcppa
5+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
6+
7+
add_executable(announce_example_1 announce_example_1.cpp)
8+
add_executable(announce_example_2 announce_example_2.cpp)
9+
add_executable(announce_example_3 announce_example_3.cpp)
10+
add_executable(announce_example_4 announce_example_4.cpp)
11+
add_executable(announce_example_5 announce_example_5.cpp)
12+
add_executable(dancing_kirby dancing_kirby.cpp)
13+
add_executable(dining_philosophers dining_philosophers.cpp)
14+
add_executable(hello_world_example hello_world_example.cpp)
15+
add_executable(math_actor_example math_actor_example.cpp)
16+
17+
# search for libs
18+
if(NOT cppa_LIBRARY)
19+
find_package(Libcppa REQUIRED)
20+
endif (NOT cppa_LIBRARY)
21+
22+
find_package(Boost COMPONENTS thread REQUIRED)
23+
24+
link_directories(${Boost_LIBRARY_DIRS})
25+
include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
26+
27+
set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
28+
29+
target_link_libraries(announce_example_1 ${EXAMPLE_LIBS})
30+
target_link_libraries(announce_example_2 ${EXAMPLE_LIBS})
31+
target_link_libraries(announce_example_3 ${EXAMPLE_LIBS})
32+
target_link_libraries(announce_example_4 ${EXAMPLE_LIBS})
33+
target_link_libraries(announce_example_5 ${EXAMPLE_LIBS})
34+
target_link_libraries(dancing_kirby ${EXAMPLE_LIBS})
35+
target_link_libraries(dining_philosophers ${EXAMPLE_LIBS})
36+
target_link_libraries(hello_world_example ${EXAMPLE_LIBS})
37+
target_link_libraries(math_actor_example ${EXAMPLE_LIBS})

examples/FindLibcppa.cmake

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# - Try to find libcppa
2+
# Once done this will define
3+
#
4+
# CPPA_FOUND - system has libcppa
5+
# CPPA_INCLUDE - libcppa include dir
6+
# CPPA_LIBRARY - link againgst libcppa
7+
#
8+
9+
if (CPPA_LIBRARY AND CPPA_INCLUDE)
10+
set(CPPA_FOUND TRUE)
11+
else (CPPA_LIBRARY AND CPPA_INCLUDE)
12+
13+
find_path(CPPA_INCLUDE
14+
NAMES
15+
cppa/cppa.hpp
16+
PATHS
17+
/usr/include
18+
/usr/local/include
19+
/opt/local/include
20+
/sw/include
21+
${CPPA_INCLUDE_PATH}
22+
${CPPA_LIBRARY_PATH}
23+
${CMAKE_INCLUDE_PATH}
24+
${CMAKE_INSTALL_PREFIX}/include
25+
)
26+
27+
if (CPPA_INCLUDE)
28+
message (STATUS "Header files found ...")
29+
else (CPPA_INCLUDE)
30+
message (SEND_ERROR "Header files NOT found. Provide absolute path with -DCPPA_INCLUDE_PATH=<path-to-header>.")
31+
endif (CPPA_INCLUDE)
32+
33+
find_library(CPPA_LIBRARY
34+
NAMES
35+
libcppa
36+
cppa
37+
PATHS
38+
/usr/lib
39+
/usr/local/lib
40+
/opt/local/lib
41+
/sw/lib
42+
${CPPA_INCLUDE_PATH}
43+
${CPPA_INCLUDE_PATH}/.libs
44+
${CPPA_LIBRARY_PATH}
45+
${CPPA_LIBRARY_PATH}/.libs
46+
${CMAKE_LIBRARY_PATH}
47+
${CMAKE_INSTALL_PREFIX}/lib
48+
)
49+
50+
if (CPPA_LIBRARY)
51+
message (STATUS "Library found ...")
52+
else (CPPA_LIBRARY)
53+
message (SEND_ERROR "Library NOT found. Provide absolute path with -DCPPA_LIBRARY_PATH=<path-to-library>.")
54+
endif (CPPA_LIBRARY)
55+
56+
if (CPPA_INCLUDE AND CPPA_LIBRARY)
57+
set(CPPA_FOUND TRUE)
58+
set(CPPA_INCLUDE ${CPPA_INCLUDE})
59+
set(CPPA_LIBRARY ${CPPA_LIBRARY})
60+
else (CPPA_INCLUDE AND CPPA_LIBRARY)
61+
message (FATAL_ERROR "CPPA LIBRARY AND/OR HEADER NOT FOUND!")
62+
endif (CPPA_INCLUDE AND CPPA_LIBRARY)
63+
64+
endif (CPPA_LIBRARY AND CPPA_INCLUDE)

unit_testing/CMakeLists.txt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
project(cppa_unit_tests)
3+
4+
# Set up environment paths to cmake modules and libcppa
5+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
6+
7+
add_executable(unit_tests
8+
main.cpp
9+
test__atom.cpp
10+
test__intrusive_containers.cpp
11+
test__local_group.cpp
12+
test__pattern.cpp
13+
test__remote_actor.cpp
14+
test__serialization.cpp
15+
test__tuple.cpp
16+
test__uniform_type.cpp
17+
ping_pong.cpp
18+
test__fixed_vector.cpp
19+
test__intrusive_ptr.cpp
20+
test__match.cpp
21+
test__primitive_variant.cpp
22+
test__ripemd_160.cpp
23+
test__spawn.cpp
24+
test__type_list.cpp
25+
test__yield_interface.cpp)
26+
27+
# search for libs
28+
if(NOT cppa_LIBRARY)
29+
find_package(Libcppa REQUIRED)
30+
endif (NOT cppa_LIBRARY)
31+
32+
find_package(Boost COMPONENTS thread REQUIRED)
33+
34+
link_directories(${Boost_LIBRARY_DIRS})
35+
include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
36+
37+
set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
38+
39+
target_link_libraries(unit_tests ${EXAMPLE_LIBS})

unit_testing/FindLibcppa.cmake

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# - Try to find libcppa
2+
# Once done this will define
3+
#
4+
# CPPA_FOUND - system has libcppa
5+
# CPPA_INCLUDE - libcppa include dir
6+
# CPPA_LIBRARY - link againgst libcppa
7+
#
8+
9+
if (CPPA_LIBRARY AND CPPA_INCLUDE)
10+
set(CPPA_FOUND TRUE)
11+
else (CPPA_LIBRARY AND CPPA_INCLUDE)
12+
13+
find_path(CPPA_INCLUDE
14+
NAMES
15+
cppa/cppa.hpp
16+
PATHS
17+
/usr/include
18+
/usr/local/include
19+
/opt/local/include
20+
/sw/include
21+
${CPPA_INCLUDE_PATH}
22+
${CPPA_LIBRARY_PATH}
23+
${CMAKE_INCLUDE_PATH}
24+
${CMAKE_INSTALL_PREFIX}/include
25+
)
26+
27+
if (CPPA_INCLUDE)
28+
message (STATUS "Header files found ...")
29+
else (CPPA_INCLUDE)
30+
message (SEND_ERROR "Header files NOT found. Provide absolute path with -DCPPA_INCLUDE_PATH=<path-to-header>.")
31+
endif (CPPA_INCLUDE)
32+
33+
find_library(CPPA_LIBRARY
34+
NAMES
35+
libcppa
36+
cppa
37+
PATHS
38+
/usr/lib
39+
/usr/local/lib
40+
/opt/local/lib
41+
/sw/lib
42+
${CPPA_INCLUDE_PATH}
43+
${CPPA_INCLUDE_PATH}/.libs
44+
${CPPA_LIBRARY_PATH}
45+
${CPPA_LIBRARY_PATH}/.libs
46+
${CMAKE_LIBRARY_PATH}
47+
${CMAKE_INSTALL_PREFIX}/lib
48+
)
49+
50+
if (CPPA_LIBRARY)
51+
message (STATUS "Library found ...")
52+
else (CPPA_LIBRARY)
53+
message (SEND_ERROR "Library NOT found. Provide absolute path with -DCPPA_LIBRARY_PATH=<path-to-library>.")
54+
endif (CPPA_LIBRARY)
55+
56+
if (CPPA_INCLUDE AND CPPA_LIBRARY)
57+
set(CPPA_FOUND TRUE)
58+
set(CPPA_INCLUDE ${CPPA_INCLUDE})
59+
set(CPPA_LIBRARY ${CPPA_LIBRARY})
60+
else (CPPA_INCLUDE AND CPPA_LIBRARY)
61+
message (FATAL_ERROR "CPPA LIBRARY AND/OR HEADER NOT FOUND!")
62+
endif (CPPA_INCLUDE AND CPPA_LIBRARY)
63+
64+
endif (CPPA_LIBRARY AND CPPA_INCLUDE)

0 commit comments

Comments
 (0)