Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
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
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-incubator
Commits
e5695676
Commit
e5695676
authored
Dec 16, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework incubator CMakeLists.txt
parent
65a7dae4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
98 deletions
+108
-98
CMakeLists.txt
CMakeLists.txt
+97
-97
cmake/CAFConfig.cmake.in
cmake/CAFConfig.cmake.in
+9
-0
cmake/FindCAF.cmake
cmake/FindCAF.cmake
+2
-1
No files found.
CMakeLists.txt
View file @
e5695676
...
@@ -3,12 +3,59 @@
...
@@ -3,12 +3,59 @@
cmake_minimum_required
(
VERSION 3.0 FATAL_ERROR
)
cmake_minimum_required
(
VERSION 3.0 FATAL_ERROR
)
project
(
caf_incubator C CXX
)
project
(
caf_incubator C CXX
)
# --
CMake includes for C/C++ features
-----------------------------------------
# --
project options ------------------
-----------------------------------------
include
(
CheckCSourceCompiles
)
option
(
BUILD_SHARED_LIBS
"Build all modules as shared library"
ON
)
include
(
CheckCSourceRuns
)
# -- set useful CMake options --------------------------------------------------
# -- includes ------------------------------------------------------------------
include
(
CMakePackageConfigHelpers
)
# For creating .cmake files
include
(
CheckCSourceCompiles
)
# Check whether compiler works
include
(
CheckCSourceRuns
)
# Check whether compiler produces binaries
include
(
GNUInstallDirs
)
# Sets default install paths
include
(
GenerateExportHeader
)
# Auto-generates dllexport macros
# -- check whether we are running as CMake subdirectory ------------------------
get_directory_property
(
_parent PARENT_DIRECTORY
)
if
(
_parent
)
set
(
caf_is_subproject ON
)
else
()
set
(
caf_is_subproject OFF
)
endif
()
unset
(
_parent
)
# enable tests if not disabled
if
(
NOT CAF_NO_UNIT_TESTS
)
enable_testing
()
function
(
add_test_suites executable dir
)
# enumerate all test suites.
set
(
suites
""
)
foreach
(
cpp_file
${
ARGN
}
)
file
(
STRINGS
"
${
dir
}
/
${
cpp_file
}
"
contents
)
foreach
(
line
${
contents
}
)
if
(
"
${
line
}
"
MATCHES
"SUITE (.+)"
)
string
(
REGEX REPLACE
".*SUITE (.+)"
"
\\
1"
suite
${
line
}
)
list
(
APPEND suites
"
${
suite
}
"
)
endif
()
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
()
endif
()
# -- make sure we have at least C++17 available --------------------------------
if
(
NOT CMAKE_CROSSCOMPILING
)
if
(
NOT CMAKE_CROSSCOMPILING
)
# Check whether the user already provided flags that enable C++ >= 17.
# Check whether the user already provided flags that enable C++ >= 17.
...
@@ -42,6 +89,22 @@ if(NOT CMAKE_CROSSCOMPILING)
...
@@ -42,6 +89,22 @@ if(NOT CMAKE_CROSSCOMPILING)
endif
()
endif
()
endif
()
endif
()
set
(
CMAKE_INSTALL_CMAKEBASEDIR
"
${
CMAKE_INSTALL_LIBDIR
}
/cmake"
CACHE PATH
"Base directory for installing cmake specific artifacts"
)
set
(
INSTALL_CAF_CMAKEDIR
"
${
CMAKE_INSTALL_CMAKEBASEDIR
}
/caf"
)
if
(
BUILD_SHARED_LIBS
)
set
(
LINK_TYPE
"shared"
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
set
(
CMAKE_VISIBILITY_INLINES_HIDDEN yes
)
if
(
POLICY CMP0063
)
cmake_policy
(
SET CMP0063 NEW
)
endif
()
else
()
set
(
CAF_STATIC_BUILD yes
)
set
(
LINK_TYPE
"static"
)
endif
()
# Be nice to VIM users and Clang tools.
# Be nice to VIM users and Clang tools.
set
(
CMAKE_EXPORT_COMPILE_COMMANDS 1
)
set
(
CMAKE_EXPORT_COMPILE_COMMANDS 1
)
...
@@ -57,12 +120,6 @@ add_custom_target(configure COMMAND ${CMAKE_CURRENT_BINARY_DIR}/config.status)
...
@@ -57,12 +120,6 @@ add_custom_target(configure COMMAND ${CMAKE_CURRENT_BINARY_DIR}/config.status)
# -- check for static builds ---------------------------------------------------
# -- check for static builds ---------------------------------------------------
# Shared libs are currently not supported on Windows.
if
(
WIN32 AND NOT CAF_BUILD_STATIC_ONLY
)
message
(
STATUS
"CAF currently only supports static-only builds on Windows"
)
set
(
CAF_BUILD_STATIC_ONLY yes
)
endif
()
if
(
CAF_BUILD_STATIC_RUNTIME
)
if
(
CAF_BUILD_STATIC_RUNTIME
)
set
(
flags_configs
set
(
flags_configs
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS
...
@@ -94,7 +151,14 @@ else()
...
@@ -94,7 +151,14 @@ else()
set
(
CAF_BUILD_STATIC_RUNTIME no
)
set
(
CAF_BUILD_STATIC_RUNTIME no
)
endif
()
endif
()
# -- utility functions ---------------------------------------------------------
# Silence annoying MSVC warning.
if
(
MSVC
)
add_compile_options
(
/wd4275 /wd4251
)
endif
()
################################################################################
# utility functions #
################################################################################
# Appends `str` to the variable named `var` with a whitespace as separator.
# 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
# Suppresses a leading whitespace if the variable is empty and does nothing if
...
@@ -127,7 +191,7 @@ add_executable(caf-generate-enum-strings cmake/caf-generate-enum-strings.cpp)
...
@@ -127,7 +191,7 @@ add_executable(caf-generate-enum-strings cmake/caf-generate-enum-strings.cpp)
function
(
enum_to_string relative_input_file relative_output_file
)
function
(
enum_to_string relative_input_file relative_output_file
)
set
(
input
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
relative_input_file
}
"
)
set
(
input
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
relative_input_file
}
"
)
set
(
output
"
${
CMAKE_
CURRENT_
BINARY_DIR
}
/
${
relative_output_file
}
"
)
set
(
output
"
${
CMAKE_BINARY_DIR
}
/
${
relative_output_file
}
"
)
add_custom_command
(
OUTPUT
"
${
output
}
"
add_custom_command
(
OUTPUT
"
${
output
}
"
COMMAND caf-generate-enum-strings
"
${
input
}
"
"
${
output
}
"
COMMAND caf-generate-enum-strings
"
${
input
}
"
"
${
output
}
"
DEPENDS caf-generate-enum-strings
"
${
input
}
"
)
DEPENDS caf-generate-enum-strings
"
${
input
}
"
)
...
@@ -238,14 +302,11 @@ endif()
...
@@ -238,14 +302,11 @@ endif()
if
(
MINGW
)
if
(
MINGW
)
add_definitions
(
-D_WIN32_WINNT=0x0600
)
add_definitions
(
-D_WIN32_WINNT=0x0600
)
add_definitions
(
-DWIN32
)
add_definitions
(
-DWIN32
)
include
(
GenerateExportHeader
)
list
(
APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi
)
list
(
APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi
)
# build static to avoid runtime dependencies to GCC libraries
# build static to avoid runtime dependencies to GCC libraries
build_string
(
"EXTRA_FLAGS"
"-static"
)
build_string
(
"EXTRA_FLAGS"
"-static"
)
elseif
(
CYGWIN
)
elseif
(
CYGWIN
)
build_string
(
"EXTRA_FLAGS"
"-U__STRICT_ANSI__"
)
build_string
(
"EXTRA_FLAGS"
"-U__STRICT_ANSI__"
)
else
()
build_string
(
"EXTRA_FLAGS"
"-fPIC"
)
endif
()
endif
()
# Add Windows-specific linker flags.
# Add Windows-specific linker flags.
...
@@ -312,92 +373,32 @@ add_custom_target(uninstall
...
@@ -312,92 +373,32 @@ add_custom_target(uninstall
COMMAND
"
${
CMAKE_COMMAND
}
"
-P
COMMAND
"
${
CMAKE_COMMAND
}
"
-P
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/cmake_uninstall.cmake"
)
# -- utility macro for adding unit tests ---------------------------------------
################################################################################
# add targets #
################################################################################
if
(
NOT CAF_NO_UNIT_TESTS
)
add_subdirectory
(
libcaf_net
)
enable_testing
()
add_subdirectory
(
libcaf_bb
)
macro
(
add_unit_tests globstr
)
file
(
GLOB_RECURSE tests
"
${
globstr
}
"
)
set
(
CAF_ALL_UNIT_TESTS
${
CAF_ALL_UNIT_TESTS
}
${
tests
}
)
endmacro
()
else
()
macro
(
add_unit_tests globstr
)
# do nothing (unit tests disabled)
endmacro
()
endif
()
# -- add targets ---------------------------------------------------------------
export
(
EXPORT CAFTargets FILE CAFTargets.cmake NAMESPACE caf::
)
include_directories
(
"
${
CAF_INCLUDE_DIRS
}
"
)
install
(
EXPORT CAFTargets
DESTINATION
"
${
INSTALL_CAF_CMAKEDIR
}
"
NAMESPACE caf::
)
macro
(
add_caf_lib name header_only
)
write_basic_package_version_file
(
string
(
TOUPPER
${
name
}
upper_name
)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
set
(
full_name
"libcaf_
${
name
}
"
)
VERSION
${
CAF_VERSION
}
if
(
NOT EXISTS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
full_name
}
"
)
COMPATIBILITY ExactVersion
)
message
(
STATUS
"skip
${
full_name
}
(not found)"
)
else
()
add_subdirectory
(
${
full_name
}
)
if
(
NOT
${
header_only
}
)
set
(
shared_target
${
full_name
}
_shared
)
set
(
static_target
${
full_name
}
_static
)
set
(
lib_varname CAF_LIBRARY_
${
upper_name
}
)
set
(
lib_varname_static
${
lib_varname
}
_STATIC
)
if
(
NOT CAF_BUILD_STATIC_ONLY
)
set
(
${
lib_varname
}
${
shared_target
}
)
set
(
CAF_LIBRARIES
${
CAF_LIBRARIES
}
${
shared_target
}
)
else
()
set
(
${
lib_varname
}
${
static_target
}
)
set
(
CAF_LIBRARIES
${
CAF_LIBRARIES
}
${
static_target
}
)
endif
()
if
(
CAF_BUILD_STATIC_ONLY OR CAF_BUILD_STATIC
)
set
(
${
lib_varname_static
}
${
static_target
}
)
endif
()
endif
()
add_unit_tests
(
"
${
full_name
}
/test/*.cpp"
)
# add headers to include directories so other subprojects can use them
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/libcaf_
${
name
}
"
)
endif
()
endmacro
()
add_caf_lib
(
bb yes
)
configure_package_config_file
(
add_caf_lib
(
net no
)
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/CAFConfig.cmake.in"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
INSTALL_DESTINATION
"
${
INSTALL_CAF_CMAKEDIR
}
"
)
# -- unit tests setup ----------------------------------------------------------
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfig.cmake"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CAFConfigVersion.cmake"
if
(
NOT CAF_NO_UNIT_TESTS
)
DESTINATION
"
${
INSTALL_CAF_CMAKEDIR
}
"
)
# setup unit test binary
add_executable
(
incubator-test
"cmake/incubator-test.cpp"
${
CAF_ALL_UNIT_TESTS
}
)
target_link_libraries
(
incubator-test
${
CAF_EXTRA_LDFLAGS
}
${
CAF_LIBRARIES
}
${
PTHREAD_LIBRARIES
}
)
add_custom_target
(
all_unit_tests
)
add_dependencies
(
incubator-test all_unit_tests
)
# enumerate all test suites.
foreach
(
test
${
CAF_ALL_UNIT_TESTS
}
)
file
(
STRINGS
${
test
}
contents
)
foreach
(
line
${
contents
}
)
if
(
"
${
line
}
"
MATCHES
"CAF_SUITE (.*)"
)
string
(
REGEX REPLACE
".* CAF_SUITE (.*)"
"
\\
1"
suite
${
line
}
)
list
(
APPEND suites
${
suite
}
)
endif
()
endforeach
()
endforeach
()
list
(
REMOVE_DUPLICATES suites
)
# creates one CMake test per test suite.
macro
(
make_test suite
)
string
(
REPLACE
" "
"_"
test_name
${
suite
}
)
set
(
caf_test
${
EXECUTABLE_OUTPUT_PATH
}
/incubator-test
)
add_test
(
${
test_name
}
${
caf_test
}
-r 300 -n -v 5 -s
"^
${
suite
}
$"
${
ARGN
}
)
endmacro
()
list
(
LENGTH suites num_suites
)
message
(
STATUS
"Found
${
num_suites
}
test suites"
)
foreach
(
suite
${
suites
}
)
make_test
(
"
${
suite
}
"
)
endforeach
()
endif
()
# -- print summary -------------------------------------------------------------
# -- print summary -------------------------------------------------------------
...
@@ -425,8 +426,7 @@ if(NOT CAF_NO_SUMMARY)
...
@@ -425,8 +426,7 @@ if(NOT CAF_NO_SUMMARY)
"
\n
====================| Build Summary |===================="
"
\n
====================| Build Summary |===================="
"
\n
"
"
\n
"
"
\n
Build type:
${
CMAKE_BUILD_TYPE
}
"
"
\n
Build type:
${
CMAKE_BUILD_TYPE
}
"
"
\n
Build static:
${
CAF_BUILD_STATIC
}
"
"
\n
Link type:
${
LINK_TYPE
}
"
"
\n
Build static only:
${
CAF_BUILD_STATIC_ONLY
}
"
"
\n
Build static runtime:
${
CAF_BUILD_STATIC_RUNTIME
}
"
"
\n
Build static runtime:
${
CAF_BUILD_STATIC_RUNTIME
}
"
"
\n
"
"
\n
"
"
\n
CXX:
${
CMAKE_CXX_COMPILER
}
"
"
\n
CXX:
${
CMAKE_CXX_COMPILER
}
"
...
...
cmake/CAFConfig.cmake.in
0 → 100644
View file @
e5695676
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_dependency(Threads)
include("${CMAKE_CURRENT_LIST_DIR}/CAFTargets.cmake")
cmake/FindCAF.cmake
View file @
e5695676
...
@@ -61,6 +61,7 @@ foreach (comp ${CAF_FIND_COMPONENTS})
...
@@ -61,6 +61,7 @@ foreach (comp ${CAF_FIND_COMPONENTS})
NAMES
NAMES
caf/detail/build_config.hpp
caf/detail/build_config.hpp
HINTS
HINTS
${
CAF_ROOT_DIR
}
${
header_hints
}
${
header_hints
}
/usr/include
/usr/include
/usr/local/include
/usr/local/include
...
@@ -71,7 +72,7 @@ foreach (comp ${CAF_FIND_COMPONENTS})
...
@@ -71,7 +72,7 @@ foreach (comp ${CAF_FIND_COMPONENTS})
message
(
WARNING
"Found all.hpp for CAF core, but not build_config.hpp"
)
message
(
WARNING
"Found all.hpp for CAF core, but not build_config.hpp"
)
set
(
CAF_
${
comp
}
_FOUND false
)
set
(
CAF_
${
comp
}
_FOUND false
)
else
()
else
()
list
(
APPEND CAF_INCLUDE_DIR
_
${
UPPERCOMP
}
"
${
caf_build_header_path
}
"
)
list
(
APPEND CAF_INCLUDE_DIR
S
"
${
caf_build_header_path
}
"
)
endif
()
endif
()
endif
()
endif
()
list
(
APPEND CAF_INCLUDE_DIRS
"
${
CAF_INCLUDE_DIR_
${
UPPERCOMP
}}
"
)
list
(
APPEND CAF_INCLUDE_DIRS
"
${
CAF_INCLUDE_DIR_
${
UPPERCOMP
}}
"
)
...
...
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