This version reads the compilation flags for Seastar from pkg-config and uses
file globbing to register all source and header files.
In comparison to the previous version, I see all files in the project explorer
view are "active" (rather than just .cc files). I believe there are also fewer
errors reported by the editor.
Signed-off-by: Jesse Haber-Kucharsky <
jhab...@scylladb.com>
---
CMakeLists.txt | 145 ++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 97 insertions(+), 48 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5538efb..b56fbab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,55 +1,104 @@
cmake_minimum_required(VERSION 3.5)
-project(scylla)
+project(Scylla)
-if (NOT DEFINED ENV{CLION_IDE})
+if(NOT DEFINED ENV{CLION_IDE})
message(FATAL_ERROR "This CMakeLists.txt file is only valid for use in CLion")
endif()
+find_package(PkgConfig REQUIRED)
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -DHAVE_HWLOC -DHAVE_DPDK")
-include_directories(. build/release/gen seastar)
-
-aux_source_directory(build/release/gen SOURCE_FILES)
-aux_source_directory(build/release/gen/cql3 SOURCE_FILES)
-aux_source_directory(build/release/gen/idl SOURCE_FILES)
-aux_source_directory(. SOURCE_FILES)
-aux_source_directory(api SOURCE_FILES)
-aux_source_directory(auth SOURCE_FILES)
-aux_source_directory(cql3 SOURCE_FILES)
-aux_source_directory(cql3/functions SOURCE_FILES)
-aux_source_directory(cql3/restrictions SOURCE_FILES)
-aux_source_directory(cql3/selection SOURCE_FILES)
-aux_source_directory(cql3/statements SOURCE_FILES)
-aux_source_directory(db/ SOURCE_FILES)
-aux_source_directory(db/commitlog SOURCE_FILES)
-aux_source_directory(db/index SOURCE_FILES)
-aux_source_directory(db/marshal SOURCE_FILES)
-aux_source_directory(db/view SOURCE_FILES)
-aux_source_directory(dht SOURCE_FILES)
-aux_source_directory(exceptions SOURCE_FILES)
-aux_source_directory(gms SOURCE_FILES)
-aux_source_directory(index SOURCE_FILES)
-aux_source_directory(io SOURCE_FILES)
-aux_source_directory(locator SOURCE_FILES)
-aux_source_directory(message SOURCE_FILES)
-aux_source_directory(repair SOURCE_FILES)
-aux_source_directory(seastar SOURCE_FILES)
-aux_source_directory(seastar/core SOURCE_FILES)
-aux_source_directory(seastar/http SOURCE_FILES)
-aux_source_directory(seastar/net SOURCE_FILES)
-aux_source_directory(seastar/rpc SOURCE_FILES)
-aux_source_directory(seastar/tests SOURCE_FILES)
-aux_source_directory(seastar/util SOURCE_FILES)
-aux_source_directory(service SOURCE_FILES)
-aux_source_directory(service/pager SOURCE_FILES)
-aux_source_directory(sstables SOURCE_FILES)
-aux_source_directory(streaming SOURCE_FILES)
-aux_source_directory(tests SOURCE_FILES)
-aux_source_directory(tests/perf SOURCE_FILES)
-aux_source_directory(thrift SOURCE_FILES)
-aux_source_directory(tracing SOURCE_FILES)
-aux_source_directory(transport SOURCE_FILES)
-aux_source_directory(transport/messages SOURCE_FILES)
-aux_source_directory(utils SOURCE_FILES)
-
-add_executable(scylla ${SOURCE_FILES})
+set(ENV{PKG_CONFIG_PATH} "${CMAKE_SOURCE_DIR}/seastar/build/release:$ENV{PKG_CONFIG_PATH}")
+pkg_check_modules(SEASTAR REQUIRED seastar)
+
+function(add_seastar_executable)
+ set(options "")
+ set(oneValueArgs NAME)
+ set(multiValueArgs SOURCES)
+ cmake_parse_arguments(args "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
+
+ add_executable(${args_NAME} ${args_SOURCES})
+
+ target_include_directories(${args_NAME} SYSTEM PUBLIC ${SEASTAR_INCLUDE_DIRS})
+ target_compile_options(${args_NAME} PUBLIC ${SEASTAR_CFLAGS})
+
+ target_link_libraries(${args_NAME}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${SEASTAR_LIBRARIES}
+ ${SEASTAR_LDFLAGS})
+endfunction(add_seastar_executable)
+
+function(add_scylla_source_directories)
+ set(options RECURSIVE)
+ set(oneValueArgs VAR)
+ set(multiValueArgs PATHS)
+ cmake_parse_arguments(args "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
+
+ set(globs "")
+
+ foreach(dir ${args_PATHS})
+ list(APPEND globs "${dir}/*.cc" "${dir}/*.hh")
+ endforeach(dir)
+
+ if(args_RECURSIVE)
+ set(glob_kind GLOB_RECURSE)
+ else(NOT args_RECURSIVE)
+ set(glob_kind GLOB)
+ endif(args_RECURSIVE)
+
+ file(${glob_kind} var
+ ${globs})
+
+ set (${args_VAR} ${var} PARENT_SCOPE)
+endfunction(add_scylla_source_directories)
+
+add_scylla_source_directories(
+ VAR SCYLLA_ROOT_SOURCE_FILES
+ RECURSIVE no
+ PATHS .)
+
+add_scylla_source_directories(
+ VAR SCYLLA_SUB_SOURCE_FILES
+ RECURSIVE yes
+
+ PATHS
+ api
+ auth
+ cql3
+ db
+ dht
+ exceptions
+ gms
+ index
+ io
+ locator
+ message
+ repair
+ service
+ sstables
+ streaming
+ thrift
+ tracing
+ transport
+ utils)
+
+add_scylla_source_directories(
+ VAR SCYLLA_GEN_SOURCE_FILES
+ RECURSIVE yes
+ PATHS build/release/gen)
+
+set(SCYLLA_SOURCE_FILES
+ ${SCYLLA_ROOT_SOURCE_FILES}
+ ${SCYLLA_GEN_SOURCE_FILES}
+ ${SCYLLA_SUB_SOURCE_FILES})
+
+add_seastar_executable(
+ NAME scylla
+ SOURCES ${SCYLLA_SOURCE_FILES})
+
+target_include_directories(scylla PRIVATE
+ .
+ build/release/gen
+ build/release/gen/cql3
+ build/release/gen/idl)
--
2.9.4