Include tools CMakeLists in the top level CMakeLists
Summary: Split main CMakeLists into src/CMakeLists The main CMakeLists duty is to make all the required libraries and variables visible to all of the other sub-CMakeLists. After doing that, it should include those sub-CMakeLists according to configuration options. This should make global configurations easier to reuse without polluting the global space with locally related configurations. It is a necessary step for including other projects like 'tools' in the release installation. Building tools is automatically disabled, but can be enabled by setting the TOOLS option to ON when running cmake. This should allow on demand building as well as combined installation of Memgraph and its tools. Reviewers: mferencevic, buda Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1018
This commit is contained in:
parent
d1dbf22cd1
commit
a17261038c
289
CMakeLists.txt
289
CMakeLists.txt
@ -25,9 +25,21 @@ if(CCACHE_FOUND AND USE_CCACHE)
|
||||
endif(CCACHE_FOUND AND USE_CCACHE)
|
||||
|
||||
# choose a compiler
|
||||
# NOTE: must be choosen before use of project() or enable_language() ----------
|
||||
set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
# NOTE: must be choosen before use of project() or enable_language()
|
||||
find_program(CLANG_FOUND clang)
|
||||
find_program(CLANGXX_FOUND clang++)
|
||||
if (CLANG_FOUND AND CLANGXX_FOUND)
|
||||
set(CMAKE_C_COMPILER ${CLANG_FOUND})
|
||||
set(CMAKE_CXX_COMPILER ${CLANGXX_FOUND})
|
||||
endif()
|
||||
|
||||
# Get current commit hash.
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
COMMAND git rev-parse --short HEAD
|
||||
)
|
||||
string(STRIP ${COMMIT_HASH} COMMIT_HASH)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
project(memgraph VERSION 0.8.0)
|
||||
@ -36,8 +48,6 @@ project(memgraph VERSION 0.8.0)
|
||||
# setup CMake module path, defines path for include() and find_package()
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# custom function definitions
|
||||
include(functions)
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -48,6 +58,58 @@ disallow_in_source_build()
|
||||
add_custom_target(clean_all
|
||||
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/clean_all.cmake
|
||||
COMMENT "Removing all files in ${CMAKE_BINARY_DIR}")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# build flags -----------------------------------------------------------------
|
||||
|
||||
# TODO: set here 17 once it will be available in the cmake version (3.8)
|
||||
# set(CMAKE_CXX_STANDARD 17)
|
||||
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# For now, explicitly set -std= flag for C++17.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Werror=switch -Werror=switch-bool")
|
||||
|
||||
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
||||
|
||||
# Use gold linker to speedup build
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
|
||||
# release flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
|
||||
#debug flags
|
||||
set(PREFERRED_DEBUGGER "gdb" CACHE STRING
|
||||
"Tunes the debug output for your preferred debugger (gdb or lldb).")
|
||||
if ("${PREFERRED_DEBUGGER}" STREQUAL "gdb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|GNU")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
|
||||
elseif ("${PREFERRED_DEBUGGER}" STREQUAL "lldb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-glldb")
|
||||
else()
|
||||
message(WARNING "Unable to tune for PREFERRED_DEBUGGER: "
|
||||
"'${PREFERRED_DEBUGGER}' with compiler: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
endif()
|
||||
|
||||
# ndebug
|
||||
option(NDEBUG "No debug" OFF)
|
||||
message(STATUS "NDEBUG: ${NDEBUG} (be careful CMAKE_BUILD_TYPE can also \
|
||||
append this flag)")
|
||||
if(NDEBUG)
|
||||
add_definitions( -DNDEBUG )
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# default build type is debug
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# setup external dependencies -------------------------------------------------
|
||||
|
||||
# threading
|
||||
find_package(Threads REQUIRED)
|
||||
@ -66,89 +128,13 @@ if (USE_READLINE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# TODO: set here 17 once it will be available in the cmake version (3.8)
|
||||
# set(CMAKE_CXX_STANDARD 17)
|
||||
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# For now, explicitly set -std= flag for C++17.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Werror=switch -Werror=switch-bool")
|
||||
|
||||
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
||||
|
||||
# Use gold linker to speedup build
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# dir variables
|
||||
set(src_dir ${CMAKE_SOURCE_DIR}/src)
|
||||
set(libs_dir ${CMAKE_SOURCE_DIR}/libs)
|
||||
set(tests_dir ${CMAKE_SOURCE_DIR}/tests)
|
||||
# -----------------------------------------------------------------------------
|
||||
add_subdirectory(libs EXCLUDE_FROM_ALL)
|
||||
|
||||
# Generate a version.hpp file
|
||||
set(VERSION_STRING ${memgraph_VERSION})
|
||||
configure_file(${src_dir}/version.hpp.in include/version.hpp @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
|
||||
# build flags -----------------------------------------------------------------
|
||||
# release flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
#debug flags
|
||||
set(PREFERRED_DEBUGGER "gdb" CACHE STRING
|
||||
"Tunes the debug output for your preferred debugger (gdb or lldb).")
|
||||
if ("${PREFERRED_DEBUGGER}" STREQUAL "gdb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|GNU")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
|
||||
elseif ("${PREFERRED_DEBUGGER}" STREQUAL "lldb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-glldb")
|
||||
else()
|
||||
message(WARNING "Unable to tune for PREFERRED_DEBUGGER: "
|
||||
"'${PREFERRED_DEBUGGER}' with compiler: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
endif()
|
||||
|
||||
# default build type is debug
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# setup external dependencies -------------------------------------------------
|
||||
add_subdirectory(libs)
|
||||
|
||||
# ndebug
|
||||
option(NDEBUG "No debug" OFF)
|
||||
message(STATUS "NDEBUG: ${NDEBUG} (be careful CMAKE_BUILD_TYPE can also \
|
||||
append this flag)")
|
||||
if(NDEBUG)
|
||||
add_definitions( -DNDEBUG )
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# proof of concept
|
||||
option(POC "Build proof of concept binaries" ON)
|
||||
message(STATUS "POC binaries: ${POC}")
|
||||
# experimental
|
||||
option(EXPERIMENTAL "Build experimental binaries" OFF)
|
||||
message(STATUS "Experimental binaries: ${EXPERIMENTAL}")
|
||||
# customers
|
||||
option(CUSTOMERS "Customer binaries" ON)
|
||||
message(STATUS "Customers binaries: ${CUSTOMERS}")
|
||||
# tests
|
||||
option(TEST_COVERAGE "Generate coverage reports from unit tests" OFF)
|
||||
message(STATUS "Generate coverage from unit tests: ${TEST_COVERAGE}")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# includes
|
||||
include_directories(${src_dir})
|
||||
include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${FMT_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${ANTLR4_INCLUDE_DIR})
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# openCypher parser -----------------------------------------------------------
|
||||
@ -178,141 +164,42 @@ add_custom_command(OUTPUT ${antlr_opencypher_generated_src}
|
||||
add_custom_target(generate_opencypher_parser
|
||||
DEPENDS ${antlr_opencypher_generated_src})
|
||||
|
||||
# include antlr header files
|
||||
include_directories(${ANTLR4_INCLUDE_DIR})
|
||||
|
||||
add_library(antlr_opencypher_parser_lib STATIC ${antlr_opencypher_generated_src})
|
||||
target_link_libraries(antlr_opencypher_parser_lib antlr4)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# all memgraph src files
|
||||
set(memgraph_src_files
|
||||
${src_dir}/communication/bolt/v1/decoder/decoded_value.cpp
|
||||
${src_dir}/communication/bolt/v1/session.cpp
|
||||
${src_dir}/communication/reactor/protocol.cpp
|
||||
${src_dir}/communication/raft/raft.cpp
|
||||
${src_dir}/communication/reactor/reactor_local.cpp
|
||||
${src_dir}/communication/reactor/reactor_distributed.cpp
|
||||
${src_dir}/data_structures/concurrent/skiplist_gc.cpp
|
||||
${src_dir}/database/graph_db.cpp
|
||||
${src_dir}/database/graph_db_config.cpp
|
||||
${src_dir}/database/graph_db_accessor.cpp
|
||||
${src_dir}/durability/paths.cpp
|
||||
${src_dir}/durability/recovery.cpp
|
||||
${src_dir}/durability/snapshooter.cpp
|
||||
${src_dir}/durability/wal.cpp
|
||||
${src_dir}/io/network/addrinfo.cpp
|
||||
${src_dir}/io/network/network_endpoint.cpp
|
||||
${src_dir}/io/network/socket.cpp
|
||||
${src_dir}/query/common.cpp
|
||||
${src_dir}/query/console.cpp
|
||||
${src_dir}/query/frontend/ast/ast.cpp
|
||||
${src_dir}/query/frontend/ast/cypher_main_visitor.cpp
|
||||
${src_dir}/query/frontend/semantic/symbol_generator.cpp
|
||||
${src_dir}/query/frontend/stripped.cpp
|
||||
${src_dir}/query/interpret/awesome_memgraph_functions.cpp
|
||||
${src_dir}/query/interpreter.cpp
|
||||
${src_dir}/query/plan/operator.cpp
|
||||
${src_dir}/query/plan/preprocess.cpp
|
||||
${src_dir}/query/plan/rule_based_planner.cpp
|
||||
${src_dir}/query/plan/variable_start_planner.cpp
|
||||
${src_dir}/query/typed_value.cpp
|
||||
${src_dir}/storage/edge_accessor.cpp
|
||||
${src_dir}/storage/locking/record_lock.cpp
|
||||
${src_dir}/storage/property_value.cpp
|
||||
${src_dir}/storage/record_accessor.cpp
|
||||
${src_dir}/storage/vertex_accessor.cpp
|
||||
${src_dir}/threading/thread.cpp
|
||||
${src_dir}/transactions/engine_master.cpp
|
||||
${src_dir}/transactions/engine_worker.cpp
|
||||
${src_dir}/utils/watchdog.cpp
|
||||
)
|
||||
include_directories(src)
|
||||
add_subdirectory(src)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# memgraph_lib depend on these libraries
|
||||
set(MEMGRAPH_ALL_LIBS stdc++fs Threads::Threads fmt cppitertools cereal
|
||||
antlr_opencypher_parser_lib dl glog gflags)
|
||||
# Optional subproject configuration -------------------------------------------
|
||||
option(POC "Build proof of concept binaries" ON)
|
||||
option(EXPERIMENTAL "Build experimental binaries" OFF)
|
||||
option(CUSTOMERS "Build customer binaries" ON)
|
||||
option(TEST_COVERAGE "Generate coverage reports from unit tests" OFF)
|
||||
option(TOOLS "Build tools binaries" OFF)
|
||||
|
||||
if (USE_LTALLOC)
|
||||
list(APPEND MEMGRAPH_ALL_LIBS ltalloc)
|
||||
# TODO(mferencevic): Enable this when clang is updated on apollo.
|
||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
|
||||
if(POC)
|
||||
add_subdirectory(poc)
|
||||
endif()
|
||||
|
||||
if (READLINE_FOUND)
|
||||
list(APPEND MEMGRAPH_ALL_LIBS readline)
|
||||
if(EXPERIMENTAL)
|
||||
add_subdirectory(experimental)
|
||||
endif()
|
||||
|
||||
# STATIC library used by memgraph executables
|
||||
add_library(memgraph_lib STATIC ${memgraph_src_files})
|
||||
target_link_libraries(memgraph_lib ${MEMGRAPH_ALL_LIBS})
|
||||
add_dependencies(memgraph_lib generate_opencypher_parser)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# proof of concepts
|
||||
if (POC)
|
||||
add_subdirectory(poc)
|
||||
if(CUSTOMERS)
|
||||
add_subdirectory(customers)
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# experimental
|
||||
if (EXPERIMENTAL)
|
||||
add_subdirectory(experimental)
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# customers
|
||||
if (CUSTOMERS)
|
||||
add_subdirectory(customers)
|
||||
endif()
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# tests
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# memgraph build name
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
COMMAND git rev-parse --short HEAD
|
||||
)
|
||||
string(STRIP ${COMMIT_HASH} COMMIT_HASH)
|
||||
set(MEMGRAPH_BUILD_NAME "memgraph-${memgraph_VERSION}-${COMMIT_HASH}_${CMAKE_BUILD_TYPE}")
|
||||
add_custom_target(memgraph_link_target ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/${MEMGRAPH_BUILD_NAME} ${CMAKE_BINARY_DIR}/memgraph DEPENDS ${MEMGRAPH_BUILD_NAME})
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# memgraph main executable
|
||||
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
|
||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph_lib)
|
||||
# Strip the executable in release build.
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build_type)
|
||||
if (lower_build_type STREQUAL "release")
|
||||
add_custom_command(TARGET ${MEMGRAPH_BUILD_NAME} POST_BUILD
|
||||
COMMAND strip -s ${MEMGRAPH_BUILD_NAME}
|
||||
COMMENT Stripping symbols and sections from
|
||||
${MEMGRAPH_BUILD_NAME})
|
||||
if(TOOLS)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
# Install and rename executable to just 'memgraph' Since we have to rename,
|
||||
# we cannot use the recommended `install(TARGETS ...)`.
|
||||
install(PROGRAMS ${CMAKE_BINARY_DIR}/${MEMGRAPH_BUILD_NAME}
|
||||
DESTINATION bin RENAME memgraph)
|
||||
# Install the config file (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/config/community.conf
|
||||
DESTINATION /etc/memgraph RENAME memgraph.conf)
|
||||
# Install logrotate configuration (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/logrotate.conf
|
||||
DESTINATION /etc/logrotate.d RENAME memgraph)
|
||||
# Create empty directories for default location of lib and log.
|
||||
install(CODE "file(MAKE_DIRECTORY \$ENV{DESTDIR}/var/log/memgraph
|
||||
\$ENV{DESTDIR}/var/lib/memgraph)")
|
||||
# Install the license file.
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE.md
|
||||
DESTINATION share/doc/memgraph RENAME copyright)
|
||||
# Install systemd service (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/memgraph.service
|
||||
DESTINATION /lib/systemd/system)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# ---- Setup CPack --------
|
||||
# General setup
|
||||
|
114
src/CMakeLists.txt
Normal file
114
src/CMakeLists.txt
Normal file
@ -0,0 +1,114 @@
|
||||
# CMake configuration for the main memgraph library and executable
|
||||
|
||||
# all memgraph src files
|
||||
set(memgraph_src_files
|
||||
communication/bolt/v1/decoder/decoded_value.cpp
|
||||
communication/bolt/v1/session.cpp
|
||||
communication/reactor/protocol.cpp
|
||||
communication/raft/raft.cpp
|
||||
communication/reactor/reactor_local.cpp
|
||||
communication/reactor/reactor_distributed.cpp
|
||||
data_structures/concurrent/skiplist_gc.cpp
|
||||
database/graph_db.cpp
|
||||
database/graph_db_config.cpp
|
||||
database/graph_db_accessor.cpp
|
||||
durability/paths.cpp
|
||||
durability/recovery.cpp
|
||||
durability/snapshooter.cpp
|
||||
durability/wal.cpp
|
||||
io/network/addrinfo.cpp
|
||||
io/network/network_endpoint.cpp
|
||||
io/network/socket.cpp
|
||||
query/common.cpp
|
||||
query/console.cpp
|
||||
query/frontend/ast/ast.cpp
|
||||
query/frontend/ast/cypher_main_visitor.cpp
|
||||
query/frontend/semantic/symbol_generator.cpp
|
||||
query/frontend/stripped.cpp
|
||||
query/interpret/awesome_memgraph_functions.cpp
|
||||
query/interpreter.cpp
|
||||
query/plan/operator.cpp
|
||||
query/plan/preprocess.cpp
|
||||
query/plan/rule_based_planner.cpp
|
||||
query/plan/variable_start_planner.cpp
|
||||
query/typed_value.cpp
|
||||
storage/edge_accessor.cpp
|
||||
storage/locking/record_lock.cpp
|
||||
storage/property_value.cpp
|
||||
storage/record_accessor.cpp
|
||||
storage/vertex_accessor.cpp
|
||||
threading/thread.cpp
|
||||
transactions/engine_master.cpp
|
||||
transactions/engine_worker.cpp
|
||||
utils/watchdog.cpp
|
||||
)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# memgraph_lib depend on these libraries
|
||||
set(MEMGRAPH_ALL_LIBS stdc++fs Threads::Threads fmt cppitertools cereal
|
||||
antlr_opencypher_parser_lib dl glog gflags)
|
||||
|
||||
if (USE_LTALLOC)
|
||||
list(APPEND MEMGRAPH_ALL_LIBS ltalloc)
|
||||
# TODO(mferencevic): Enable this when clang is updated on apollo.
|
||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
|
||||
endif()
|
||||
|
||||
if (READLINE_FOUND)
|
||||
list(APPEND MEMGRAPH_ALL_LIBS readline)
|
||||
endif()
|
||||
|
||||
# STATIC library used by memgraph executables
|
||||
add_library(memgraph_lib STATIC ${memgraph_src_files})
|
||||
target_link_libraries(memgraph_lib ${MEMGRAPH_ALL_LIBS})
|
||||
add_dependencies(memgraph_lib generate_opencypher_parser)
|
||||
|
||||
# Generate a version.hpp file
|
||||
set(VERSION_STRING ${memgraph_VERSION})
|
||||
configure_file(version.hpp.in version.hpp @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(MEMGRAPH_BUILD_NAME "memgraph-${memgraph_VERSION}-${COMMIT_HASH}_${CMAKE_BUILD_TYPE}")
|
||||
|
||||
# memgraph main executable
|
||||
add_executable(${MEMGRAPH_BUILD_NAME} memgraph_bolt.cpp)
|
||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph_lib)
|
||||
# Output the executable in main binary dir.
|
||||
set_target_properties(${MEMGRAPH_BUILD_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
# Strip the executable in release build.
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build_type)
|
||||
if (lower_build_type STREQUAL "release")
|
||||
add_custom_command(TARGET ${MEMGRAPH_BUILD_NAME} POST_BUILD
|
||||
COMMAND strip -s $<TARGET_FILE:${MEMGRAPH_BUILD_NAME}>
|
||||
COMMENT Stripping symbols and sections from
|
||||
${MEMGRAPH_BUILD_NAME})
|
||||
endif()
|
||||
|
||||
add_custom_target(memgraph_link_target ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:${MEMGRAPH_BUILD_NAME}> ${CMAKE_BINARY_DIR}/memgraph
|
||||
DEPENDS ${MEMGRAPH_BUILD_NAME})
|
||||
|
||||
# Everything here is under "memgraph" install component.
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "memgraph")
|
||||
|
||||
# Install and rename executable to just 'memgraph' Since we have to rename,
|
||||
# we cannot use the recommended `install(TARGETS ...)`.
|
||||
install(PROGRAMS ${CMAKE_BINARY_DIR}/${MEMGRAPH_BUILD_NAME}
|
||||
DESTINATION bin RENAME memgraph)
|
||||
# Install the config file (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/config/community.conf
|
||||
DESTINATION /etc/memgraph RENAME memgraph.conf)
|
||||
# Install logrotate configuration (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/logrotate.conf
|
||||
DESTINATION /etc/logrotate.d RENAME memgraph)
|
||||
# Create empty directories for default location of lib and log.
|
||||
install(CODE "file(MAKE_DIRECTORY \$ENV{DESTDIR}/var/log/memgraph
|
||||
\$ENV{DESTDIR}/var/lib/memgraph)")
|
||||
# Install the license file.
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE.md
|
||||
DESTINATION share/doc/memgraph RENAME copyright)
|
||||
# Install systemd service (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/memgraph.service
|
||||
DESTINATION /lib/systemd/system)
|
||||
|
@ -1,75 +1,12 @@
|
||||
# MemGraph Tools CMake configuration
|
||||
# You should use the top level CMake configuration with -DTOOLS=ON option set.
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
if (NOT UNIX)
|
||||
message(FATAL, "Unsupported operating system.")
|
||||
endif()
|
||||
|
||||
# ccache setup
|
||||
# ccache isn't enabled all the time because it makes some problem
|
||||
# during the code coverage process
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
option(USE_CCACHE "ccache:" ON)
|
||||
message(STATUS "CCache: ${USE_CCACHE}")
|
||||
if(CCACHE_FOUND AND USE_CCACHE)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND AND USE_CCACHE)
|
||||
|
||||
# choose a compiler
|
||||
# NOTE: must be choosen before use of project() or enable_language()
|
||||
set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
|
||||
project(memgraph_tools)
|
||||
|
||||
# setup CMake module path, defines path for include() and find_package()
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/../cmake)
|
||||
# custom function definitions
|
||||
include(functions)
|
||||
project(memgraph_tools VERSION ${memgraph_VERSION})
|
||||
|
||||
disallow_in_source_build()
|
||||
|
||||
# threading
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# optional readline
|
||||
find_package(Readline)
|
||||
if (READLINE_FOUND)
|
||||
add_definitions(-DHAS_READLINE)
|
||||
endif()
|
||||
|
||||
# Explicitly set -std= flag for C++17.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall")
|
||||
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
||||
|
||||
set(PREFERRED_DEBUGGER "gdb" CACHE STRING
|
||||
"Tunes the debug output for your preferred debugger (gdb or lldb).")
|
||||
if ("${PREFERRED_DEBUGGER}" STREQUAL "gdb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|GNU")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
|
||||
elseif ("${PREFERRED_DEBUGGER}" STREQUAL "lldb" AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-glldb")
|
||||
else()
|
||||
message(WARNING "Unable to tune for PREFERRED_DEBUGGER: "
|
||||
"'${PREFERRED_DEBUGGER}' with compiler: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
endif()
|
||||
|
||||
# Setup external dependencies. Use EXCLUDE_FROM_ALL to prevent *installing* libs.
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/../libs libs EXCLUDE_FROM_ALL)
|
||||
include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${FMT_INCLUDE_DIR})
|
||||
|
||||
# Include memgraph headers
|
||||
set(memgraph_src_dir ${PROJECT_SOURCE_DIR}/../src)
|
||||
include_directories(${memgraph_src_dir})
|
||||
# Everything that is installed here, should be under the "tools" component.
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "tools")
|
||||
|
||||
add_subdirectory(src)
|
||||
enable_testing()
|
||||
|
@ -9,7 +9,7 @@ TIMEOUT=600 ./init
|
||||
bash -c "doxygen Doxyfile >/dev/null 2>/dev/null"
|
||||
|
||||
cd build
|
||||
cmake ..
|
||||
cmake -DTOOLS=ON ..
|
||||
TIMEOUT=1000 make -j$THREADS
|
||||
|
||||
cd ..
|
||||
@ -19,6 +19,7 @@ cd build_release
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark memgraph__stress
|
||||
|
||||
# Install tools, because they may be needed to run some benchmarks and tests.
|
||||
cd ../tools
|
||||
./setup
|
||||
|
||||
|
@ -13,7 +13,7 @@ TIMEOUT=600 ./init
|
||||
bash -c "doxygen Doxyfile >/dev/null 2>/dev/null"
|
||||
|
||||
cd build
|
||||
cmake -DTEST_COVERAGE=ON ..
|
||||
cmake -DTOOLS=ON -DTEST_COVERAGE=ON ..
|
||||
TIMEOUT=1000 make -j$THREADS
|
||||
|
||||
cd ..
|
||||
@ -32,6 +32,7 @@ cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark
|
||||
|
||||
# Install tools, because they may be needed to run some benchmarks and tests.
|
||||
cd ../../memgraph/tools
|
||||
./setup
|
||||
|
||||
|
@ -9,7 +9,7 @@ TIMEOUT=600 ./init
|
||||
bash -c "doxygen Doxyfile >/dev/null 2>/dev/null"
|
||||
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_READLINE=OFF ..
|
||||
cmake -DTOOLS=ON -DCMAKE_BUILD_TYPE=Release -DUSE_READLINE=OFF ..
|
||||
TIMEOUT=1000 make -j$THREADS
|
||||
|
||||
# Create a binary package (which can then be used for Docker image).
|
||||
@ -22,6 +22,7 @@ cpack -G DEB --config ../CPackConfig.cmake
|
||||
cd ../../docs/user_technical
|
||||
./bundle_community
|
||||
|
||||
# Install tools, because they may be needed to run some benchmarks and tests.
|
||||
cd ../../tools
|
||||
./setup
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@ -13,8 +14,7 @@ BASE_DIR_NAME = os.path.basename(BASE_DIR)
|
||||
BUILD_DIR = os.path.join(BASE_DIR, "build")
|
||||
LIBS_DIR = os.path.join(BASE_DIR, "libs")
|
||||
TESTS_DIR = os.path.join(BUILD_DIR, "tests")
|
||||
TOOLS_DIR = os.path.join(BASE_DIR, "tools")
|
||||
TOOLS_BUILD_DIR = os.path.join(TOOLS_DIR, "build")
|
||||
TOOLS_BUILD_DIR = os.path.join(BUILD_DIR, "tools")
|
||||
OUTPUT_DIR = os.path.join(BUILD_DIR, "apollo")
|
||||
|
||||
# output lists
|
||||
@ -120,6 +120,9 @@ outfile_paths = "\./" + cmd.replace("cppcheck", ".cppcheck_errors").replace(".",
|
||||
RUNS.append(generate_run("cppcheck", commands = 'TIMEOUT=1000 ./{} {}'.format(cmd, mode),
|
||||
infile = archive, outfile_paths = outfile_paths))
|
||||
|
||||
# TODO: Refactor apollo/generate to be a config file which specifies how
|
||||
# each test is run and which files it depends on.
|
||||
|
||||
# ctest tests
|
||||
ctest_output = run_cmd(["ctest", "-N"], TESTS_DIR)
|
||||
tests = []
|
||||
@ -128,9 +131,11 @@ tests = []
|
||||
CTEST_ORDER = {"unit": 0, "concurrent": 1}
|
||||
CTEST_DELIMITER = "__"
|
||||
for row in ctest_output.split("\n"):
|
||||
# filter rows to find tests, ctest prefixes all test names with BASE_DIR_NAME
|
||||
if row.count(BASE_DIR_NAME + CTEST_DELIMITER) == 0: continue
|
||||
name = row.split(":")[1].strip().replace(BASE_DIR_NAME + CTEST_DELIMITER, "")
|
||||
# Filter rows only containing tests.
|
||||
if not re.match("^\s*Test\s+#", row): continue
|
||||
test_name = row.split(":")[1].strip()
|
||||
# We prefix all test names with BASE_DIR_NAME
|
||||
name = test_name.replace(BASE_DIR_NAME + CTEST_DELIMITER, "")
|
||||
path = os.path.join(TESTS_DIR, name.replace(CTEST_DELIMITER, "/", 1))
|
||||
order = CTEST_ORDER.get(name.split(CTEST_DELIMITER)[0], len(CTEST_ORDER))
|
||||
tests.append((order, name, path))
|
||||
@ -312,7 +317,7 @@ ctest_output = run_cmd(["ctest", "-N"], TOOLS_BUILD_DIR)
|
||||
tools_infile = create_archive("tools_test", [TOOLS_BUILD_DIR], cwd = WORKSPACE_DIR)
|
||||
for row in ctest_output.split("\n"):
|
||||
# Filter rows only containing tests.
|
||||
if "Test #" not in row: continue
|
||||
if not re.match("^\s*Test\s+#", row): continue
|
||||
test_name = row.split(":")[1].strip()
|
||||
test_dir = os.path.relpath(TOOLS_BUILD_DIR, WORKSPACE_DIR)
|
||||
commands = "cd {}\nctest --output-on-failure -R \"^{}$\"".format(test_dir, test_name)
|
||||
|
@ -9,8 +9,13 @@ cd ${script_dir}/build
|
||||
|
||||
# Setup cmake
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DTOOLS=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=${script_dir} \
|
||||
${script_dir}
|
||||
${script_dir}/..
|
||||
|
||||
# Install the tools
|
||||
make -j$(nproc) install
|
||||
make -j$(nproc) tools
|
||||
cmake -DCOMPONENT=tools -P cmake_install.cmake
|
||||
cd ${script_dir}
|
||||
mv bin/* ./
|
||||
rm -rf bin build
|
||||
|
@ -1,22 +1,5 @@
|
||||
add_executable(mg_import_csv
|
||||
mg_import_csv/main.cpp
|
||||
# This is just friggin terrible. mg_import_csv needs to depend almost on
|
||||
# the whole memgraph, just to use TypedValue and BaseEncoder.
|
||||
${memgraph_src_dir}/communication/bolt/v1/decoder/decoded_value.cpp
|
||||
${memgraph_src_dir}/data_structures/concurrent/skiplist_gc.cpp
|
||||
${memgraph_src_dir}/database/graph_db_accessor.cpp
|
||||
${memgraph_src_dir}/durability/paths.cpp
|
||||
${memgraph_src_dir}/durability/snapshooter.cpp
|
||||
${memgraph_src_dir}/durability/wal.cpp
|
||||
${memgraph_src_dir}/query/typed_value.cpp
|
||||
${memgraph_src_dir}/storage/edge_accessor.cpp
|
||||
${memgraph_src_dir}/storage/locking/record_lock.cpp
|
||||
${memgraph_src_dir}/storage/property_value.cpp
|
||||
${memgraph_src_dir}/storage/record_accessor.cpp
|
||||
${memgraph_src_dir}/storage/vertex_accessor.cpp
|
||||
${memgraph_src_dir}/transactions/engine_master.cpp
|
||||
${memgraph_src_dir}/transactions/engine_worker.cpp
|
||||
)
|
||||
add_executable(mg_import_csv mg_import_csv/main.cpp)
|
||||
target_link_libraries(mg_import_csv memgraph_lib)
|
||||
|
||||
# Strip the executable in release build.
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build_type)
|
||||
@ -26,7 +9,7 @@ if (lower_build_type STREQUAL "release")
|
||||
COMMENT Stripping symbols and sections from mg_import_csv)
|
||||
endif()
|
||||
|
||||
target_link_libraries(mg_import_csv stdc++fs Threads::Threads fmt
|
||||
gflags glog cppitertools)
|
||||
install(TARGETS mg_import_csv
|
||||
RUNTIME DESTINATION .)
|
||||
install(TARGETS mg_import_csv RUNTIME DESTINATION bin)
|
||||
|
||||
# Target for building all the tool executables.
|
||||
add_custom_target(tools DEPENDS mg_import_csv)
|
||||
|
@ -1,29 +1,7 @@
|
||||
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
|
||||
|
||||
add_executable(mg_recovery_check
|
||||
mg_recovery_check.cpp
|
||||
${memgraph_src_dir}/communication/bolt/v1/decoder/decoded_value.cpp
|
||||
${memgraph_src_dir}/data_structures/concurrent/skiplist_gc.cpp
|
||||
${memgraph_src_dir}/database/graph_db.cpp
|
||||
${memgraph_src_dir}/database/graph_db_config.cpp
|
||||
${memgraph_src_dir}/database/graph_db_accessor.cpp
|
||||
${memgraph_src_dir}/durability/paths.cpp
|
||||
${memgraph_src_dir}/durability/recovery.cpp
|
||||
${memgraph_src_dir}/durability/snapshooter.cpp
|
||||
${memgraph_src_dir}/durability/wal.cpp
|
||||
${memgraph_src_dir}/query/typed_value.cpp
|
||||
${memgraph_src_dir}/storage/edge_accessor.cpp
|
||||
${memgraph_src_dir}/storage/locking/record_lock.cpp
|
||||
${memgraph_src_dir}/storage/property_value.cpp
|
||||
${memgraph_src_dir}/storage/record_accessor.cpp
|
||||
${memgraph_src_dir}/storage/vertex_accessor.cpp
|
||||
${memgraph_src_dir}/transactions/engine_master.cpp
|
||||
${memgraph_src_dir}/transactions/engine_worker.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mg_recovery_check stdc++fs Threads::Threads fmt glog
|
||||
gflags cppitertools)
|
||||
target_link_libraries(mg_recovery_check gtest gtest_main)
|
||||
add_executable(mg_recovery_check mg_recovery_check.cpp)
|
||||
target_link_libraries(mg_recovery_check memgraph_lib gtest gtest_main)
|
||||
|
||||
# Copy CSV data to CMake build dir
|
||||
configure_file(csv/comment_nodes.csv csv/comment_nodes.csv COPYONLY)
|
||||
|
Loading…
Reference in New Issue
Block a user