Unverified Commit 7bce1d66 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1087

Modernize CMake setup
parents 8f025383 60e87a05
This diff is collapsed.
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
// Default CMake flags for release builds. // Default CMake flags for release builds.
defaultReleaseBuildFlags = [ defaultReleaseBuildFlags = [
'CAF_ENABLE_RUNTIME_CHECKS:BOOL=yes', 'CAF_ENABLE_RUNTIME_CHECKS:BOOL=ON',
] ]
// Default CMake flags for debug builds. // Default CMake flags for debug builds.
defaultDebugBuildFlags = defaultReleaseBuildFlags + [ defaultDebugBuildFlags = defaultReleaseBuildFlags + [
'CAF_SANITIZERS:STRING=address,undefined', 'CAF_SANITIZERS:STRING=address,undefined',
'CAF_LOG_LEVEL:STRING=TRACE', 'CAF_LOG_LEVEL:STRING=TRACE',
'CAF_ENABLE_ACTOR_PROFILER:BOOL=yes', 'CAF_ENABLE_ACTOR_PROFILER:BOOL=ON',
] ]
// Configures the behavior of our stages. // Configures the behavior of our stages.
...@@ -28,10 +28,6 @@ config = [ ...@@ -28,10 +28,6 @@ config = [
// Our build matrix. Keys are the operating system labels and values are build configurations. // Our build matrix. Keys are the operating system labels and values are build configurations.
buildMatrix: [ buildMatrix: [
// Various Linux builds for debug and release. // Various Linux builds for debug and release.
['debian-8', [
builds: ['debug', 'release'],
tools: ['clang-4'],
]],
['centos-6', [ ['centos-6', [
builds: ['debug', 'release'], builds: ['debug', 'release'],
tools: ['gcc-7'], tools: ['gcc-7'],
...@@ -97,12 +93,20 @@ config = [ ...@@ -97,12 +93,20 @@ config = [
'OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include', 'OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include',
], ],
], ],
Windows: [
debug: defaultDebugBuildFlags + [
'CAF_ENABLE_OPENSSL_MODULE:BOOL=OFF',
],
release: defaultReleaseBuildFlags + [
'CAF_ENABLE_OPENSSL_MODULE:BOOL=OFF',
],
],
], ],
// Configures what binary the coverage report uses and what paths to exclude. // Configures what binary the coverage report uses and what paths to exclude.
coverage: [ coverage: [
binaries: [ binaries: [
'build/bin/caf-core-test', 'build/libcaf_core/caf-core-test',
'build/bin/caf-io-test', 'build/libcaf_io/caf-io-test',
], ],
relativeExcludePaths: [ relativeExcludePaths: [
'examples', 'examples',
...@@ -151,6 +155,8 @@ pipeline { ...@@ -151,6 +155,8 @@ pipeline {
buildDir: 'build', buildDir: 'build',
installation: 'cmake in search path', installation: 'cmake in search path',
sourceDir: '.', sourceDir: '.',
cmakeArgs: '-DCAF_ENABLE_IO_MODULE:BOOL=OFF ' +
'-DCAF_ENABLE_UTILITY_TARGETS:BOOL=ON',
steps: [[ steps: [[
args: '--target consistency-check', args: '--target consistency-check',
withCmake: true, withCmake: true,
......
...@@ -25,10 +25,8 @@ ...@@ -25,10 +25,8 @@
#define CAF_LOG_LEVEL CAF_LOG_LEVEL_@CAF_LOG_LEVEL@ #define CAF_LOG_LEVEL CAF_LOG_LEVEL_@CAF_LOG_LEVEL@
#cmakedefine CAF_NO_MEM_MANAGEMENT
#cmakedefine CAF_ENABLE_RUNTIME_CHECKS #cmakedefine CAF_ENABLE_RUNTIME_CHECKS
#cmakedefine CAF_NO_EXCEPTIONS #cmakedefine CAF_ENABLE_EXCEPTIONS
#cmakedefine CAF_ENABLE_ACTOR_PROFILER #cmakedefine CAF_ENABLE_ACTOR_PROFILER
This diff is collapsed.
add_custom_target(all_examples) add_custom_target(all_examples)
include_directories(${LIBCAF_INCLUDE_DIRS}) function(add_example folder name)
macro(add folder name)
add_executable(${name} ${folder}/${name}.cpp ${ARGN}) add_executable(${name} ${folder}/${name}.cpp ${ARGN})
target_link_libraries(${name}
${CAF_EXTRA_LDFLAGS}
${CAF_LIBRARIES}
${PTHREAD_LIBRARIES})
install(FILES ${folder}/${name}.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/examples/${folder}) install(FILES ${folder}/${name}.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/examples/${folder})
add_dependencies(${name} all_examples) add_dependencies(${name} all_examples)
endmacro() endfunction()
function(add_core_example folder name)
add_example(${folder} ${name} ${ARGN})
target_link_libraries(${name} CAF::core)
endfunction()
# -- examples for CAF::core ----------------------------------------------------
# introductionary applications # introductionary applications
add(. aout) add_core_example(. aout)
add(. hello_world) add_core_example(. hello_world)
# basic message passing primitives # basic message passing primitives
add(message_passing calculator) add_core_example(message_passing calculator)
add(message_passing cell) add_core_example(message_passing cell)
add(message_passing dancing_kirby) add_core_example(message_passing dancing_kirby)
add(message_passing delegating) add_core_example(message_passing delegating)
add(message_passing divider) add_core_example(message_passing divider)
add(message_passing fan_out_request) add_core_example(message_passing fan_out_request)
add(message_passing fixed_stack) add_core_example(message_passing fixed_stack)
add(message_passing promises) add_core_example(message_passing promises)
add(message_passing request) add_core_example(message_passing request)
add(message_passing typed_calculator) add_core_example(message_passing typed_calculator)
# streaming API # streaming API
add(streaming integer_stream) add_core_example(streaming integer_stream)
# dynamic behavior changes using 'become' # dynamic behavior changes using 'become'
add(dynamic_behavior skip_messages) add_core_example(dynamic_behavior skip_messages)
add(dynamic_behavior dining_philosophers) add_core_example(dynamic_behavior dining_philosophers)
# adding custom message types # adding custom message types
add(custom_type custom_types_1) add_core_example(custom_type custom_types_1)
add(custom_type custom_types_2) add_core_example(custom_type custom_types_2)
add(custom_type custom_types_3) add_core_example(custom_type custom_types_3)
# basic remoting # testing DSL
add(remoting group_chat) add_example(testing ping_pong)
add(remoting group_server) target_link_libraries(ping_pong CAF::core CAF::test)
add(remoting remote_spawn)
add(remoting distributed_calculator)
# basic I/O with brokers
add(broker simple_broker)
add(broker simple_http_broker)
# testing DSL # -- examples for CAF::io ------------------------------------------------------
add(testing ping_pong)
if(TARGET CAF::io)
function(add_io_example folder name)
add_example(${folder} ${name} ${ARGN})
target_link_libraries(${name} CAF::io CAF::core)
endfunction()
# basic remoting
add_io_example(remoting group_chat)
add_io_example(remoting group_server)
add_io_example(remoting remote_spawn)
add_io_example(remoting distributed_calculator)
# basic I/O with brokers
add_io_example(broker simple_broker)
add_io_example(broker simple_http_broker)
endif()
if(CAF_BUILD_PROTOBUF_EXAMPLES)
find_package(Protobuf) if(CAF_ENABLE_PROTOBUF_EXAMPLES)
if(PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE) find_package(Protobuf REQUIRED)
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders "${CMAKE_CURRENT_SOURCE_DIR}/remoting/pingpong.proto") if(NOT PROTOBUF_PROTOC_EXECUTABLE)
message(FATAL_ERROR "CMake was unable to set PROTOBUF_PROTOC_EXECUTABLE")
endif()
protobuf_generate_cpp(ProtoSources ProtoHeaders "${CMAKE_CURRENT_SOURCE_DIR}/remoting/pingpong.proto")
include_directories(${PROTOBUF_INCLUDE_DIR}) include_directories(${PROTOBUF_INCLUDE_DIR})
# add binary dir as include path as generated headers will be located there
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(protobuf_broker broker/protobuf_broker.cpp ${ProtoSources}) add_executable(protobuf_broker broker/protobuf_broker.cpp ${ProtoSources})
target_link_libraries(protobuf_broker ${CMAKE_DL_LIBS} ${CAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${PROTOBUF_LIBRARIES}) target_link_libraries(protobuf_broker ${PROTOBUF_LIBRARIES} CAF::core CAF::io)
add_dependencies(protobuf_broker all_examples) add_dependencies(protobuf_broker all_examples)
endif(PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE)
endif() endif()
if(CAF_BUILD_QT_EXAMPLES) if(CAF_ENABLE_QT5_EXAMPLES)
find_package(Qt5 COMPONENTS Core Gui Widgets QUIET) find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
if(Qt5_FOUND)
message(STATUS "Found Qt5") message(STATUS "Found Qt5")
#include(${QT_USE_FILE}) #include(${QT_USE_FILE})
QT5_ADD_RESOURCES(GROUP_CHAT_RCS ) QT5_ADD_RESOURCES(GROUP_CHAT_RCS )
QT5_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui) QT5_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
QT5_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp) QT5_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory # generated headers will be in cmake build directory
#include_directories(. qtsupport ${CMAKE_CURRENT_BINARY_DIR} ${CPPA_INCLUDE})
include_directories(qtsupport include_directories(qtsupport
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${Qt5Core_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS}
...@@ -87,43 +100,18 @@ if(CAF_BUILD_QT_EXAMPLES) ...@@ -87,43 +100,18 @@ if(CAF_BUILD_QT_EXAMPLES)
${GROUP_CHAT_MOC_SRC} ${GROUP_CHAT_MOC_SRC}
${GROUP_CHAT_UI_HDR}) ${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat target_link_libraries(qt_group_chat
${CMAKE_DL_LIBS}
${CAF_LIBRARIES}
Qt5::Core Qt5::Core
Qt5::Gui Qt5::Gui
Qt5::Widgets) Qt5::Widgets
add_dependencies(qt_group_chat all_examples) CAF::core
else() CAF::io)
find_package(Qt4)
if(QT4_FOUND)
message(STATUS "Found Qt4")
include(${QT_USE_FILE})
QT4_ADD_RESOURCES(GROUP_CHAT_RCS )
QT4_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
QT4_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory
#include_directories(. qtsupport ${CMAKE_CURRENT_BINARY_DIR} ${CPPA_INCLUDE})
include_directories(qtsupport ${CMAKE_CURRENT_BINARY_DIR})
set(GROUP_CHAT_SRCS qtsupport/qt_group_chat.cpp qtsupport/chatwidget.cpp)
add_executable(qt_group_chat
${GROUP_CHAT_SRCS}
${GROUP_CHAT_MOC_SRC}
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
${CMAKE_DL_LIBS}
${CAF_LIBRARIES}
${QT_LIBRARIES})
add_dependencies(qt_group_chat all_examples) add_dependencies(qt_group_chat all_examples)
endif()
endif()
endif() endif()
if(NOT CAF_NO_CURL_EXAMPLES) if(CAF_ENABLE_CURL_EXAMPLES)
find_package(CURL) find_package(CURL REQUIRED)
if(CURL_FOUND)
add_executable(curl_fuse curl/curl_fuse.cpp) add_executable(curl_fuse curl/curl_fuse.cpp)
include_directories(${CURL_INCLUDE_DIRS}) include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(curl_fuse ${CMAKE_DL_LIBS} ${CAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${CURL_LIBRARY}) target_link_libraries(curl_fuse ${CURL_LIBRARY} CAF::core CAF::io)
add_dependencies(curl_fuse all_examples) add_dependencies(curl_fuse all_examples)
endif(CURL_FOUND)
endif() endif()
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <iostream> #include <iostream>
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp"
using namespace caf; using namespace caf;
using std::endl; using std::endl;
......
...@@ -19,9 +19,9 @@ add_enum_consistency_check("caf/intrusive/inbox_result.hpp" ...@@ -19,9 +19,9 @@ add_enum_consistency_check("caf/intrusive/inbox_result.hpp"
add_enum_consistency_check("caf/intrusive/task_result.hpp" add_enum_consistency_check("caf/intrusive/task_result.hpp"
"src/intrusive/task_result_strings.cpp") "src/intrusive/task_result_strings.cpp")
# -- list cpp files for libcaf_core -------------------------------------------- # -- add library target --------------------------------------------------------
set(CAF_CORE_SOURCES add_library(libcaf_core_obj OBJECT ${CAF_CORE_HEADERS}
src/abstract_actor.cpp src/abstract_actor.cpp
src/abstract_channel.cpp src/abstract_channel.cpp
src/abstract_group.cpp src/abstract_group.cpp
...@@ -154,140 +154,42 @@ set(CAF_CORE_SOURCES ...@@ -154,140 +154,42 @@ set(CAF_CORE_SOURCES
src/uuid.cpp src/uuid.cpp
) )
# -- list cpp files for caf-core-test ------------------------------------------ target_include_directories(libcaf_core_obj PRIVATE
"${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
set(CAF_CORE_TEST_SOURCES
test/actor_clock.cpp
test/actor_factory.cpp
test/actor_lifetime.cpp
test/actor_pool.cpp
test/actor_profiler.cpp
test/actor_registry.cpp
test/actor_system_config.cpp
test/actor_termination.cpp
test/aout.cpp
test/behavior.cpp
test/binary_deserializer.cpp
test/binary_serializer.cpp
test/blocking_actor.cpp
test/broadcast_downstream_manager.cpp
test/byte.cpp
test/composition.cpp
test/config_option.cpp
test/config_option_set.cpp
test/config_value.cpp
test/config_value_adaptor.cpp
test/const_typed_message_view.cpp
test/constructor_attach.cpp
test/continuous_streaming.cpp
test/cow_tuple.cpp
test/custom_exception_handler.cpp
test/decorator/sequencer.cpp
test/deep_to_string.cpp
test/detached_actors.cpp
test/detail/bounds_checker.cpp
test/detail/ini_consumer.cpp
test/detail/limited_vector.cpp
test/detail/meta_object.cpp
test/detail/parse.cpp
test/detail/parser/read_bool.cpp
test/detail/parser/read_floating_point.cpp
test/detail/parser/read_ini.cpp
test/detail/parser/read_number.cpp
test/detail/parser/read_number_or_timespan.cpp
test/detail/parser/read_signed_integer.cpp
test/detail/parser/read_string.cpp
test/detail/parser/read_timespan.cpp
test/detail/parser/read_unsigned_integer.cpp
test/detail/ringbuffer.cpp
test/detail/ripemd_160.cpp
test/detail/serialized_size.cpp
test/detail/tick_emitter.cpp
test/detail/type_id_list_builder.cpp
test/detail/unique_function.cpp
test/detail/unordered_flat_map.cpp
test/dictionary.cpp
test/dynamic_spawn.cpp
test/error.cpp
test/expected.cpp
test/function_view.cpp
test/fused_downstream_manager.cpp
test/handles.cpp
test/hash/fnv.cpp
test/inspector.cpp
test/intrusive/drr_cached_queue.cpp
test/intrusive/drr_queue.cpp
test/intrusive/fifo_inbox.cpp
test/intrusive/lifo_inbox.cpp
test/intrusive/task_queue.cpp
test/intrusive/wdrr_dynamic_multiplexed_queue.cpp
test/intrusive/wdrr_fixed_multiplexed_queue.cpp
test/intrusive_ptr.cpp
test/ipv4_address.cpp
test/ipv4_endpoint.cpp
test/ipv4_subnet.cpp
test/ipv6_address.cpp
test/ipv6_endpoint.cpp
test/ipv6_subnet.cpp
test/local_group.cpp
test/logger.cpp
test/mailbox_element.cpp
test/make_config_value_field.cpp
test/message.cpp
test/message_id.cpp
test/message_lifetime.cpp
test/metaprogramming.cpp
test/mixin/requester.cpp
test/mixin/sender.cpp
test/mock_streaming_classes.cpp
test/native_streaming_classes.cpp
test/node_id.cpp
test/optional.cpp
test/or_else.cpp
test/pipeline_streaming.cpp
test/policy/categorized.cpp
test/policy/select_all.cpp
test/policy/select_any.cpp
test/request_timeout.cpp
test/result.cpp
test/selective_streaming.cpp
test/serialization.cpp
test/settings.cpp
test/simple_timeout.cpp
test/span.cpp
test/stateful_actor.cpp
test/string_algorithms.cpp
test/string_view.cpp
test/sum_type.cpp
test/thread_hook.cpp
test/tracing_data.cpp
test/type_id_list.cpp
test/typed_behavior.cpp
test/typed_message_view.cpp
test/typed_response_promise.cpp
test/typed_spawn.cpp
test/unit.cpp
test/uri.cpp
test/uuid.cpp
test/variant.cpp
)
# -- add library target -------------------------------------------------------- add_library(libcaf_core "${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
$<TARGET_OBJECTS:libcaf_core_obj>)
add_library(libcaf_core_obj OBJECT ${CAF_CORE_SOURCES} ${CAF_CORE_HEADERS}) target_include_directories(libcaf_core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
add_library(libcaf_core target_include_directories(libcaf_core INTERFACE
"${PROJECT_SOURCE_DIR}/cmake/dummy.cpp" $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
$<TARGET_OBJECTS:libcaf_core_obj>)
add_library(CAF::core ALIAS libcaf_core)
add_library(caf::core ALIAS libcaf_core) # -- dependencies and compiler flags -------------------------------------------
if(BUILD_SHARED_LIBS AND NOT WIN32) if(BUILD_SHARED_LIBS AND NOT WIN32)
target_compile_options(libcaf_core PRIVATE -fPIC) target_compile_options(libcaf_core PRIVATE -fPIC)
target_compile_options(libcaf_core_obj PRIVATE -fPIC) target_compile_options(libcaf_core_obj PRIVATE -fPIC)
endif() endif()
target_link_libraries(libcaf_core PUBLIC ${CAF_EXTRA_LDFLAGS}) if(NOT TARGET Threads::Threads)
find_package(Threads REQUIRED)
endif()
target_link_libraries(libcaf_core PUBLIC Threads::Threads)
if(MSVC)
target_link_libraries(libcaf_core PUBLIC iphlpapi)
endif()
if(CAF_SANITIZERS)
target_link_libraries(libcaf_core PUBLIC -fsanitize=${CAF_SANITIZERS})
endif()
# -- API exports ---------------------------------------------------------------
generate_export_header(libcaf_core generate_export_header(libcaf_core
EXPORT_MACRO_NAME CAF_CORE_EXPORT EXPORT_MACRO_NAME CAF_CORE_EXPORT
...@@ -321,21 +223,142 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf" ...@@ -321,21 +223,142 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf"
# -- build unit tests ---------------------------------------------------------- # -- build unit tests ----------------------------------------------------------
if(NOT CAF_NO_UNIT_TESTS) if(NOT CAF_ENABLE_TESTING)
add_executable(caf-core-test return()
endif()
add_executable(caf-core-test
test/core-test.cpp test/core-test.cpp
${CAF_CORE_TEST_SOURCES}
$<TARGET_OBJECTS:libcaf_core_obj>) $<TARGET_OBJECTS:libcaf_core_obj>)
target_include_directories(caf-core-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(caf-core-test PRIVATE libcaf_core_EXPORTS)
target_link_libraries(caf-core-test ${CAF_EXTRA_LDFLAGS})
add_test_suites(caf-core-test
"${CMAKE_CURRENT_SOURCE_DIR}"
${CAF_CORE_TEST_SOURCES})
endif()
# -- add this library to the global CAF_LIBRARIES ------------------------------ target_include_directories(caf-core-test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(caf-core-test PRIVATE libcaf_core_EXPORTS)
list(APPEND CAF_LIBRARIES libcaf_core) target_link_libraries(caf-core-test PUBLIC CAF::test)
set(CAF_LIBRARIES ${CAF_LIBRARIES} PARENT_SCOPE) target_link_libraries(caf-core-test PRIVATE
$<TARGET_PROPERTY:libcaf_core,INTERFACE_LINK_LIBRARIES>)
target_include_directories(caf-core-test PRIVATE
"${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
caf_add_test_suites(caf-core-test
actor_clock
actor_factory
actor_lifetime
actor_pool
actor_profiler
actor_registry
actor_system_config
actor_termination
aout
behavior
binary_deserializer
binary_serializer
blocking_actor
broadcast_downstream_manager
byte
composition
config_option
config_option_set
config_value
config_value_adaptor
const_typed_message_view
constructor_attach
continuous_streaming
cow_tuple
decorator.sequencer
deep_to_string
detached_actors
detail.bounds_checker
detail.ini_consumer
detail.limited_vector
detail.meta_object
detail.parse
detail.parser.read_bool
detail.parser.read_floating_point
detail.parser.read_ini
detail.parser.read_number
detail.parser.read_number_or_timespan
detail.parser.read_signed_integer
detail.parser.read_string
detail.parser.read_timespan
detail.parser.read_unsigned_integer
detail.ringbuffer
detail.ripemd_160
detail.serialized_size
detail.tick_emitter
detail.type_id_list_builder
detail.unique_function
detail.unordered_flat_map
dictionary
dynamic_spawn
error
expected
function_view
fused_downstream_manager
handles
hash.fnv
inspector
intrusive.drr_cached_queue
intrusive.drr_queue
intrusive.fifo_inbox
intrusive.lifo_inbox
intrusive.task_queue
intrusive.wdrr_dynamic_multiplexed_queue
intrusive.wdrr_fixed_multiplexed_queue
intrusive_ptr
ipv4_address
ipv4_endpoint
ipv4_subnet
ipv6_address
ipv6_endpoint
ipv6_subnet
local_group
logger
mailbox_element
make_config_value_field
message
message_id
message_lifetime
metaprogramming
mixin.requester
mixin.sender
mock_streaming_classes
native_streaming_classes
node_id
optional
or_else
pipeline_streaming
policy.categorized
policy.select_all
policy.select_any
request_timeout
result
selective_streaming
serialization
settings
simple_timeout
span
stateful_actor
string_algorithms
string_view
sum_type
thread_hook
tracing_data
type_id_list
typed_behavior
typed_message_view
typed_response_promise
typed_spawn
unit
uri
uuid
variant
)
if(CAF_ENABLE_EXCEPTIONS)
caf_add_test_suites(caf-core-test custom_exception_handler)
endif()
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
# include <stdexcept> # include <stdexcept>
#endif #endif
...@@ -33,32 +33,32 @@ CAF_CORE_EXPORT void log_cstring_error(const char* cstring); ...@@ -33,32 +33,32 @@ CAF_CORE_EXPORT void log_cstring_error(const char* cstring);
} // namespace caf::detail } // namespace caf::detail
#ifdef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
# define CAF_RAISE_ERROR_IMPL_1(msg) \ # define CAF_RAISE_ERROR_IMPL_2(exception_type, msg) \
do { \ do { \
::caf::detail::log_cstring_error(msg); \ ::caf::detail::log_cstring_error(msg); \
CAF_CRITICAL(msg); \ throw exception_type(msg); \
} while (false) } while (false)
# define CAF_RAISE_ERROR_IMPL_2(unused, msg) CAF_RAISE_ERROR_IMPL_1(msg) # define CAF_RAISE_ERROR_IMPL_1(msg) \
CAF_RAISE_ERROR_IMPL_2(std::runtime_error, msg)
#else // CAF_NO_EXCEPTIONS #else // CAF_ENABLE_EXCEPTIONS
# define CAF_RAISE_ERROR_IMPL_2(exception_type, msg) \ # define CAF_RAISE_ERROR_IMPL_1(msg) \
do { \ do { \
::caf::detail::log_cstring_error(msg); \ ::caf::detail::log_cstring_error(msg); \
throw exception_type(msg); \ CAF_CRITICAL(msg); \
} while (false) } while (false)
# define CAF_RAISE_ERROR_IMPL_1(msg) \ # define CAF_RAISE_ERROR_IMPL_2(unused, msg) CAF_RAISE_ERROR_IMPL_1(msg)
CAF_RAISE_ERROR_IMPL_2(std::runtime_error, msg)
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
#ifdef CAF_MSVC #ifdef CAF_MSVC
/// Throws an exception if `CAF_NO_EXCEPTIONS` is undefined, otherwise calls /// Throws an exception if `CAF_ENABLE_EXCEPTIONS` is defined, otherwise calls
/// abort() after printing a given message. /// abort() after printing a given message.
# define CAF_RAISE_ERROR(...) \ # define CAF_RAISE_ERROR(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_RAISE_ERROR_IMPL_, \ CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_RAISE_ERROR_IMPL_, \
...@@ -67,7 +67,7 @@ CAF_CORE_EXPORT void log_cstring_error(const char* cstring); ...@@ -67,7 +67,7 @@ CAF_CORE_EXPORT void log_cstring_error(const char* cstring);
#else // CAF_MSVC #else // CAF_MSVC
/// Throws an exception if `CAF_NO_EXCEPTIONS` is undefined, otherwise calls /// Throws an exception if `CAF_ENABLE_EXCEPTIONS` is defined, otherwise calls
/// abort() after printing a given message. /// abort() after printing a given message.
# define CAF_RAISE_ERROR(...) \ # define CAF_RAISE_ERROR(...) \
CAF_PP_OVERLOAD(CAF_RAISE_ERROR_IMPL_, __VA_ARGS__)(__VA_ARGS__) CAF_PP_OVERLOAD(CAF_RAISE_ERROR_IMPL_, __VA_ARGS__)(__VA_ARGS__)
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
# include <exception> # include <exception>
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
#include <forward_list> #include <forward_list>
#include <map> #include <map>
...@@ -190,10 +190,10 @@ public: ...@@ -190,10 +190,10 @@ public:
/// Function object for handling exit messages. /// Function object for handling exit messages.
using exit_handler = std::function<void(pointer, exit_msg&)>; using exit_handler = std::function<void(pointer, exit_msg&)>;
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
/// Function object for handling exit messages. /// Function object for handling exit messages.
using exception_handler = std::function<error(pointer, std::exception_ptr&)>; using exception_handler = std::function<error(pointer, std::exception_ptr&)>;
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
/// Consumes messages from the mailbox. /// Consumes messages from the mailbox.
struct mailbox_visitor { struct mailbox_visitor {
...@@ -232,9 +232,9 @@ public: ...@@ -232,9 +232,9 @@ public:
static void default_exit_handler(pointer ptr, exit_msg& x); static void default_exit_handler(pointer ptr, exit_msg& x);
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
static error default_exception_handler(pointer ptr, std::exception_ptr& x); static error default_exception_handler(pointer ptr, std::exception_ptr& x);
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
// -- constructors and destructors ------------------------------------------- // -- constructors and destructors -------------------------------------------
...@@ -389,7 +389,7 @@ public: ...@@ -389,7 +389,7 @@ public:
set_exit_handler([fun](scheduled_actor*, exit_msg& x) { fun(x); }); set_exit_handler([fun](scheduled_actor*, exit_msg& x) { fun(x); });
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
/// Sets a custom exception handler for this actor. If multiple handlers are /// Sets a custom exception handler for this actor. If multiple handlers are
/// defined, only the functor that was added *last* is being executed. /// defined, only the functor that was added *last* is being executed.
inline void set_exception_handler(exception_handler fun) { inline void set_exception_handler(exception_handler fun) {
...@@ -408,7 +408,7 @@ public: ...@@ -408,7 +408,7 @@ public:
set_exception_handler( set_exception_handler(
[f](scheduled_actor*, std::exception_ptr& x) { return f(x); }); [f](scheduled_actor*, std::exception_ptr& x) { return f(x); });
} }
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
/// @cond PRIVATE /// @cond PRIVATE
...@@ -703,10 +703,10 @@ protected: ...@@ -703,10 +703,10 @@ protected:
/// Pointer to a private thread object associated with a detached actor. /// Pointer to a private thread object associated with a detached actor.
detail::private_thread* private_thread_; detail::private_thread* private_thread_;
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
/// Customization point for setting a default exception callback. /// Customization point for setting a default exception callback.
exception_handler exception_handler_; exception_handler exception_handler_;
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
/// @endcond /// @endcond
}; };
......
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
self_->set_exit_handler(std::forward<Fun>(fun)); self_->set_exit_handler(std::forward<Fun>(fun));
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
/// @copydoc scheduled_actor::set_exception_handler /// @copydoc scheduled_actor::set_exception_handler
template <class Fun> template <class Fun>
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
self_->set_exception_handler(std::forward<Fun>(fun)); self_->set_exception_handler(std::forward<Fun>(fun));
} }
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
// -- linking and monitoring ------------------------------------------------- // -- linking and monitoring -------------------------------------------------
......
...@@ -107,7 +107,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) { ...@@ -107,7 +107,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) {
CAF_PUSH_AID_FROM_PTR(self); CAF_PUSH_AID_FROM_PTR(self);
self->initialize(); self->initialize();
error rsn; error rsn;
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
try { try {
self->act(); self->act();
rsn = self->fail_state_; rsn = self->fail_state_;
......
...@@ -97,7 +97,7 @@ void scheduled_actor::default_exit_handler(scheduled_actor* ptr, exit_msg& x) { ...@@ -97,7 +97,7 @@ void scheduled_actor::default_exit_handler(scheduled_actor* ptr, exit_msg& x) {
default_error_handler(ptr, x.reason); default_error_handler(ptr, x.reason);
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
error scheduled_actor::default_exception_handler(pointer ptr, error scheduled_actor::default_exception_handler(pointer ptr,
std::exception_ptr& x) { std::exception_ptr& x) {
CAF_ASSERT(x != nullptr); CAF_ASSERT(x != nullptr);
...@@ -115,7 +115,7 @@ error scheduled_actor::default_exception_handler(pointer ptr, ...@@ -115,7 +115,7 @@ error scheduled_actor::default_exception_handler(pointer ptr,
} }
return sec::runtime_error; return sec::runtime_error;
} }
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
// -- constructors and destructors --------------------------------------------- // -- constructors and destructors ---------------------------------------------
...@@ -129,10 +129,10 @@ scheduled_actor::scheduled_actor(actor_config& cfg) ...@@ -129,10 +129,10 @@ scheduled_actor::scheduled_actor(actor_config& cfg)
node_down_handler_(default_node_down_handler), node_down_handler_(default_node_down_handler),
exit_handler_(default_exit_handler), exit_handler_(default_exit_handler),
private_thread_(nullptr) private_thread_(nullptr)
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
, ,
exception_handler_(default_exception_handler) exception_handler_(default_exception_handler)
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
{ {
auto& sys_cfg = home_system().config(); auto& sys_cfg = home_system().config();
auto interval = sys_cfg.stream_tick_duration(); auto interval = sys_cfg.stream_tick_duration();
...@@ -743,9 +743,9 @@ bool scheduled_actor::activate(execution_unit* ctx) { ...@@ -743,9 +743,9 @@ bool scheduled_actor::activate(execution_unit* ctx) {
CAF_LOG_ERROR("activate called on a terminated actor"); CAF_LOG_ERROR("activate called on a terminated actor");
return false; return false;
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
try { try {
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
if (!getf(is_initialized_flag)) { if (!getf(is_initialized_flag)) {
initialize(); initialize();
if (finalize()) { if (finalize()) {
...@@ -754,7 +754,7 @@ bool scheduled_actor::activate(execution_unit* ctx) { ...@@ -754,7 +754,7 @@ bool scheduled_actor::activate(execution_unit* ctx) {
} }
CAF_LOG_DEBUG("initialized actor:" << CAF_ARG(name())); CAF_LOG_DEBUG("initialized actor:" << CAF_ARG(name()));
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
} catch (...) { } catch (...) {
CAF_LOG_ERROR("actor died during initialization"); CAF_LOG_ERROR("actor died during initialization");
auto eptr = std::current_exception(); auto eptr = std::current_exception();
...@@ -762,7 +762,7 @@ bool scheduled_actor::activate(execution_unit* ctx) { ...@@ -762,7 +762,7 @@ bool scheduled_actor::activate(execution_unit* ctx) {
finalize(); finalize();
return false; return false;
} }
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
return true; return true;
} }
...@@ -779,7 +779,7 @@ auto scheduled_actor::activate(execution_unit* ctx, mailbox_element& x) ...@@ -779,7 +779,7 @@ auto scheduled_actor::activate(execution_unit* ctx, mailbox_element& x)
auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result { auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
CAF_LOG_TRACE(CAF_ARG(x)); CAF_LOG_TRACE(CAF_ARG(x));
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
auto handle_exception = [&](std::exception_ptr eptr) { auto handle_exception = [&](std::exception_ptr eptr) {
auto err = call_handler(exception_handler_, this, eptr); auto err = call_handler(exception_handler_, this, eptr);
if (x.mid.is_request()) { if (x.mid.is_request()) {
...@@ -789,7 +789,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result { ...@@ -789,7 +789,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
quit(std::move(err)); quit(std::move(err));
}; };
try { try {
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
switch (consume(x)) { switch (consume(x)) {
case invoke_message_result::dropped: case invoke_message_result::dropped:
return activation_result::dropped; return activation_result::dropped;
...@@ -803,7 +803,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result { ...@@ -803,7 +803,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
case invoke_message_result::skipped: case invoke_message_result::skipped:
return activation_result::skipped; return activation_result::skipped;
} }
#ifndef CAF_NO_EXCEPTIONS #ifdef CAF_ENABLE_EXCEPTIONS
} catch (std::exception& e) { } catch (std::exception& e) {
CAF_LOG_INFO("actor died because of an exception, what: " << e.what()); CAF_LOG_INFO("actor died because of an exception, what: " << e.what());
static_cast<void>(e); // keep compiler happy when not logging static_cast<void>(e); // keep compiler happy when not logging
...@@ -814,7 +814,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result { ...@@ -814,7 +814,7 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
} }
finalize(); finalize();
return activation_result::terminated; return activation_result::terminated;
#endif // CAF_NO_EXCEPTIONS #endif // CAF_ENABLE_EXCEPTIONS
} }
// -- behavior management ---------------------------------------------------- // -- behavior management ----------------------------------------------------
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
using namespace caf; using namespace caf;
#ifndef CAF_NO_EXCEPTIONS #ifndef CAF_ENABLE_EXCEPTIONS
# error "building unit test for exception handlers in no-exceptions build"
#endif
class exception_testee : public event_based_actor { class exception_testee : public event_based_actor {
public: public:
...@@ -77,11 +79,3 @@ CAF_TEST(test_custom_exception_handler) { ...@@ -77,11 +79,3 @@ CAF_TEST(test_custom_exception_handler) {
// receive all down messages // receive all down messages
self->wait_for(testee1, testee2, testee3); self->wait_for(testee1, testee2, testee3);
} }
#else // CAF_NO_EXCEPTIONS
CAF_TEST(no_exceptions_dummy) {
CAF_CHECK_EQUAL(true, true);
}
#endif // CAF_NO_EXCEPTIONS
...@@ -10,9 +10,9 @@ add_enum_consistency_check("caf/io/basp/message_type.hpp" ...@@ -10,9 +10,9 @@ add_enum_consistency_check("caf/io/basp/message_type.hpp"
add_enum_consistency_check("caf/io/network/operation.hpp" add_enum_consistency_check("caf/io/network/operation.hpp"
"src/io/network/operation_strings.cpp") "src/io/network/operation_strings.cpp")
# -- list cpp files ------------------------------------------------------------ # -- add library target --------------------------------------------------------
set(CAF_IO_SOURCES add_library(libcaf_io_obj OBJECT ${CAF_IO_HEADERS}
src/detail/socket_guard.cpp src/detail/socket_guard.cpp
src/io/abstract_broker.cpp src/io/abstract_broker.cpp
src/io/basp/header.cpp src/io/basp/header.cpp
...@@ -55,38 +55,31 @@ set(CAF_IO_SOURCES ...@@ -55,38 +55,31 @@ set(CAF_IO_SOURCES
src/policy/udp.cpp src/policy/udp.cpp
) )
set(CAF_IO_TEST_SOURCES target_include_directories(libcaf_io_obj PRIVATE
test/io/basp/message_queue.cpp "${CMAKE_CURRENT_SOURCE_DIR}")
test/io/basp_broker.cpp
test/io/broker.cpp
test/io/http_broker.cpp
test/io/monitor.cpp
test/io/network/default_multiplexer.cpp
test/io/network/ip_endpoint.cpp
test/io/receive_buffer.cpp
test/io/remote_actor.cpp
test/io/remote_group.cpp
test/io/remote_spawn.cpp
test/io/unpublish.cpp
test/io/worker.cpp
)
# -- add library target --------------------------------------------------------
add_library(libcaf_io_obj OBJECT ${CAF_IO_SOURCES} ${CAF_IO_HEADERS})
add_library(libcaf_io add_library(libcaf_io
"${PROJECT_SOURCE_DIR}/cmake/dummy.cpp" "${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
$<TARGET_OBJECTS:libcaf_io_obj>) $<TARGET_OBJECTS:libcaf_io_obj>)
add_library(caf::io ALIAS libcaf_io) target_include_directories(libcaf_io INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
add_library(CAF::io ALIAS libcaf_io)
if(BUILD_SHARED_LIBS AND NOT WIN32) if(BUILD_SHARED_LIBS AND NOT WIN32)
target_compile_options(libcaf_io PRIVATE -fPIC) target_compile_options(libcaf_io PRIVATE -fPIC)
target_compile_options(libcaf_io_obj PRIVATE -fPIC) target_compile_options(libcaf_io_obj PRIVATE -fPIC)
endif() endif()
target_link_libraries(libcaf_io PUBLIC caf::core ${CAF_EXTRA_LDFLAGS}) target_include_directories(libcaf_io_obj PRIVATE
$<TARGET_PROPERTY:libcaf_core,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(libcaf_io PUBLIC CAF::core)
if(MSVC)
target_link_libraries(libcaf_io PUBLIC ws2_32 iphlpapi)
endif()
generate_export_header(libcaf_io generate_export_header(libcaf_io
EXPORT_MACRO_NAME CAF_IO_EXPORT EXPORT_MACRO_NAME CAF_IO_EXPORT
...@@ -119,21 +112,37 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf" ...@@ -119,21 +112,37 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf"
# -- build unit tests ---------------------------------------------------------- # -- build unit tests ----------------------------------------------------------
if(NOT CAF_NO_UNIT_TESTS) if(NOT CAF_ENABLE_TESTING)
add_executable(caf-io-test return()
endif()
add_executable(caf-io-test
test/io-test.cpp test/io-test.cpp
${CAF_IO_TEST_SOURCES}
$<TARGET_OBJECTS:libcaf_io_obj>) $<TARGET_OBJECTS:libcaf_io_obj>)
target_include_directories(caf-io-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(caf-io-test PRIVATE libcaf_io_EXPORTS)
target_link_libraries(caf-io-test caf::core ${CAF_EXTRA_LDFLAGS})
add_test_suites(caf-io-test
"${CMAKE_CURRENT_SOURCE_DIR}"
${CAF_IO_TEST_SOURCES})
endif()
# -- add this library to the global CAF_LIBRARIES ------------------------------ target_include_directories(caf-io-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
list(APPEND CAF_LIBRARIES libcaf_io) target_compile_definitions(caf-io-test PRIVATE libcaf_io_EXPORTS)
set(CAF_LIBRARIES ${CAF_LIBRARIES} PARENT_SCOPE) target_link_libraries(caf-io-test PRIVATE CAF::core CAF::test)
target_link_libraries(caf-io-test PRIVATE
$<TARGET_PROPERTY:libcaf_io,INTERFACE_LINK_LIBRARIES>)
target_include_directories(caf-io-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
caf_add_test_suites(caf-io-test
io.basp.message_queue
io.basp_broker
io.broker
io.http_broker
io.monitor
io.network.default_multiplexer
io.network.ip_endpoint
io.receive_buffer
io.remote_actor
io.remote_group
io.remote_spawn
io.unpublish
io.worker
)
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
file(GLOB_RECURSE CAF_OPENSSL_HEADERS "caf/*.hpp") file(GLOB_RECURSE CAF_OPENSSL_HEADERS "caf/*.hpp")
# -- list cpp files ------------------------------------------------------------ # -- add library target --------------------------------------------------------
set(CAF_OPENSSL_SOURCES add_library(libcaf_openssl_obj OBJECT ${CAF_OPENSSL_HEADERS}
src/openssl/manager.cpp src/openssl/manager.cpp
src/openssl/middleman_actor.cpp src/openssl/middleman_actor.cpp
src/openssl/publish.cpp src/openssl/publish.cpp
...@@ -12,33 +12,36 @@ set(CAF_OPENSSL_SOURCES ...@@ -12,33 +12,36 @@ set(CAF_OPENSSL_SOURCES
src/openssl/session.cpp src/openssl/session.cpp
) )
set(CAF_OPENSSL_TEST_SOURCES target_include_directories(libcaf_openssl_obj PRIVATE
test/openssl/authentication.cpp "${CMAKE_CURRENT_SOURCE_DIR}")
test/openssl/remote_actor.cpp
)
# -- add library target --------------------------------------------------------
add_library(libcaf_openssl_obj OBJECT ${CAF_OPENSSL_SOURCES} ${CAF_OPENSSL_HEADERS})
add_library(libcaf_openssl add_library(libcaf_openssl
"${PROJECT_SOURCE_DIR}/cmake/dummy.cpp" "${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
$<TARGET_OBJECTS:libcaf_openssl_obj>) $<TARGET_OBJECTS:libcaf_openssl_obj>)
add_library(caf::openssl ALIAS libcaf_openssl) target_include_directories(libcaf_openssl INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
add_library(CAF::openssl ALIAS libcaf_openssl)
if(BUILD_SHARED_LIBS AND NOT WIN32) if(BUILD_SHARED_LIBS AND NOT WIN32)
target_compile_options(libcaf_openssl PRIVATE -fPIC) target_compile_options(libcaf_openssl PRIVATE -fPIC)
target_compile_options(libcaf_openssl_obj PRIVATE -fPIC) target_compile_options(libcaf_openssl_obj PRIVATE -fPIC)
endif() endif()
target_link_libraries(libcaf_openssl PUBLIC if(NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
caf::core caf::io ${OPENSSL_LIBRARIES}) find_package(OpenSSL REQUIRED)
if(NOT APPLE AND NOT WIN32)
target_link_libraries(libcaf_openssl PUBLIC "-pthread")
endif() endif()
target_include_directories(libcaf_openssl_obj PRIVATE
$<TARGET_PROPERTY:libcaf_core,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:libcaf_io,INTERFACE_INCLUDE_DIRECTORIES>
${OPENSSL_INCLUDE_DIR})
target_link_libraries(libcaf_openssl PUBLIC
CAF::core CAF::io
OpenSSL::SSL OpenSSL::Crypto)
generate_export_header(libcaf_openssl generate_export_header(libcaf_openssl
EXPORT_MACRO_NAME CAF_OPENSSL_EXPORT EXPORT_MACRO_NAME CAF_OPENSSL_EXPORT
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/caf/detail/openssl_export.hpp" EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/caf/detail/openssl_export.hpp"
...@@ -75,22 +78,26 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf" ...@@ -75,22 +78,26 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf"
# -- build unit tests ---------------------------------------------------------- # -- build unit tests ----------------------------------------------------------
if(NOT CAF_NO_UNIT_TESTS) if(NOT CAF_ENABLE_TESTING)
add_executable(caf-openssl-test return()
endif()
add_executable(caf-openssl-test
test/openssl-test.cpp test/openssl-test.cpp
${CAF_OPENSSL_TEST_SOURCES} ${CAF_OPENSSL_TEST_SOURCES}
$<TARGET_OBJECTS:libcaf_openssl_obj>) $<TARGET_OBJECTS:libcaf_openssl_obj>)
target_include_directories(caf-openssl-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(caf-openssl-test PRIVATE libcaf_openssl_EXPORTS)
target_link_libraries(caf-openssl-test caf::core caf::io
${OPENSSL_LIBRARIES} ${CAF_EXTRA_LDFLAGS})
add_test_suites(caf-openssl-test
"${CMAKE_CURRENT_SOURCE_DIR}"
${CAF_OPENSSL_TEST_SOURCES})
endif()
# -- add this library to the global CAF_LIBRARIES ------------------------------ target_include_directories(caf-openssl-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(caf-openssl-test PRIVATE libcaf_openssl_EXPORTS)
list(APPEND CAF_LIBRARIES libcaf_openssl) target_link_libraries(caf-openssl-test PRIVATE
CAF::io CAF::core CAF::test OpenSSL::SSL OpenSSL::Crypto)
set(CAF_LIBRARIES ${CAF_LIBRARIES} PARENT_SCOPE) target_include_directories(caf-openssl-test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}")
caf_add_test_suites(caf-openssl-test
openssl.authentication
openssl.remote_actor
)
add_custom_target(all_tools) add_custom_target(all_tools)
include_directories(${LIBCAF_INCLUDE_DIRS})
macro(add name) macro(add name)
add_executable(${name} ${name}.cpp ${ARGN}) add_executable(${name} ${name}.cpp ${ARGN})
target_link_libraries(${name} install(FILES ${name}.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/tools)
${CAF_EXTRA_LDFLAGS}
${CAF_LIBRARIES}
${PTHREAD_LIBRARIES})
install(FILES ${name}.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/tools/${folder})
add_dependencies(${name} all_tools) add_dependencies(${name} all_tools)
endmacro() endmacro()
if(WIN32) add(caf-vec)
target_link_libraries(caf-vec PRIVATE CAF::core)
if(TARGET CAF::io)
if(WIN32)
message(STATUS "skip caf-run (not supported on Windows)") message(STATUS "skip caf-run (not supported on Windows)")
else() else()
add(caf-run) add(caf-run)
target_link_libraries(caf-run PRIVATE CAF::io CAF::core)
endif()
endif() endif()
add(caf-vec)
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