Commit ca4c9147 authored by Dominik Charousset's avatar Dominik Charousset

cmake support

parent f7e88b57
cmake_minimum_required(VERSION 2.4)
project(cppa)
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wextra -Wall -Werror -pedantic")
set(LIBCPPA_SRC
src/abstract_event_based_actor.cpp
src/abstract_tuple.cpp
src/actor.cpp
src/actor_count.cpp
src/actor_proxy.cpp
src/actor_proxy_cache.cpp
src/actor_registry.cpp
src/addressed_message.cpp
src/any_tuple.cpp
src/atom.cpp
src/attachable.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/channel.cpp
src/converted_thread_context.cpp
src/cppa.cpp
src/demangle.cpp
src/deserializer.cpp
src/duration.cpp
src/empty_tuple.cpp
src/event_based_actor.cpp
src/exception.cpp
src/fiber.cpp
src/group.cpp
src/group_manager.cpp
src/invokable.cpp
src/local_actor.cpp
src/mailman.cpp
src/mock_scheduler.cpp
src/native_socket.cpp
src/network_manager.cpp
src/object.cpp
src/object_array.cpp
src/partial_function.cpp
src/pattern.cpp
src/post_office.cpp
src/primitive_variant.cpp
src/process_information.cpp
src/receive.cpp
src/ripemd_160.cpp
src/scheduled_actor.cpp
src/scheduled_actor_dummy.cpp
src/scheduler.cpp
src/self.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/singleton_manager.cpp
src/stacked_event_based_actor.cpp
src/string_serialization.cpp
src/thread_pool_scheduler.cpp
src/to_uniform_name.cpp
src/unicast_network.cpp
src/uniform_type_info.cpp
src/yield_interface.cpp
src/yielding_actor.cpp
)
find_package(Boost COMPONENTS thread REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${Boost_INCLUDE_DIRS})
add_library(libcppa SHARED ${LIBCPPA_SRC})
target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})
set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 2)
set(LIBCPPA_VERSION_PATCH 0)
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
set_target_properties(libcppa PROPERTIES SOVERSION ${LIBRARY_SOVERSION} VERSION ${LIBRARY_VERSION} OUTPUT_NAME cppa)
install(TARGETS libcppa LIBRARY DESTINATION lib)
# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa
FILES_MATCHING PATTERN "*.hpp")
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
set (CPPA_BINARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set (CPPA_LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
# setting path to cppa headers and libcppa
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
set (CPPA_LIBRARY_PATH ${CPPA_LIBRARY_OUTPUT_PATH})
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
if (APPLE)
set (CPPA_LIBRARY ${CPPA_LIBRARY_PATH}/libcppa.dylib)
elseif (UNIX)
set (CPPA_LIBRARY ${CPPA_LIBRARY_PATH}/libcppa.so)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
set (LIBRARY_OUTPUT_PATH ${CPPA_LIBRARY_OUTPUT_PATH}
CACHE PATH "Single directory for all libraries")
set (EXECUTABLE_OUTPUT_PATH ${CPPA_BINARY_OUTPUT_PATH}
CACHE PATH "Single directory for all executables")
add_subdirectory(unit_testing)
add_subdirectory(examples)
#add_subdirectory(benchmarks)
#add_dependencies(unit_tests libcppa)
#add_dependencies(benchmarks libcppa)
add_dependencies(announce_example_1 libcppa)
add_dependencies(announce_example_2 libcppa)
add_dependencies(announce_example_3 libcppa)
add_dependencies(announce_example_4 libcppa)
add_dependencies(announce_example_5 libcppa)
add_dependencies(dancing_kirby libcppa)
add_dependencies(dining_philosophers libcppa)
add_dependencies(hello_world_example libcppa)
add_dependencies(math_actor_example libcppa)
add_dependencies(unit_tests libcppa)
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest:
\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing
\"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
cmake_minimum_required(VERSION 2.6)
project(cppa_examples)
# Set up environment paths to cmake modules and libcppa
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(announce_example_1 announce_example_1.cpp)
add_executable(announce_example_2 announce_example_2.cpp)
add_executable(announce_example_3 announce_example_3.cpp)
add_executable(announce_example_4 announce_example_4.cpp)
add_executable(announce_example_5 announce_example_5.cpp)
add_executable(dancing_kirby dancing_kirby.cpp)
add_executable(dining_philosophers dining_philosophers.cpp)
add_executable(hello_world_example hello_world_example.cpp)
add_executable(math_actor_example math_actor_example.cpp)
# search for libs
if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED)
endif (NOT cppa_LIBRARY)
find_package(Boost COMPONENTS thread REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
target_link_libraries(announce_example_1 ${EXAMPLE_LIBS})
target_link_libraries(announce_example_2 ${EXAMPLE_LIBS})
target_link_libraries(announce_example_3 ${EXAMPLE_LIBS})
target_link_libraries(announce_example_4 ${EXAMPLE_LIBS})
target_link_libraries(announce_example_5 ${EXAMPLE_LIBS})
target_link_libraries(dancing_kirby ${EXAMPLE_LIBS})
target_link_libraries(dining_philosophers ${EXAMPLE_LIBS})
target_link_libraries(hello_world_example ${EXAMPLE_LIBS})
target_link_libraries(math_actor_example ${EXAMPLE_LIBS})
# - Try to find libcppa
# Once done this will define
#
# CPPA_FOUND - system has libcppa
# CPPA_INCLUDE - libcppa include dir
# CPPA_LIBRARY - link againgst libcppa
#
if (CPPA_LIBRARY AND CPPA_INCLUDE)
set(CPPA_FOUND TRUE)
else (CPPA_LIBRARY AND CPPA_INCLUDE)
find_path(CPPA_INCLUDE
NAMES
cppa/cppa.hpp
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CPPA_INCLUDE_PATH}
${CPPA_LIBRARY_PATH}
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)
if (CPPA_INCLUDE)
message (STATUS "Header files found ...")
else (CPPA_INCLUDE)
message (SEND_ERROR "Header files NOT found. Provide absolute path with -DCPPA_INCLUDE_PATH=<path-to-header>.")
endif (CPPA_INCLUDE)
find_library(CPPA_LIBRARY
NAMES
libcppa
cppa
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${CPPA_INCLUDE_PATH}
${CPPA_INCLUDE_PATH}/.libs
${CPPA_LIBRARY_PATH}
${CPPA_LIBRARY_PATH}/.libs
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)
if (CPPA_LIBRARY)
message (STATUS "Library found ...")
else (CPPA_LIBRARY)
message (SEND_ERROR "Library NOT found. Provide absolute path with -DCPPA_LIBRARY_PATH=<path-to-library>.")
endif (CPPA_LIBRARY)
if (CPPA_INCLUDE AND CPPA_LIBRARY)
set(CPPA_FOUND TRUE)
set(CPPA_INCLUDE ${CPPA_INCLUDE})
set(CPPA_LIBRARY ${CPPA_LIBRARY})
else (CPPA_INCLUDE AND CPPA_LIBRARY)
message (FATAL_ERROR "CPPA LIBRARY AND/OR HEADER NOT FOUND!")
endif (CPPA_INCLUDE AND CPPA_LIBRARY)
endif (CPPA_LIBRARY AND CPPA_INCLUDE)
cmake_minimum_required(VERSION 2.6)
project(cppa_unit_tests)
# Set up environment paths to cmake modules and libcppa
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(unit_tests
main.cpp
test__atom.cpp
test__intrusive_containers.cpp
test__local_group.cpp
test__pattern.cpp
test__remote_actor.cpp
test__serialization.cpp
test__tuple.cpp
test__uniform_type.cpp
ping_pong.cpp
test__fixed_vector.cpp
test__intrusive_ptr.cpp
test__match.cpp
test__primitive_variant.cpp
test__ripemd_160.cpp
test__spawn.cpp
test__type_list.cpp
test__yield_interface.cpp)
# search for libs
if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED)
endif (NOT cppa_LIBRARY)
find_package(Boost COMPONENTS thread REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
target_link_libraries(unit_tests ${EXAMPLE_LIBS})
# - Try to find libcppa
# Once done this will define
#
# CPPA_FOUND - system has libcppa
# CPPA_INCLUDE - libcppa include dir
# CPPA_LIBRARY - link againgst libcppa
#
if (CPPA_LIBRARY AND CPPA_INCLUDE)
set(CPPA_FOUND TRUE)
else (CPPA_LIBRARY AND CPPA_INCLUDE)
find_path(CPPA_INCLUDE
NAMES
cppa/cppa.hpp
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CPPA_INCLUDE_PATH}
${CPPA_LIBRARY_PATH}
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)
if (CPPA_INCLUDE)
message (STATUS "Header files found ...")
else (CPPA_INCLUDE)
message (SEND_ERROR "Header files NOT found. Provide absolute path with -DCPPA_INCLUDE_PATH=<path-to-header>.")
endif (CPPA_INCLUDE)
find_library(CPPA_LIBRARY
NAMES
libcppa
cppa
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${CPPA_INCLUDE_PATH}
${CPPA_INCLUDE_PATH}/.libs
${CPPA_LIBRARY_PATH}
${CPPA_LIBRARY_PATH}/.libs
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)
if (CPPA_LIBRARY)
message (STATUS "Library found ...")
else (CPPA_LIBRARY)
message (SEND_ERROR "Library NOT found. Provide absolute path with -DCPPA_LIBRARY_PATH=<path-to-library>.")
endif (CPPA_LIBRARY)
if (CPPA_INCLUDE AND CPPA_LIBRARY)
set(CPPA_FOUND TRUE)
set(CPPA_INCLUDE ${CPPA_INCLUDE})
set(CPPA_LIBRARY ${CPPA_LIBRARY})
else (CPPA_INCLUDE AND CPPA_LIBRARY)
message (FATAL_ERROR "CPPA LIBRARY AND/OR HEADER NOT FOUND!")
endif (CPPA_INCLUDE AND CPPA_LIBRARY)
endif (CPPA_LIBRARY AND CPPA_INCLUDE)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment