Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
7bce1d66
Unverified
Commit
7bce1d66
authored
Apr 15, 2020
by
Dominik Charousset
Committed by
GitHub
Apr 15, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1087
Modernize CMake setup
parents
8f025383
60e87a05
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
814 additions
and
1223 deletions
+814
-1223
CMakeLists.txt
CMakeLists.txt
+182
-476
Jenkinsfile
Jenkinsfile
+14
-8
cmake/build_config.hpp.in
cmake/build_config.hpp.in
+1
-3
configure
configure
+225
-362
examples/CMakeLists.txt
examples/CMakeLists.txt
+93
-105
examples/aout.cpp
examples/aout.cpp
+0
-1
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+163
-140
libcaf_core/caf/raise_error.hpp
libcaf_core/caf/raise_error.hpp
+13
-13
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+10
-10
libcaf_core/caf/typed_actor_view.hpp
libcaf_core/caf/typed_actor_view.hpp
+2
-2
libcaf_core/src/blocking_actor.cpp
libcaf_core/src/blocking_actor.cpp
+1
-1
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+12
-12
libcaf_core/test/custom_exception_handler.cpp
libcaf_core/test/custom_exception_handler.cpp
+3
-9
libcaf_io/CMakeLists.txt
libcaf_io/CMakeLists.txt
+46
-37
libcaf_openssl/CMakeLists.txt
libcaf_openssl/CMakeLists.txt
+38
-31
tools/CMakeLists.txt
tools/CMakeLists.txt
+11
-13
No files found.
CMakeLists.txt
View file @
7bce1d66
cmake_minimum_required
(
VERSION 3.0 FATAL_ERROR
)
cmake_minimum_required
(
VERSION 3.4 FATAL_ERROR
)
project
(
caf CXX
)
project
(
CAF CXX
)
# -- project options -----------------------------------------------------------
option
(
BUILD_SHARED_LIBS
"Build all modules as shared library"
ON
)
# -- includes ------------------------------------------------------------------
# -- includes ------------------------------------------------------------------
include
(
CMakeDependentOption
)
# Conditional default values
include
(
CMakePackageConfigHelpers
)
# For creating .cmake files
include
(
CMakePackageConfigHelpers
)
# For creating .cmake files
include
(
GNUInstallDirs
)
# Sets default install paths
include
(
GNUInstallDirs
)
# Sets default install paths
include
(
GenerateExportHeader
)
# Auto-generates dllexport macros
include
(
GenerateExportHeader
)
# Auto-generates dllexport macros
# -- general options -----------------------------------------------------------
option
(
BUILD_SHARED_LIBS
"Build shared library targets"
ON
)
option
(
CMAKE_EXPORT_COMPILE_COMMANDS
"Write JSON compile commands database"
ON
)
option
(
THREADS_PREFER_PTHREAD_FLAG
"Prefer -pthread flag if available "
ON
)
# -- CAF options that are off by default ----------------------------------------
option
(
CAF_ENABLE_CURL_EXAMPLES
"Build examples with libcurl"
OFF
)
option
(
CAF_ENABLE_PROTOBUF_EXAMPLES
"Build examples with Google Protobuf"
OFF
)
option
(
CAF_ENABLE_QT5_EXAMPLES
"Build examples with the Qt5 framework"
OFF
)
option
(
CAF_ENABLE_RUNTIME_CHECKS
"Build CAF with extra runtime assertions"
OFF
)
option
(
CAF_ENABLE_UTILITY_TARGETS
"Include targets like consistency-check"
OFF
)
option
(
CAF_ENABLE_ACTOR_PROFILER
"Enable experimental profiler API"
OFF
)
# -- CAF options that are on by default ----------------------------------------
option
(
CAF_ENABLE_EXAMPLES
"Build small programs showcasing CAF features"
ON
)
option
(
CAF_ENABLE_IO_MODULE
"Build networking I/O module"
ON
)
option
(
CAF_ENABLE_TESTING
"Build unit test suites"
ON
)
option
(
CAF_ENABLE_TOOLS
"Build utility programs such as caf-run"
ON
)
option
(
CAF_ENABLE_EXCEPTIONS
"Build CAF with support for exceptions"
ON
)
# -- CAF options that depend on others -----------------------------------------
cmake_dependent_option
(
CAF_ENABLE_OPENSSL_MODULE
"Build OpenSSL module"
ON
"CAF_ENABLE_IO_MODULE"
OFF
)
# -- CAF options with non-boolean values ---------------------------------------
set
(
CAF_LOG_LEVEL
"QUIET"
CACHE STRING
"Set log verbosity of CAF components"
)
set
(
CAF_SANITIZERS
""
CACHE STRING
"Comma separated sanitizers, e.g., 'address,undefined'"
)
set
(
CAF_INSTALL_CMAKEDIR
"
${
CMAKE_INSTALL_PREFIX
}
/
${
CMAKE_INSTALL_LIBDIR
}
/cmake/CAF"
CACHE STRING
"Path for installing CMake files, enables 'find_package(CAF)'"
)
# -- macOS-specific options ----------------------------------------------------
if
(
APPLE
)
option
(
CMAKE_MACOSX_RPATH
"Use rpaths on macOS and iOS"
ON
)
endif
()
# -- project-specific CMake settings -------------------------------------------
# -- project-specific CMake settings -------------------------------------------
set
(
CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
set
(
CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
# --
check whether we are running as CMake subdirectory
------------------------
# --
sanity checking -----------------------------------
------------------------
get_directory_property
(
_parent PARENT_DIRECTORY
)
if
(
CAF_ENABLE_OPENSSL_MODULE AND NOT CAF_ENABLE_IO_MODULE
)
if
(
_parent
)
message
(
FATAL_ERROR
"Invalid options: cannot build OpenSSL without I/O"
)
set
(
caf_is_subproject ON
)
else
()
set
(
caf_is_subproject OFF
)
endif
()
endif
()
unset
(
_parent
)
# enable tests if not disabled
set
(
CAF_VALID_LOG_LEVELS QUIET ERROR WARNING INFO DEBUG TRACE
)
if
(
NOT CAF_
NO_UNIT_TEST
S
)
if
(
NOT CAF_
LOG_LEVEL IN_LIST CAF_VALID_LOG_LEVEL
S
)
enable_testing
(
)
message
(
FATAL_ERROR
"Invalid log level:
\"
${
CAF_LOG_LEVEL
}
\"
"
)
function
(
add_test_suites executable dir
)
endif
(
)
# enumerate all test suites.
set
(
suites
""
)
# -- compiler setup ------------------------------------------------------------
foreach
(
cpp_file
${
ARGN
}
)
file
(
STRINGS
"
${
dir
}
/
${
cpp_file
}
"
contents
)
if
(
MSVC
)
foreach
(
line
${
contents
}
)
# Disable 4275 and 4251 (warnings regarding C++ classes at ABI boundaries).
if
(
"
${
line
}
"
MATCHES
"SUITE (.+)"
)
add_compile_options
(
/wd4275 /wd4251
)
string
(
REGEX REPLACE
".*SUITE (.+)"
"
\\
1"
suite
${
line
}
)
if
(
CAF_SANITIZERS
)
list
(
APPEND suites
"
${
suite
}
"
)
message
(
FATAL_ERROR
"Sanitizer builds are currently not supported on MSVC
"
)
endif
()
endif
()
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
OR CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
# Flags for both compilers.
add_compile_options
(
-ftemplate-depth=512 -ftemplate-backtrace-limit=0
-Wall -Wextra -pedantic
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
# Flags for Clang only.
add_compile_options
(
-Wdocumentation
)
else
()
# Flags for GCC only.
add_compile_options
(
-Wno-missing-field-initializers
)
endif
()
endif
()
if
(
CAF_SANITIZERS
)
add_compile_options
(
-fsanitize=
${
CAF_SANITIZERS
}
-fno-omit-frame-pointer
)
endif
()
# -- unit testing setup / caf_add_test_suites function ------------------------
if
(
CAF_ENABLE_TESTING
)
enable_testing
()
function
(
caf_add_test_suites target
)
foreach
(
suiteName
${
ARGN
}
)
string
(
REPLACE
"."
"/"
suitePath
${
suiteName
}
)
target_sources
(
${
target
}
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
suitePath
}
.cpp"
)
add_test
(
NAME
${
suiteName
}
COMMAND
${
target
}
-r300 -n -v5 -s
"^
${
suiteName
}
$"
)
endforeach
()
endforeach
()
endforeach
()
list
(
REMOVE_DUPLICATES suites
)
list
(
LENGTH suites num_suites
)
message
(
STATUS
"Found
${
num_suites
}
test suite for
${
executable
}
"
)
# creates one CMake test per test suite.
macro
(
make_test suite
)
string
(
REPLACE
" "
"_"
test_name
${
suite
}
)
add_test
(
NAME
${
test_name
}
COMMAND
${
executable
}
-r300 -n -v5 -s
"^
${
suite
}
$"
)
endmacro
()
list
(
LENGTH suites num_suites
)
foreach
(
suite
${
suites
}
)
make_test
(
"
${
suite
}
"
)
endforeach
()
endfunction
()
endfunction
()
endif
()
endif
()
# -- make sure we have at least C++17 available --------------------------------
# -- make sure we have at least C++17 available --------------------------------
# TODO: simply set CXX_STANDARD when switching to CMake ≥ 3.9.6
if
(
NOT CMAKE_CROSSCOMPILING
)
if
(
NOT CMAKE_CROSSCOMPILING
)
# Check whether the user already provided flags that enable C++ >= 17.
try_compile
(
caf_has_cxx_17
try_compile
(
caf_has_cxx_17
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/check-compiler-features.cpp"
)
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/check-compiler-features.cpp"
)
# Try enabling C++17 mode if user-provided flags aren't sufficient.
if
(
NOT caf_has_cxx_17
)
if
(
NOT caf_has_cxx_17
)
if
(
MSVC
)
if
(
MSVC
)
set
(
cxx_flag
"/std:c++17"
)
set
(
cxx_flag
"/std:c++17"
)
...
@@ -81,7 +132,7 @@ if(NOT CMAKE_CROSSCOMPILING)
...
@@ -81,7 +132,7 @@ if(NOT CMAKE_CROSSCOMPILING)
COMPILE_DEFINITIONS
"
${
cxx_flag
}
"
COMPILE_DEFINITIONS
"
${
cxx_flag
}
"
OUTPUT_VARIABLE cxx_check_output
)
OUTPUT_VARIABLE cxx_check_output
)
if
(
NOT caf_has_cxx_17
)
if
(
NOT caf_has_cxx_17
)
MESSAGE
(
FATAL_ERROR
"
\n
Fatal error: unable activate C++17 mode!\
message
(
FATAL_ERROR
"
\n
Fatal error: unable activate C++17 mode!\
\n
Please see README.md for supported compilers.\
\n
Please see README.md for supported compilers.\
\n\n
try_compile output:
\n
${
cxx_check_output
}
"
)
\n\n
try_compile output:
\n
${
cxx_check_output
}
"
)
endif
()
endif
()
...
@@ -89,113 +140,27 @@ if(NOT CMAKE_CROSSCOMPILING)
...
@@ -89,113 +140,27 @@ if(NOT CMAKE_CROSSCOMPILING)
endif
()
endif
()
endif
()
endif
()
set
(
CMAKE_INSTALL_CMAKEBASEDIR
"
${
CMAKE_INSTALL_LIBDIR
}
/cmake"
CACHE PATH
# -- set default visibility to hidden when building shared libs ----------------
"Base directory for installing cmake specific artifacts"
)
set
(
INSTALL_CAF_CMAKEDIR
"
${
CMAKE_INSTALL_CMAKEBASEDIR
}
/caf"
)
if
(
BUILD_SHARED_LIBS
)
if
(
BUILD_SHARED_LIBS
)
set
(
LINK_TYPE
"shared"
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
set
(
CMAKE_VISIBILITY_INLINES_HIDDEN yes
)
set
(
CMAKE_VISIBILITY_INLINES_HIDDEN yes
)
if
(
POLICY CMP0063
)
if
(
POLICY CMP0063
)
cmake_policy
(
SET CMP0063 NEW
)
cmake_policy
(
SET CMP0063 NEW
)
endif
()
endif
()
else
()
set
(
CAF_STATIC_BUILD yes
)
set
(
LINK_TYPE
"static"
)
endif
()
# Be nice to VIM users and Clang tools.
set
(
CMAKE_EXPORT_COMPILE_COMMANDS 1
)
# Silence policy CMP0042 warning by enabling RPATH explicitly.
if
(
APPLE AND NOT DEFINED CMAKE_MACOSX_RPATH
)
set
(
CMAKE_MACOSX_RPATH true
)
endif
()
if
(
CAF_BUILD_STATIC_RUNTIME
)
set
(
flags_configs
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
)
foreach
(
flags
${
flags_configs
}
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
OR CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
if
(
NOT
${
flags
}
MATCHES
"-static-libstdc
\\
+
\\
+"
)
set
(
${
flags
}
"
${${
flags
}}
-static-libstdc++"
)
endif
()
if
(
NOT
${
flags
}
MATCHES
"-static-libgcc"
)
set
(
${
flags
}
"
${${
flags
}}
-static-libgcc"
)
endif
()
elseif
(
MSVC
)
if
(
${
flags
}
MATCHES
"/MD"
)
string
(
REGEX REPLACE
"/MD"
"/MT"
${
flags
}
"
${${
flags
}}
"
)
endif
()
endif
()
endforeach
()
else
()
set
(
CAF_BUILD_STATIC_RUNTIME no
)
endif
()
endif
()
# add helper target that simplifies re-running configure
# -- utility targets -----------------------------------------------------------
if
(
NOT caf_is_subproject
)
add_custom_target
(
configure COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/config.status
)
endif
()
# Silence annoying MSVC warning.
if
(
CAF_ENABLE_UTILITY_TARGETS
)
if
(
MSVC
)
add_executable
(
caf-generate-enum-strings
add_compile_options
(
/wd4275 /wd4251
)
endif
()
################################################################################
# utility functions #
################################################################################
# Appends `str` to the variable named `var` with a whitespace as separator.
# Suppresses a leading whitespace if the variable is empty and does nothing if
# `str` is empty.
function
(
build_string var str
)
if
(
NOT str STREQUAL
""
)
if
(
"
${${
var
}}
"
STREQUAL
""
)
set
(
"
${
var
}
"
"
${
str
}
"
PARENT_SCOPE
)
else
()
set
(
"
${
var
}
"
"
${${
var
}}
${
str
}
"
PARENT_SCOPE
)
endif
()
endif
()
endfunction
(
build_string
)
# Forces `var` to 'no' if the content of the variables evaluates to false.
function
(
pretty_no var
)
if
(
NOT
"
${${
var
}}
"
)
set
(
"
${
var
}
"
no PARENT_SCOPE
)
endif
()
endfunction
(
pretty_no
)
# Forces `var` to 'yes' if the content of the variables evaluates to false.
function
(
pretty_yes var
)
if
(
"
${${
var
}}
"
)
set
(
"
${
var
}
"
yes PARENT_SCOPE
)
endif
()
endfunction
(
pretty_yes
)
add_executable
(
caf-generate-enum-strings
EXCLUDE_FROM_ALL
EXCLUDE_FROM_ALL
cmake/caf-generate-enum-strings.cpp
)
cmake/caf-generate-enum-strings.cpp
)
add_custom_target
(
consistency-check
)
add_custom_target
(
consistency-check
)
add_custom_target
(
update-enum-strings
)
# adds a consistency check that verifies that `cpp_file` is still valid by
add_custom_target
(
update-enum-strings
)
# re-generating the file and comparing it to the existing file
function
(
add_enum_consistency_check hpp_file cpp_file
)
# adds a consistency check that verifies that `cpp_file` is still valid by
# re-generating the file and comparing it to the existing file
function
(
add_enum_consistency_check hpp_file cpp_file
)
set
(
input
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
hpp_file
}
"
)
set
(
input
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
hpp_file
}
"
)
set
(
file_under_test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
cpp_file
}
"
)
set
(
file_under_test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
cpp_file
}
"
)
set
(
output
"
${
CMAKE_CURRENT_BINARY_DIR
}
/check/
${
cpp_file
}
"
)
set
(
output
"
${
CMAKE_CURRENT_BINARY_DIR
}
/check/
${
cpp_file
}
"
)
...
@@ -220,50 +185,25 @@ function(add_enum_consistency_check hpp_file cpp_file)
...
@@ -220,50 +185,25 @@ function(add_enum_consistency_check hpp_file cpp_file)
"
${
file_under_test
}
"
"
${
file_under_test
}
"
DEPENDS caf-generate-enum-strings
"
${
input
}
"
)
DEPENDS caf-generate-enum-strings
"
${
input
}
"
)
add_dependencies
(
update-enum-strings
"
${
target_name
}
-update"
)
add_dependencies
(
update-enum-strings
"
${
target_name
}
-update"
)
endfunction
()
endfunction
()
################################################################################
# set prefix paths if available #
################################################################################
build_string
(
"CMAKE_PREFIX_PATH"
"
${
CAF_QT_PREFIX_PATH
}
"
)
################################################################################
# make sure config parameters are printed with yes or no in summary #
################################################################################
pretty_yes
(
"CAF_FORCE_NO_EXCEPTIONS"
)
pretty_no
(
"CAF_ENABLE_RUNTIME_CHECKS"
)
pretty_no
(
"CAF_NO_MEM_MANAGEMENT"
)
pretty_no
(
"CAF_NO_EXCEPTIONS"
)
pretty_no
(
"CAF_NO_OPENSSL"
)
pretty_no
(
"CAF_NO_TOOLS"
)
pretty_no
(
"CAF_NO_SUMMARY"
)
if
(
NOT CAF_NO_IO
)
set
(
CAF_NO_IO no
)
else
()
else
()
set
(
CAF_NO_TOOLS yes
)
function
(
add_enum_consistency_check hpp_file cpp_file
)
# nop
endfunction
()
endif
()
endif
()
################################################################################
# -- get CAF version -----------------------------------------------------------
# get version of CAF #
################################################################################
# read content of config.hpp
# get line containing the version from config.hpp and extract version number
file
(
READ
"libcaf_core/caf/config.hpp"
CONFIG_HPP
)
file
(
READ
"libcaf_core/caf/config.hpp"
CAF_CONFIG_HPP
)
# get line containing the version
string
(
REGEX MATCH
"#define CAF_VERSION [0-9]+"
CAF_VERSION_LINE
"
${
CAF_CONFIG_HPP
}
"
)
string
(
REGEX MATCH
"#define CAF_VERSION [0-9]+"
VERSION_LINE
"
${
CONFIG_HPP
}
"
)
string
(
REGEX MATCH
"[0-9]+"
CAF_VERSION_INT
"
${
CAF_VERSION_LINE
}
"
)
# extract version number from line
string
(
REGEX MATCH
"[0-9]+"
VERSION_INT
"
${
VERSION_LINE
}
"
)
# calculate major, minor, and patch version
# calculate major, minor, and patch version
math
(
EXPR CAF_VERSION_MAJOR
"
${
VERSION_INT
}
/ 10000"
)
math
(
EXPR CAF_VERSION_MAJOR
"
${
CAF_
VERSION_INT
}
/ 10000"
)
math
(
EXPR CAF_VERSION_MINOR
"(
${
VERSION_INT
}
/ 100) % 100"
)
math
(
EXPR CAF_VERSION_MINOR
"(
${
CAF_
VERSION_INT
}
/ 100) % 100"
)
math
(
EXPR CAF_VERSION_PATCH
"
${
VERSION_INT
}
% 100"
)
math
(
EXPR CAF_VERSION_PATCH
"
${
CAF_
VERSION_INT
}
% 100"
)
# create full version string
# create full version string
set
(
CAF_VERSION
set
(
CAF_VERSION
"
${
CAF_VERSION_MAJOR
}
.
${
CAF_VERSION_MINOR
}
.
${
CAF_VERSION_PATCH
}
"
)
"
${
CAF_VERSION_MAJOR
}
.
${
CAF_VERSION_MINOR
}
.
${
CAF_VERSION_PATCH
}
"
)
# set the library version for our shared library targets
# set the library version for our shared library targets
if
(
CMAKE_HOST_SYSTEM_NAME MATCHES
"OpenBSD"
)
if
(
CMAKE_HOST_SYSTEM_NAME MATCHES
"OpenBSD"
)
set
(
CAF_LIB_VERSION
"
${
CAF_VERSION_MAJOR
}
.
${
CAF_VERSION_MINOR
}
"
)
set
(
CAF_LIB_VERSION
"
${
CAF_VERSION_MAJOR
}
.
${
CAF_VERSION_MINOR
}
"
)
...
@@ -271,241 +211,69 @@ else()
...
@@ -271,241 +211,69 @@ else()
set
(
CAF_LIB_VERSION
"
${
CAF_VERSION
}
"
)
set
(
CAF_LIB_VERSION
"
${
CAF_VERSION
}
"
)
endif
()
endif
()
################################################################################
# -- generate build config header ----------------------------------------------
# set output paths for binaries and libraries if not provided by the user #
################################################################################
# prohibit in-source builds
if
(
CMAKE_CURRENT_SOURCE_DIR STREQUAL
"
${
CMAKE_CURRENT_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
()
if
(
NOT XCODE
)
# set binary output path if not defined by user
if
(
NOT EXECUTABLE_OUTPUT_PATH
)
set
(
EXECUTABLE_OUTPUT_PATH
"
${
CMAKE_CURRENT_BINARY_DIR
}
/bin"
)
endif
()
# set library output path if not defined by user
if
(
NOT LIBRARY_OUTPUT_PATH
)
set
(
LIBRARY_OUTPUT_PATH
"
${
CMAKE_CURRENT_BINARY_DIR
}
/lib"
)
endif
()
endif
()
################################################################################
# compiler setup #
################################################################################
# set optional build flags
configure_file
(
"
${
PROJECT_SOURCE_DIR
}
/cmake/build_config.hpp.in"
# increase max. template depth on GCC and Clang
"
${
CMAKE_BINARY_DIR
}
/caf/detail/build_config.hpp"
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
@ONLY
)
OR CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
add_compile_options
(
"-ftemplate-depth=512"
"-ftemplate-backtrace-limit=0"
)
endif
()
# enable useful warnings by default
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
add_compile_options
(
-Wdocumentation
)
endif
()
# explicitly disable obnoxious GCC warnings
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
add_compile_options
(
-Wno-missing-field-initializers
)
endif
()
# set -fno-exception if requested
if
(
CAF_FORCE_NO_EXCEPTIONS
)
add_compile_options
(
-fno-exceptions
)
endif
()
# allow enabling IPO on gcc/clang
if
(
POLICY CMP0069
)
cmake_policy
(
SET CMP0069 NEW
)
else
()
if
(
CMAKE_INTERPROCEDURAL_OPTIMIZATION
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
add_compile_options
(
-flto
)
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
add_compile_options
(
-flto -fno-fat-lto-objects
)
endif
()
endif
()
endif
()
# enable address sanitizer if requested by the user
if
(
CAF_SANITIZERS
)
add_compile_options
(
"-fsanitize=
${
CAF_SANITIZERS
}
"
"-fno-omit-frame-pointer"
)
list
(
APPEND CAF_EXTRA_LDFLAGS
"-fsanitize=
${
CAF_SANITIZERS
}
"
)
endif
()
# -pthread is ignored on MacOSX but required on other platforms
if
(
NOT APPLE AND NOT WIN32
)
add_compile_options
(
-pthread
)
list
(
APPEND CAF_EXTRA_LDFLAGS
"-pthread"
)
endif
()
# -fPIC generates warnings on MinGW and Cygwin plus extra setup steps needed on MinGW
if
(
MINGW
)
add_definitions
(
-D_WIN32_WINNT=0x0600 -DWIN32
)
list
(
APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi
)
# build static to avoid runtime dependencies to GCC libraries
add_compile_options
(
-static
)
elseif
(
CYGWIN
)
add_compile_options
(
-U__STRICT_ANSI__
)
endif
()
if
(
WIN32
)
list
(
APPEND CAF_EXTRA_LDFLAGS ws2_32 iphlpapi
)
endif
()
# iOS support
# -- install testing DSL headers -----------------------------------------------
if
(
CAF_OSX_SYSROOT
)
set
(
CMAKE_OSX_SYSROOT
"
${
CAF_OSX_SYSROOT
}
"
)
endif
()
if
(
CAF_IOS_DEPLOYMENT_TARGET
)
if
(
CAF_OSX_SYSROOT STREQUAL
"iphonesimulator"
)
add_compile_options
(
"-mios-simulator-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
else
()
add_compile_options
(
"-miphoneos-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
endif
()
endif
()
#
###############################################################################
#
install includes from test
# setup logging #
install
(
DIRECTORY libcaf_test/caf/ DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/caf
################################################################################
FILES_MATCHING PATTERN
"*.hpp"
)
# make sure log level is defined and all-uppercase
add_library
(
libcaf_test INTERFACE
)
if
(
NOT CAF_LOG_LEVEL
)
set
(
CAF_LOG_LEVEL
"QUIET"
)
else
()
string
(
TOUPPER
"
${
CAF_LOG_LEVEL
}
"
CAF_LOG_LEVEL
)
endif
()
set
(
validLogLevels QUIET ERROR WARNING INFO DEBUG TRACE
)
target_include_directories
(
libcaf_test INTERFACE
list
(
FIND validLogLevels
"
${
CAF_LOG_LEVEL
}
"
logLevelIndex
)
$<BUILD_INTERFACE:
${
PROJECT_SOURCE_DIR
}
/libcaf_test>
)
if
(
logLevelIndex LESS 0
)
MESSAGE
(
FATAL_ERROR
"Invalid log level:
\"
${
CAF_LOG_LEVEL
}
\"
"
)
endif
()
################################################################################
add_library
(
CAF::test ALIAS libcaf_test
)
# setup for install target #
################################################################################
# install includes from test
# -- provide an uinstall target ------------------------------------------------
install
(
DIRECTORY libcaf_test/caf/ DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/caf
FILES_MATCHING PATTERN
"*.hpp"
)
# process cmake_uninstall.cmake.in
# process cmake_uninstall.cmake.in
configure_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/cmake_uninstall.cmake.in"
configure_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/cmake_uninstall.cmake.in"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
IMMEDIATE @ONLY
)
# add uninstall target if it does not exist yet
# add uninstall target if it does not exist yet
if
(
NOT TARGET uninstall
)
if
(
NOT TARGET uninstall
)
add_custom_target
(
uninstall
)
add_custom_target
(
uninstall
)
endif
()
endif
()
add_custom_command
(
TARGET uninstall
add_custom_command
(
TARGET uninstall
PRE_BUILD
PRE_BUILD
COMMAND
"
${
CMAKE_COMMAND
}
"
-P
COMMAND
"
${
CMAKE_COMMAND
}
"
-P
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
)
# -- set include paths for subprojects -----------------------------------------
# -- build all components the user asked for -----------------------------------
configure_file
(
"
${
PROJECT_SOURCE_DIR
}
/cmake/build_config.hpp.in"
"
${
CMAKE_BINARY_DIR
}
/caf/detail/build_config.hpp"
@ONLY
)
# -- set include paths for all subprojects -------------------------------------
add_subdirectory
(
libcaf_core
)
include_directories
(
"
${
CMAKE_BINARY_DIR
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_core"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_io"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_test"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_openssl"
)
################################################################################
if
(
CAF_ENABLE_IO_MODULE
)
# add targets #
add_subdirectory
(
libcaf_io
)
################################################################################
endif
()
macro
(
add_optional_caf_lib name
)
if
(
CAF_ENABLE_OPENSSL_MODULE
)
string
(
TOUPPER
${
name
}
upper_name
)
add_subdirectory
(
libcaf_openssl
)
set
(
flag_varname CAF_NO_
${
upper_name
}
)
endif
()
if
(
NOT
${
flag_varname
}
AND EXISTS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_
${
name
}
/CMakeLists.txt"
)
add_subdirectory
(
"libcaf_
${
name
}
"
)
else
()
set
(
${
flag_varname
}
yes
)
endif
()
endmacro
()
macro
(
add_optional_caf_binaries name
)
string
(
TOUPPER
${
name
}
upper_name
)
set
(
dependency_failed no
)
# check all additional dependency flags
foreach
(
flag_name
${
ARGN
}
)
if
(
${
flag_name
}
)
set
(
dependency_failed yes
)
endif
()
endforeach
()
if
(
NOT dependency_failed
)
if
(
NOT CAF_NO_
${
upper_name
}
AND EXISTS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
name
}
/CMakeLists.txt"
)
add_subdirectory
(
${
name
}
)
else
()
# make sure variable is set for nicer build log
set
(
CAF_NO_
${
upper_name
}
yes
)
endif
()
else
()
message
(
STATUS
"Disable
${
name
}
, one of the following flags was set:
${
ARGN
}
"
)
# make sure variable is set for nicer build log
set
(
CAF_NO_
${
upper_name
}
yes
)
endif
()
endmacro
()
# build core and I/O library
if
(
CAF_ENABLE_EXAMPLES
)
add_subdirectory
(
libcaf_core
)
add_subdirectory
(
examples
)
add_optional_caf_lib
(
io
)
# build SSL module if OpenSSL library is available
if
(
NOT CAF_NO_OPENSSL
)
find_package
(
OpenSSL
)
if
(
OPENSSL_FOUND
)
# Check OpenSSL version >= 1.0.1
if
(
OPENSSL_VERSION VERSION_LESS 1.0.1
)
message
(
STATUS
"Disable OpenSSL. Required >= 1.0.1 due to TLSv1.2 support."
)
set
(
CAF_NO_OPENSSL yes
)
else
()
if
(
NOT CMAKE_CROSSCOMPILING
)
# Check if openssl headers and library versions match
try_run
(
sslRunResult sslCompileResult
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/openssl-check.cpp"
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=
${
OPENSSL_INCLUDE_DIR
}
"
LINK_LIBRARIES
${
OPENSSL_LIBRARIES
}
OUTPUT_VARIABLE sslOutput
)
if
(
NOT sslCompileResult
)
message
(
FATAL_ERROR
"failed to compile/link against OpenSSL"
)
endif
()
if
(
NOT sslRunResult EQUAL 0
)
message
(
FATAL_ERROR
"OpenSSL version does not match headers:
${
sslOutput
}
"
)
endif
()
endif
()
include_directories
(
BEFORE
${
OPENSSL_INCLUDE_DIR
}
)
add_optional_caf_lib
(
openssl
)
endif
()
else
(
OPENSSL_FOUND
)
set
(
CAF_NO_OPENSSL yes
)
endif
(
OPENSSL_FOUND
)
endif
()
endif
()
# build examples if not being told otherwise
if
(
CAF_ENABLE_TOOLS
)
add_optional_caf_binaries
(
examples
)
add_subdirectory
(
tools
)
endif
()
# build tools if not being told otherwise
# -- generate and install .cmake files -----------------------------------------
add_optional_caf_binaries
(
tools
)
export
(
EXPORT CAFTargets FILE CAFTargets.cmake NAMESPACE
caf
::
)
export
(
EXPORT CAFTargets FILE CAFTargets.cmake NAMESPACE
CAF
::
)
install
(
EXPORT CAFTargets
install
(
EXPORT CAFTargets
DESTINATION
"
${
INSTALL_CAF
_CMAKEDIR
}
"
DESTINATION
"
${
CAF_INSTALL
_CMAKEDIR
}
"
NAMESPACE
caf
::
)
NAMESPACE
CAF
::
)
write_basic_package_version_file
(
write_basic_package_version_file
(
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
...
@@ -514,74 +282,12 @@ write_basic_package_version_file(
...
@@ -514,74 +282,12 @@ write_basic_package_version_file(
configure_package_config_file
(
configure_package_config_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/CAFConfig.cmake.in"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/CAFConfig.cmake.in"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
INSTALL_DESTINATION
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
"
${
INSTALL_CAF
_CMAKEDIR
}
"
)
INSTALL_DESTINATION
"
${
CAF_INSTALL
_CMAKEDIR
}
"
)
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
DESTINATION
"
${
INSTALL_CAF_CMAKEDIR
}
"
)
DESTINATION
"
${
CAF_INSTALL_CMAKEDIR
}
"
)
################################################################################
# Add additional project files to GUI #
################################################################################
file
(
GLOB_RECURSE script_files
"scripts/*"
)
add_custom_target
(
gui_dummy SOURCES configure
${
script_files
}
)
################################################################################
# print summary #
################################################################################
# little helper macro to invert a boolean
macro
(
invertYesNo in out
)
if
(
${
in
}
)
set
(
${
out
}
no
)
else
()
set
(
${
out
}
yes
)
endif
()
endmacro
()
# invert CAF_NO_* variables for nicer output
invertYesNo
(
CAF_NO_IO CAF_BUILD_IO
)
invertYesNo
(
CAF_NO_EXAMPLES CAF_BUILD_EXAMPLES
)
invertYesNo
(
CAF_NO_TOOLS CAF_BUILD_TOOLS
)
invertYesNo
(
CAF_NO_UNIT_TESTS CAF_BUILD_UNIT_TESTS
)
invertYesNo
(
CAF_NO_EXCEPTIONS CAF_BUILD_WITH_EXCEPTIONS
)
invertYesNo
(
CAF_NO_MEM_MANAGEMENT CAF_BUILD_MEM_MANAGEMENT
)
invertYesNo
(
CAF_NO_OPENSSL CAF_BUILD_OPENSSL
)
if
(
GENERATOR_IS_MULTI_CONFIG
)
set
(
summary_build_type
"Multi-Config"
)
else
()
set
(
summary_build_type
"
${
CMAKE_BUILD_TYPE
}
"
)
endif
()
# done
if
(
NOT CAF_NO_SUMMARY
)
message
(
STATUS
"
\n
====================| Build Summary |===================="
"
\n
"
"
\n
CAF version:
${
CAF_VERSION
}
"
"
\n
"
"
\n
CXX:
${
CMAKE_CXX_COMPILER
}
"
"
\n
Build type:
${
summary_build_type
}
"
"
\n
Link type:
${
LINK_TYPE
}
"
"
\n
Build static runtime:
${
CAF_BUILD_STATIC_RUNTIME
}
"
"
\n
Runtime checks:
${
CAF_ENABLE_RUNTIME_CHECKS
}
"
"
\n
Log level:
${
CAF_LOG_LEVEL
}
"
"
\n
With mem. mgmt.:
${
CAF_BUILD_MEM_MANAGEMENT
}
"
"
\n
With exceptions:
${
CAF_BUILD_WITH_EXCEPTIONS
}
"
"
\n
"
"
\n
Build I/O module:
${
CAF_BUILD_IO
}
"
"
\n
Build OpenSSL module:
${
CAF_BUILD_OPENSSL
}
"
"
\n
Build tools:
${
CAF_BUILD_TOOLS
}
"
"
\n
Build examples:
${
CAF_BUILD_EXAMPLES
}
"
"
\n
Build unit tests:
${
CAF_BUILD_UNIT_TESTS
}
"
"
\n
"
"
\n
"
"
\n
Source directory:
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
\n
Build directory:
${
CMAKE_CURRENT_BINARY_DIR
}
"
"
\n
Executable path:
${
EXECUTABLE_OUTPUT_PATH
}
"
"
\n
Library path:
${
LIBRARY_OUTPUT_PATH
}
"
"
\n
Install prefix:
${
CMAKE_INSTALL_PREFIX
}
"
"
\n
Generator:
${
CMAKE_GENERATOR
}
"
"
\n
"
"
\n
===========================================================
\n
"
)
endif
()
Jenkinsfile
View file @
7bce1d66
...
@@ -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
,
...
...
cmake/build_config.hpp.in
View file @
7bce1d66
...
@@ -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
configure
View file @
7bce1d66
#!/bin/sh
#!/bin/sh
# Convenience wrapper for easily viewing/setting options that
set
-e
# the project's CMake scripts will recognize.
command
=
"
$0
$*
"
# Convenience wrapper for easily setting options that the project's CMake
dirname_0
=
`
dirname
$0
`
# scripts will recognize.
sourcedir
=
`
cd
$dirname_0
&&
pwd
`
Command
=
"
$0
$*
"
CommandDirname
=
`
dirname
$0
`
SourceDir
=
`
cd
$CommandDirname
&&
pwd
`
usage
=
"
\
usage
=
"
\
Usage:
$0
[OPTION]... [VAR=VALUE]...
Usage:
$0
[--<variable>=<value>...]
General CMake options:
Build Options:
--cmake=PATH set a custom path to the CMake binary
--cmake=PATH set a custom path to the CMake binary
--generator=GENERATOR set CMake generator (see cmake --help)
--build-dir=PATH set build directory [build]
--build-type=TYPE set CMake build type [RelWithDebInfo]:
--build-type=STRING set build type of single-configuration generators
- Debug: debugging flags enabled
--generator=STRING set CMake generator (see cmake --help)
- MinSizeRel: minimal output size
--cxx-flags=STRING set CMAKE_CXX_FLAGS when running CMake
- Release: optimizations on, debugging off
--prefix=PATH set installation directory
- RelWithDebInfo: release flags plus debugging
--extra-flags=STRING additional compiler flags (sets CMAKE_CXX_FLAGS)
--build-dir=DIR place build files in directory [build]
--bin-dir=DIR executable directory [build/bin]
--lib-dir=DIR library directory [build/lib]
--with-clang=FILE path to clang++ executable
--with-gcc=FILE path to g++ executable
--with-qt-prefix=PATH prefix path for Qt5 cmake modules
--with-openssl=PATH path to OpenSSL library and headers
--dual-build build using both gcc and clang
--build-static build as static library
--static-runtime build with static C++ runtime
--no-compiler-check disable compiler version check
--no-auto-libc++ do not automatically enable libc++ for Clang
--no-exceptions do not catch exceptions in CAF
--force-no-exceptions build CAF with '-fno-exceptions'
--warnings-as-errors build with '-Werror'
Optional Targets:
Locating packages in non-standard locations:
--with-qt-examples build Qt example(s)
--with-protobuf-examples build Google Protobuf example(s)
Installation Directories:
--openssl-root-dir=PATH set root directory of an OpenSSL installation
--prefix=PREFIX installation directory [/usr/local]
Remove Standard Features (even if all dependencies are available):
Debugging options:
--no-memory-management build without memory management
--no-examples build without examples
--no-curl-examples build without libcurl examples
--no-unit-tests build without unit tests
--no-openssl build without OpenSSL module
--no-tools build without CAF tools such as caf-run
--no-io build without I/O module
--no-summary do not print configuration before building
--libs-only sets no-examples, no-tools and no-unit-tests
--core-only same as libs-only but also adds sets
no-openssl, and no-io
Debugging:
--log-level=STRING build with debugging output, possible values:
--with-runtime-checks build with requirement checks at runtime
--with-log-level=LVL build with debugging output, possible values:
- ERROR
- ERROR
- WARNING
- WARNING
- INFO
- INFO
- DEBUG
- DEBUG
- TRACE
- TRACE
--with-sanitizers=LIST build with this list of sanitizers enabled
--sanitizers=STRING build with this list of sanitizers enabled
--with-actor-profiler enables the (experimental) actor_profiler API
Convenience options:
Convenience options:
--dev-mode sets --build-type=debug, --no-examples,
--dev-mode shortcut for passing:
--no-tools, --with-runtime-checks,
--build-type=Debug
--log-level=trace, and
--log-level=TRACE
--with-sanitizers=address,undefined
--sanitizers=address,undefined
--disable-examples
--disable-tools
--enable-utility-targets
--enable-runtime-checks
Flags (use --enable-<name> to activate and --disable-<name> to deactivate):
shared-libs build shared library targets [ON]
export-compile-commands write JSON compile commands database [ON]
prefer-pthread-flag prefer -pthread flag if available [ON]
curl-examples build examples with libcurl [OFF]
protobuf-examples build examples with Google Protobuf [OFF]
qt5-examples build examples with the Qt5 framework [OFF]
runtime-checks build CAF with extra runtime assertions [OFF]
utility-targets include targets like consistency-check [OFF]
actor-profiler enable experimental proiler API [OFF]
examples build small programs showcasing CAF features [ON]
io-module build networking I/O module [ON]
openssl-module build OpenSSL module [ON]
testing build unit test suites [ON]
tools build utility programs such as caf-run [ON]
with-exceptions build CAF with support for exceptions [ON]
Influential Environment Variables (only on first invocation):
Influential Environment Variables (only on first invocation):
CXX C++ compiler command
CXX C++ compiler command
CXXFLAGS C++ compiler flags (overrides defaults)
CXXFLAGS Additional C++ compiler flags
LDFLAGS Additional linker flags
LDFLAGS Additional linker flags
CMAKE_GENERATOR Selects a custom generator
CMAKE_GENERATOR Selects a custom generator
iOS Build Options (should be used with XCode generator):
--sysroot=DIR set system root for Clang
- iphoneos: for iOS device
- iphonesimulator: for iOS simulator
--ios-min-ver=VERSION set the ios deployment target version
"
"
# Appends a CMake cache entry definition to the CMakeCacheEntries variable.
# Appends a CMake cache entry definition to the CMakeCacheEntries variable.
# $1 is the cache entry variable name
# $1: variable name
# $2 is the cache entry variable type
# $2: CMake type
# $3 is the cache entry variable value
# $3: value
append_cache_entry
()
append_cache_entry
()
{
{
case
"
$3
"
in
case
"
$3
"
in
*
\
*
)
*
\
*
)
# string contains whitespace
# string contains whitespace
CMakeCacheEntries
=
"
$CMakeCacheEntries
-D
\"
$1
:
$2
=
$3
\"
"
CMakeCacheEntries
=
"
$CMakeCacheEntries
-D
\"
$1
:
$2
=
$3
\"
"
;;
;;
*
)
*
)
# string contains
whitespace
# string contains no
whitespace
CMakeCacheEntries
=
"
$CMakeCacheEntries
-D
$1
:
$2
=
$3
"
CMakeCacheEntries
=
"
$CMakeCacheEntries
-D
$1
:
$2
=
$3
"
;;
;;
esac
esac
}
}
# Creates a build directory via CMake.
# Appends a BOOL cache entry to the CMakeCacheEntries variable.
# $1 is the path to a compiler executable.
# $1: flag name
# $2 is the suffix of the build directory.
# $2: value (ON or OFF)
# $3 is the executable output path.
set_build_flag
()
{
# $4 is the library output path.
FlagName
=
''
# $5 is the CMake generator.
case
"
$1
"
in
configure
()
shared-libs
)
FlagName
=
'BUILD_SHARED_LIBS'
;;
{
export-compile-commands
)
FlagName
=
'CMAKE_EXPORT_COMPILE_COMMANDS'
;;
prefer-pthread-flag
)
FlagName
=
'THREADS_PREFER_PTHREAD_FLAG'
;;
CMakeCacheEntries
=
$CMakeDefaultCache
curl-examples
)
FlagName
=
'CAF_ENABLE_CURL_EXAMPLES'
;;
protobuf-examples
)
FlagName
=
'CAF_ENABLE_PROTOBUF_EXAMPLES'
;;
if
[
-n
"
$1
"
]
;
then
qt5-examples
)
FlagName
=
'CAF_ENABLE_QT5_EXAMPLES'
;;
append_cache_entry CMAKE_CXX_COMPILER FILEPATH
$1
runtime-checks
)
FlagName
=
'CAF_ENABLE_RUNTIME_CHECKS'
;;
fi
utility-targets
)
FlagName
=
'CAF_ENABLE_UTILITY_TARGETS'
;;
actor-profiler
)
FlagName
=
'CAF_ENABLE_ACTOR_PROFILER'
;;
case
"
$builddir
"
in
examples
)
FlagName
=
'CAF_ENABLE_EXAMPLES'
;;
/
*
)
io-module
)
FlagName
=
'CAF_ENABLE_IO_MODULE'
;;
#absolute path given
openssl-module
)
FlagName
=
'CAF_ENABLE_OPENSSL_MODULE'
;;
absolute_builddir
=
"
$builddir
"
testing
)
FlagName
=
'CAF_ENABLE_TESTING'
;;
;;
tools
)
FlagName
=
'CAF_ENABLE_TOOLS'
;;
exceptions
)
FlagName
=
'CAF_ENABLE_EXCEPTIONS'
;;
*
)
*
)
# relative path given; convert to absolute path
echo
"Invalid flag '
$1
'. Try
$0
--help to see available options."
absolute_builddir
=
"
$PWD
/
$builddir
"
exit
1
;;
;;
esac
esac
append_cache_entry
$FlagName
BOOL
$2
if
[
-n
"
$2
"
]
;
then
workdir
=
"
$absolute_builddir
-
$2
"
else
workdir
=
"
$absolute_builddir
"
fi
workdirs
=
"
$workdirs
$workdir
"
if
[
-n
"
$3
"
]
;
then
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH
"
$3
"
else
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH
"
$workdir
/bin"
fi
if
[
-n
"
$4
"
]
;
then
append_cache_entry LIBRARY_OUTPUT_PATH PATH
"
$4
"
else
append_cache_entry LIBRARY_OUTPUT_PATH PATH
"
$workdir
/lib"
fi
if
[
-d
"
$workdir
"
]
;
then
# If a build directory exists, check if it has a CMake cache.
if
[
-f
"
$workdir
/CMakeCache.txt"
]
;
then
# If the CMake cache exists, delete it so that this configuration
# is not tainted by a previous one.
rm
-f
"
$workdir
/CMakeCache.txt"
fi
else
mkdir
-p
"
$workdir
"
fi
cd
"
$workdir
"
if
[
-n
"
$5
"
]
;
then
"
$CMakeCommand
"
-G
"
$5
"
$CMakeCacheEntries
"
$sourcedir
"
else
"
$CMakeCommand
"
$CMakeCacheEntries
"
$sourcedir
"
fi
printf
"#!/bin/sh
\n\n
"
>
config.status
printf
"# Switch to the source of this build directory.
\n
"
>>
config.status
printf
"cd
\"
$sourcedir
\"\n\n
"
>>
config.status
printf
"# Invoke the command to configure this build.
\n
"
>>
config.status
if
[
-n
"
$CC
"
]
;
then
printf
"CC=
\"
%s
\"\n
"
"
$CC
"
>>
config.status
fi
if
[
-n
"
$CXX
"
]
;
then
printf
"CXX=
\"
%s
\"\n
"
"
$CXX
"
>>
config.status
fi
if
[
-n
"
$CXXFLAGS
"
]
;
then
printf
"CXXFLAGS=
\"
%s
\"\n
"
"
$CXXFLAGS
"
>>
config.status
fi
if
[
-n
"
$LDFLAGS
"
]
;
then
printf
"LDFLAGS=
\"
%s
\"\n
"
"
$LDFLAGS
"
>>
config.status
fi
echo
$command
>>
config.status
chmod
u+x config.status
}
}
# Set defaults.
# Set defaults.
builddir
=
"
$sourced
ir
/build"
CMakeBuildDir
=
"
$SourceD
ir
/build"
CMakeCacheEntries
=
""
CMakeCacheEntries
=
""
append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local
append_cache_entry CAF_ENABLE_RUNTIME_CHECKS BOOL
false
# parse custom environment variable to initialize CMakeGenerator
if
[
-n
"
$CMAKE_GENERATOR
"
]
;
then
CMakeGenerator
=
"
$CMAKE_GENERATOR
"
fi
# Parse
arguments
.
# Parse
user input
.
while
[
$#
-ne
0
]
;
do
while
[
$#
-ne
0
]
;
do
# Fetch the option argument.
case
"
$1
"
in
case
"
$1
"
in
-
*
=
*
)
optarg
=
`
echo
"
$1
"
|
sed
's/[-_a-zA-Z0-9]*=//'
`
;;
--
*
=
*
)
optarg
=
`
echo
"
$1
"
|
sed
's/[-_a-zA-Z0-9]*=//'
`
;;
*
)
optarg
=
;;
--enable-
*
)
optarg
=
`
echo
"
$1
"
|
sed
's/--enable-//'
`
;;
--disable-
*
)
optarg
=
`
echo
"
$1
"
|
sed
's/--disable-//'
`
;;
*
)
;;
esac
esac
# Consume current input.
case
"
$1
"
in
case
"
$1
"
in
--help
|
-h
)
--help
|
-h
)
echo
"
${
usage
}
"
1>&2
echo
"
${
usage
}
"
1>&2
...
@@ -213,139 +141,58 @@ while [ $# -ne 0 ]; do
...
@@ -213,139 +141,58 @@ while [ $# -ne 0 ]; do
--cmake
=
*
)
--cmake
=
*
)
CMakeCommand
=
"
$optarg
"
CMakeCommand
=
"
$optarg
"
;;
;;
--build-dir
=
*
)
CMakeBuildDir
=
"
$optarg
"
;;
--generator
=
*
)
--generator
=
*
)
CMakeGenerator
=
"
$optarg
"
CMakeGenerator
=
"
$optarg
"
;;
;;
--build-type
=
*
)
CMakeBuildType
=
"
$optarg
"
;;
--cxx-flags
=
*
)
append_cache_entry CMAKE_CXX_FLAGS STRING
"
$optarg
"
;;
--prefix
=
*
)
--prefix
=
*
)
append_cache_entry CMAKE_INSTALL_PREFIX PATH
"
$optarg
"
append_cache_entry CMAKE_INSTALL_PREFIX PATH
"
$optarg
"
;;
;;
--with-runtime-checks
)
--log-level
=
*
)
append_cache_entry CAF_ENABLE_RUNTIME_CHECKS BOOL
yes
append_cache_entry CAF_LOG_LEVEL STRING
"
$optarg
"
;;
;;
--with
-sanitizers
=
*
)
-
-sanitizers
=
*
)
append_cache_entry CAF_SANITIZERS STRING
"
$optarg
"
append_cache_entry CAF_SANITIZERS STRING
"
$optarg
"
;;
;;
--with-actor-profiler
)
--dev-mode
)
append_cache_entry CAF_ENABLE_ACTOR_PROFILER BOOL
yes
;;
--no-memory-management
)
append_cache_entry CAF_NO_MEM_MANAGEMENT BOOL
yes
;;
--no-compiler-check
)
append_cache_entry CAF_NO_COMPILER_CHECK BOOL
yes
;;
--no-auto-libc
++
)
append_cache_entry CAF_NO_AUTO_LIBCPP BOOL
yes
;;
--no-exceptions
)
append_cache_entry CAF_NO_EXCEPTIONS BOOL
yes
;;
--force-no-exceptions
)
append_cache_entry CAF_NO_EXCEPTIONS BOOL
yes
append_cache_entry CAF_FORCE_NO_EXCEPTIONS BOOL
yes
;;
--sysroot
=
*
)
append_cache_entry CAF_OSX_SYSROOT PATH
"
$optarg
"
;;
--ios-min-ver
=
*
)
append_cache_entry CMAKE_OSX_ARCHITECTURES STRING
"
\$
(ARCHS_STANDARD_32_64_BIT)"
append_cache_entry CAF_IOS_DEPLOYMENT_TARGET STRING
"
$optarg
"
;;
--with-log-level
=
*
)
append_cache_entry CAF_LOG_LEVEL STRING
"
$optarg
"
append_cache_entry CAF_LOG_LEVEL STRING
"
$optarg
"
CMakeBuildType
=
'Debug'
append_cache_entry CAF_LOG_LEVEL STRING
'TRACE'
append_cache_entry CAF_SANITIZERS STRING
'address,undefined'
set_build_flag examples OFF
set_build_flag tools OFF
set_build_flag utility-targets ON
set_build_flag runtime-checks ON
;;
;;
--with-clang
=
*
)
--enable-
*
)
clang
=
"
$optarg
"
set_build_flag
$optarg
ON
;;
--with-gcc
=
*
)
gcc
=
"
$optarg
"
;;
;;
--with-qt-prefix
=
*
)
--disable-
*
)
append_cache_entry CAF_QT_PREFIX_PATH STRING
"
$optarg
"
set_build_flag
$optarg
OFF
;;
;;
--with-openssl
=
*
)
--openssl-root-dir
=
*
)
append_cache_entry OPENSSL_ROOT_DIR PATH
"
$optarg
"
append_cache_entry OPENSSL_ROOT_DIR PATH
"
$optarg
"
;;
;;
--build-type
=
*
)
append_cache_entry CMAKE_BUILD_TYPE STRING
"
$optarg
"
;;
--extra-flags
=
*
)
append_cache_entry CMAKE_CXX_FLAGS STRING
"
$optarg
"
;;
--build-dir
=
*
)
builddir
=
"
$optarg
"
;;
--bin-dir
=
*
)
bindir
=
"
$optarg
"
;;
--lib-dir
=
*
)
libdir
=
"
$optarg
"
;;
--dual-build
)
dualbuild
=
1
;;
--no-examples
)
append_cache_entry CAF_NO_EXAMPLES BOOL
yes
;;
--with-qt-examples
)
append_cache_entry CAF_BUILD_QT_EXAMPLES BOOL
yes
;;
--with-protobuf-examples
)
append_cache_entry CAF_BUILD_PROTOBUF_EXAMPLES BOOL
yes
;;
--no-curl-examples
)
append_cache_entry CAF_NO_CURL_EXAMPLES BOOL
yes
;;
--no-unit-tests
)
append_cache_entry CAF_NO_UNIT_TESTS BOOL
yes
;;
--no-openssl
)
append_cache_entry CAF_NO_OPENSSL BOOL
yes
;;
--build-static
)
append_cache_entry BUILD_SHARED_LIBS BOOL no
;;
--static-runtime
)
append_cache_entry CAF_BUILD_STATIC_RUNTIME BOOL
yes
;;
--no-tools
)
append_cache_entry CAF_NO_TOOLS BOOL
yes
;;
--no-io
)
append_cache_entry CAF_NO_IO BOOL
yes
;;
--no-summary
)
append_cache_entry CAF_NO_SUMMARY BOOL
yes
;;
--libs-only
)
for
var
in
CAF_NO_TOOLS CAF_NO_EXAMPLES CAF_NO_UNIT_TESTS
;
do
append_cache_entry
$var
BOOL
yes
done
;;
--core-only
)
for
var
in
CAF_NO_TOOLS CAF_NO_EXAMPLES CAF_NO_UNIT_TESTS CAF_NO_IO CAF_NO_OPENSSL
;
do
append_cache_entry
$var
BOOL
yes
done
;;
--dev-mode
)
for
var
in
CAF_NO_TOOLS CAF_NO_EXAMPLES CAF_ENABLE_RUNTIME_CHECKS
;
do
append_cache_entry
$var
BOOL
yes
done
append_cache_entry CMAKE_BUILD_TYPE STRING Debug
append_cache_entry CAF_LOG_LEVEL STRING TRACE
append_cache_entry CAF_SANITIZERS STRING address,undefined
;;
*
)
*
)
echo
"Invalid option '
$1
'. Try
$0
--help to see available options."
echo
"Invalid option '
$1
'. Try
$0
--help to see available options."
exit
1
exit
1
;;
;;
esac
esac
# Get next input.
shift
shift
done
done
# Check for `cmake` command.
# Check for `cmake` command.
if
[
-z
"
$CMakeCommand
"
]
;
then
if
[
-z
"
$CMakeCommand
"
]
;
then
# prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL)
# Prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL).
if
command
-v
cmake3
>
/dev/null 2>&1
;
then
if
command
-v
cmake3
>
/dev/null 2>&1
;
then
CMakeCommand
=
"cmake3"
CMakeCommand
=
"cmake3"
elif
command
-v
cmake
>
/dev/null 2>&1
;
then
elif
command
-v
cmake
>
/dev/null 2>&1
;
then
...
@@ -354,34 +201,50 @@ if [ -z "$CMakeCommand" ]; then
...
@@ -354,34 +201,50 @@ if [ -z "$CMakeCommand" ]; then
echo
"This package requires CMake, please install it first."
echo
"This package requires CMake, please install it first."
echo
"Then you may use this script to configure the CMake build."
echo
"Then you may use this script to configure the CMake build."
echo
"Note: pass --cmake=PATH to use cmake in non-standard locations."
echo
"Note: pass --cmake=PATH to use cmake in non-standard locations."
exit
1
;
exit
1
fi
fi
fi
fi
# At this point we save the global CMake variables so that configure() can
# Make sure the build directory is an absolute path.
# later use them.
case
"
$CMakeBuildDir
"
in
CMakeDefaultCache
=
$CMakeCacheEntries
/
*
)
CMakeAbsoluteBuildDir
=
"
$CMakeBuildDir
"
;;
*
)
CMakeAbsoluteBuildDir
=
"
$PWD
/
$CMakeBuildDir
"
;;
esac
if
[
-n
"
$dualbuild
"
]
;
then
# If a build directory exists, delete any existing cache to have a clean build.
# Use what we got in $PATH if --with-clang or --with-gcc is not specified.
if
[
-d
"
$CMakeAbsoluteBuildDir
"
]
;
then
if
[
-z
"
$clang
"
]
;
then
if
[
-f
"
$CMakeAbsoluteBuildDir
/CMakeCache.txt"
]
;
then
clang
=
clang++
rm
-f
"
$CMakeAbsoluteBuildDir
/CMakeCache.txt"
fi
if
[
-z
"
$gcc
"
]
;
then
gcc
=
g++
fi
fi
else
mkdir
-p
"
$CMakeAbsoluteBuildDir
"
fi
for
i
in
gcc clang
;
do
# Run CMake.
eval
"compiler=
\$
$i
"
cd
"
$CMakeAbsoluteBuildDir
"
configure
$compiler
$i
""
""
$CMakeGenerator
if
[
-n
"
$CMakeGenerator
"
]
;
then
done
"
$CMakeCommand
"
-G
"
$CMakeGenerator
"
$CMakeCacheEntries
"
$SourceDir
"
else
else
# Prefer Clang to GCC.
"
$CMakeCommand
"
$CMakeCacheEntries
"
$SourceDir
"
if
[
-n
"
$clang
"
]
;
then
fi
compiler
=
$clang
elif
[
-n
"
$gcc
"
]
;
then
compiler
=
$gcc
fi
configure
"
$compiler
"
""
"
$bindir
"
"
$libdir
"
"
$CMakeGenerator
"
# Generate a config.status file that allows re-running a clean build.
printf
"#!/bin/sh
\n\n
"
>
config.status
printf
"# Switch to the source of this build directory.
\n
"
>>
config.status
printf
"cd
\"
%s
\"\n\n
"
"
$CMakeAbsoluteBuildDir
"
>>
config.status
printf
"# Invoke the command to configure this build.
\n
"
>>
config.status
if
[
-n
"
$CXX
"
]
;
then
printf
"CXX=
\"
%s
\"\n
"
"
$CXX
"
>>
config.status
fi
if
[
-n
"
$CXXFLAGS
"
]
;
then
printf
"CXXFLAGS=
\"
%s
\"\n
"
"
$CXXFLAGS
"
>>
config.status
fi
if
[
-n
"
$LDFLAGS
"
]
;
then
printf
"LDFLAGS=
\"
%s
\"\n
"
"
$LDFLAGS
"
>>
config.status
fi
fi
echo
$Command
>>
config.status
chmod
u+x config.status
examples/CMakeLists.txt
View file @
7bce1d66
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
()
examples/aout.cpp
View file @
7bce1d66
...
@@ -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
;
...
...
libcaf_core/CMakeLists.txt
View file @
7bce1d66
...
@@ -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
()
libcaf_core/caf/raise_error.hpp
View file @
7bce1d66
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "caf/config.hpp"
#include "caf/config.hpp"
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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 un
defined, 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 un
defined, 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__)
...
...
libcaf_core/caf/scheduled_actor.hpp
View file @
7bce1d66
...
@@ -20,9 +20,9 @@
...
@@ -20,9 +20,9 @@
#include "caf/config.hpp"
#include "caf/config.hpp"
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
&
)
>
;
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
);
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
);
});
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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_
;
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
};
};
...
...
libcaf_core/caf/typed_actor_view.hpp
View file @
7bce1d66
...
@@ -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
));
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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 -------------------------------------------------
...
...
libcaf_core/src/blocking_actor.cpp
View file @
7bce1d66
...
@@ -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
;
#if
ndef CAF_NO
_EXCEPTIONS
#if
def CAF_ENABLE
_EXCEPTIONS
try
{
try
{
self
->
act
();
self
->
act
();
rsn
=
self
->
fail_state_
;
rsn
=
self
->
fail_state_
;
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
7bce1d66
...
@@ -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
);
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
)
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
;
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
()));
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
));
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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
;
}
}
#if
ndef CAF_NO
_EXCEPTIONS
#if
def 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 ----------------------------------------------------
...
...
libcaf_core/test/custom_exception_handler.cpp
View file @
7bce1d66
...
@@ -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
libcaf_io/CMakeLists.txt
View file @
7bce1d66
...
@@ -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
)
libcaf_openssl/CMakeLists.txt
View file @
7bce1d66
...
@@ -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
)
tools/CMakeLists.txt
View file @
7bce1d66
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment