diff --git a/cmake/SeastarConfig.cmake.in b/cmake/SeastarConfig.cmake.in index 7d4e868338..967c687f70 100644 --- a/cmake/SeastarConfig.cmake.in +++ b/cmake/SeastarConfig.cmake.in @@ -20,9 +20,6 @@ # Copyright (C) 2018 Scylladb, Ltd. # -# We would like to use `find_dependency`, but it is not supported properly until CMake 3.8. -#include (FindDependencyMacro) - list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) if (CMAKE_CXX_STANDARD) diff --git a/cmake/SeastarDependencies.cmake b/cmake/SeastarDependencies.cmake index c4d32b3eeb..df3ea09284 100644 --- a/cmake/SeastarDependencies.cmake +++ b/cmake/SeastarDependencies.cmake @@ -20,6 +20,8 @@ # Copyright (C) 2019 Scylladb, Ltd. # +include(CMakeParseArguments) + # # CMake bundles `FindBoost.cmake`, which is coupled to the Boost version. If # we're on a system without a recent enough version of `FindBoost.cmake`, then @@ -48,9 +50,26 @@ if (Boost_VERSION_STRING VERSION_LESS 1.81.0) INTERFACE_COMPILE_DEFINITIONS "BOOST_NO_CXX98_FUNCTION_BASE") endif () -macro (seastar_find_dep package) - find_package (${package} ${ARGN}) -endmacro () +if (CMAKE_FIND_PACKAGE_NAME) + # used inside find_package(Seastar) + include (CMakeFindDependencyMacro) + + macro (seastar_find_dep package) + cmake_parse_arguments(args "REQUIRED" "" "" ${ARGN}) + if (arg_REQUIRED) + find_dependency (${package} ${arg_UNPARSED_ARGUMENTS}) + else () + # some packages are not REQUIRED, so we just check for them instead of + # populating "REQUIRED" from the original find_package() call. + find_package (${package} ${ARGN}) + endif () + endmacro () +else() + macro (seastar_find_dep package) + # used when configuring Seastar + find_package (${package} ${ARGN}) + endmacro () +endif () macro (seastar_find_dependencies) #