`cmake/SeastarDependencies.cmake` module is introduced.
It contains `seastar_find_dependencies` macro which iterates through
dependencies specification and calls `find_package` on each parsed entry.
Main `CMakeLists.txt` and `cmake/
SeastarConfig.cmake.in` use the new module
instead of listing and finding dependencies by itself.
---
CMakeLists.txt | 28 +------
cmake/
SeastarConfig.cmake.in | 25 +-----
cmake/SeastarDependencies.cmake | 133 ++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+), 48 deletions(-)
create mode 100644 cmake/SeastarDependencies.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40c0472c..cb476a01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -229,33 +229,11 @@ find_package (Boost 1.64.0 REQUIRED
thread
OPTIONAL_COMPONENTS unit_test_framework)
-find_package (c-ares 1.13.0 REQUIRED MODULE)
-find_package (cryptopp 5.6.5 REQUIRED)
-# No version information published.
-find_package (dpdk)
-find_package (fmt 5.0.0 REQUIRED)
-find_package (lz4 1.7.3 REQUIRED)
+include (SeastarDependencies)
+seastar_find_dependencies ()
-##
-## Private and private/public dependencies.
-##
-
-find_package (Concepts)
-find_package (GnuTLS 3.3.26 REQUIRED)
-find_package (LinuxMembarrier)
-find_package (Protobuf 2.5.0 REQUIRED)
-find_package (Sanitizers)
-find_package (StdAtomic REQUIRED)
-set (StdFilesystem_CXX_DIALECT ${Seastar_CXX_DIALECT})
-find_package (StdFilesystem REQUIRED)
-find_package (hwloc 1.11.2)
-# No version information published.
-find_package (lksctp-tools REQUIRED)
-# No version information published.
-find_package (numactl)
+# Private build dependencies not visible to consumers
find_package (ragel 6.10 REQUIRED)
-find_package (rt REQUIRED)
-find_package (yaml-cpp 0.5.1 REQUIRED)
#
# Code generation helpers.
diff --git a/cmake/
SeastarConfig.cmake.in b/cmake/
SeastarConfig.cmake.in
index 19221871..2cba04ba 100644
--- a/cmake/
SeastarConfig.cmake.in
+++ b/cmake/
SeastarConfig.cmake.in
@@ -38,29 +38,8 @@ find_package (Boost
thread
unit_test_framework)
-find_package (c-ares 1.13 REQUIRED MODULE)
-find_package (cryptopp 5.6.5 REQUIRED)
-find_package (dpdk)
-find_package (fmt 5.0.0 REQUIRED)
-find_package (lz4 1.7.3 REQUIRED)
-
-#
-# Private and private/public dependencies.
-#
-
-find_package (Concepts)
-find_package (GnuTLS 3.3.26 REQUIRED)
-find_package (LinuxMembarrier)
-find_package (Protobuf 2.5.0 REQUIRED)
-find_package (Sanitizers)
-find_package (StdAtomic REQUIRED)
-set (StdFilesystem_CXX_DIALECT "@Seastar_CXX_DIALECT@")
-find_package (StdFilesystem REQUIRED)
-find_package (hwloc 1.11.2)
-find_package (lksctp-tools)
-find_package (numactl)
-find_package (rt REQUIRED)
-find_package (yaml-cpp 0.5.1 REQUIRED)
+include (SeastarDependencies)
+seastar_find_dependencies ()
if (NOT TARGET Seastar::seastar)
include ("${CMAKE_CURRENT_LIST_DIR}/SeastarTargets.cmake")
diff --git a/cmake/SeastarDependencies.cmake b/cmake/SeastarDependencies.cmake
new file mode 100644
index 00000000..b1ad6be0
--- /dev/null
+++ b/cmake/SeastarDependencies.cmake
@@ -0,0 +1,133 @@
+#
+# This file is open source software, licensed to you under the terms
+# of the Apache License, Version 2.0 (the "License"). See the NOTICE file
+# distributed with this work for additional information regarding copyright
+# ownership. You may not use this file except in compliance with the License.
+#
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# Copyright (C) 2019 Scylladb, Ltd.
+#
+
+set (StdFilesystem_CXX_DIALECT ${Seastar_CXX_DIALECT})
+
+#
+# List of Seastar dependencies that is meant to be used
+# both in Seastar configuration and by clients which
+# consume Seastar via SeastarConfig.cmake.
+#
+# Each dependency declaration starts with ENTRY keyword.
+# The following sub-keys can be used:
+# * NAME - package name to use in `find_package`
+# * MIN_VERSION - minimum version requirement for the package
+# * other keys without values (options) are left unparsed
+# (this allows to provide `find_package` with numerous options
+# without specifically parsing them, for example: REQUIRED)
+#
+# Keys other than NAME are optional.
+#
+
+set (seastar_dependencies
+ ##
+ ## Public dependencies.
+ ##
+ ENTRY
+ NAME c-ares
+ MIN_VERSION 1.13
+ REQUIRED
+ MODULE
+ ENTRY
+ NAME cryptopp
+ MIN_VERSION 5.6.5
+ REQUIRED
+ ENTRY
+ NAME dpdk
+ ENTRY
+ NAME fmt
+ MIN_VERSION 5.0.0
+ REQUIRED
+ ENTRY
+ NAME lz4
+ MIN_VERSION 1.7.3
+ REQUIRED
+ ##
+ ## Private and private/public dependencies.
+ ##
+ ENTRY
+ NAME Concepts
+ ENTRY
+ NAME GnuTLS
+ MIN_VERSION 3.3.26
+ REQUIRED
+ ENTRY
+ NAME LinuxMembarrier
+ ENTRY
+ NAME Protobuf
+ MIN_VERSION 2.5.0
+ REQUIRED
+ ENTRY
+ NAME Sanitizers
+ ENTRY
+ NAME StdAtomic
+ REQUIRED
+ ENTRY
+ NAME StdFilesystem
+ REQUIRED
+ ENTRY
+ NAME hwloc
+ MIN_VERSION 1.11.2
+ ENTRY
+ NAME lksctp-tools
+ REQUIRED # No version information published.
+ ENTRY
+ NAME numactl # No version information published.
+ ENTRY
+ NAME rt
+ REQUIRED
+ ENTRY
+ NAME yaml-cpp
+ MIN_VERSION 0.5.1
+ REQUIRED
+)
+
+#
+# Iterate through Seastar dependencies list defined above and execute `find_package`
+# with corresponding configuration in each parsed entry.
+#
+# This is intentionally a macro since we don't want to introduce non-intuitive
+# side-effects of `find_package` calls which sets some non-cache variables.
+#
+macro (seastar_find_dependencies)
+ string (LENGTH "ENTRY" entry_kw_len)
+ while (TRUE)
+ string (FIND "${seastar_dependencies}" "ENTRY" current_entry_idx)
+ if (current_entry_idx EQUAL -1)
+ break ()
+ endif()
+ # Skip ahead ENTRY keyword
+ math (EXPR begin_position "${entry_kw_len} + 1")
+ string (SUBSTRING "${seastar_dependencies}" ${begin_position} -1 seastar_dependencies)
+ # Find the next ENTRY keyword to extract the current entry contents
+ string (FIND "${seastar_dependencies}" "ENTRY" next_entry_idx)
+ if (NOT next_entry_idx EQUAL -1)
+ math (EXPR content_end_idx "${next_entry_idx} - 1")
+ string (SUBSTRING "${seastar_dependencies}" 0 ${content_end_idx} current_entry_contents)
+ string (SUBSTRING "${seastar_dependencies}" ${next_entry_idx} -1 seastar_dependencies)
+ else()
+ set (current_entry_contents "${seastar_dependencies}")
+ endif()
+ cmake_parse_arguments (ENTRY_ARG "" "NAME;MIN_VERSION" "" "${current_entry_contents}")
+ find_package ("${ENTRY_ARG_NAME}" ${ENTRY_ARG_MIN_VERSION} ${ENTRY_ARG_UNPARSED_ARGUMENTS})
+ endwhile ()
+endmacro ()
--
2.17.1