2016-12-18 04:00:32 +08:00
|
|
|
# MemGraph CMake configuration
|
|
|
|
|
2019-04-23 17:00:49 +08:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
2016-05-16 04:43:42 +08:00
|
|
|
|
2016-12-18 04:00:32 +08:00
|
|
|
# !! IMPORTANT !! run ./project_root/init.sh before cmake command
|
|
|
|
# to download dependencies
|
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
if(NOT UNIX)
|
2018-01-15 19:19:55 +08:00
|
|
|
message(FATAL_ERROR "Unsupported operating system.")
|
2017-02-17 23:11:57 +08:00
|
|
|
endif()
|
|
|
|
|
2017-03-08 15:59:37 +08:00
|
|
|
# Set `make clean` to ignore outputs of add_custom_command. If generated files
|
|
|
|
# need to be cleaned, set ADDITIONAL_MAKE_CLEAN_FILES property.
|
|
|
|
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM TRUE)
|
|
|
|
|
2017-03-08 01:25:49 +08:00
|
|
|
# ccache setup
|
|
|
|
# ccache isn't enabled all the time because it makes some problem
|
|
|
|
# during the code coverage process
|
2017-03-08 15:59:37 +08:00
|
|
|
find_program(CCACHE_FOUND ccache)
|
2017-03-08 01:25:49 +08:00
|
|
|
option(USE_CCACHE "ccache:" ON)
|
|
|
|
message(STATUS "CCache: ${USE_CCACHE}")
|
|
|
|
if(CCACHE_FOUND AND USE_CCACHE)
|
2017-02-23 22:34:04 +08:00
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
2017-03-08 01:25:49 +08:00
|
|
|
endif(CCACHE_FOUND AND USE_CCACHE)
|
2017-02-23 22:34:04 +08:00
|
|
|
|
2017-03-17 23:57:43 +08:00
|
|
|
# choose a compiler
|
2017-12-04 20:56:17 +08:00
|
|
|
# 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})
|
2019-04-19 16:44:25 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't find clang and/or clang++!")
|
2017-12-04 20:56:17 +08:00
|
|
|
endif()
|
|
|
|
|
2020-02-11 23:39:54 +08:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
project(memgraph)
|
|
|
|
|
2021-10-03 18:07:04 +08:00
|
|
|
# Install licenses.
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/licenses/
|
|
|
|
DESTINATION share/doc/memgraph)
|
|
|
|
|
2020-02-11 23:39:54 +08:00
|
|
|
# For more information about how to release a new version of Memgraph, see
|
|
|
|
# `release/README.md`.
|
|
|
|
|
|
|
|
# Option that is used to specify which version of Memgraph should be built. The
|
|
|
|
# default is `ON` which causes the build system to build Memgraph Enterprise.
|
|
|
|
# Memgraph Community is built if explicitly set to `OFF`.
|
|
|
|
option(MG_ENTERPRISE "Build Memgraph Enterprise Edition" ON)
|
|
|
|
|
|
|
|
# Set the current version here to override the automatic version detection. The
|
|
|
|
# version must be specified as `X.Y.Z`. Primarily used when building new patch
|
|
|
|
# versions.
|
|
|
|
set(MEMGRAPH_OVERRIDE_VERSION "")
|
|
|
|
|
|
|
|
# Custom suffix that this version should have. The suffix can be any arbitrary
|
|
|
|
# string. Primarily used when building a version for a specific customer.
|
|
|
|
set(MEMGRAPH_OVERRIDE_VERSION_SUFFIX "")
|
|
|
|
|
|
|
|
# Variables used to generate the versions.
|
|
|
|
if (MG_ENTERPRISE)
|
2021-09-30 01:14:39 +08:00
|
|
|
set(get_version_offering "")
|
2020-02-11 23:39:54 +08:00
|
|
|
else()
|
2021-09-30 01:14:39 +08:00
|
|
|
set(get_version_offering "--open-source")
|
2020-02-11 23:39:54 +08:00
|
|
|
endif()
|
2021-10-15 00:58:42 +08:00
|
|
|
set(get_version_script "${CMAKE_CURRENT_SOURCE_DIR}/release/get_version.py")
|
2020-02-11 23:39:54 +08:00
|
|
|
|
|
|
|
# Get version that should be used in the binary.
|
2017-12-04 20:56:17 +08:00
|
|
|
execute_process(
|
2020-02-11 23:39:54 +08:00
|
|
|
OUTPUT_VARIABLE MEMGRAPH_VERSION
|
2020-12-21 21:57:43 +08:00
|
|
|
RESULT_VARIABLE MEMGRAPH_VERSION_RESULT
|
2021-09-30 01:14:39 +08:00
|
|
|
COMMAND "${get_version_script}" ${get_version_offering}
|
2020-02-11 23:39:54 +08:00
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION}"
|
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}"
|
2021-03-15 18:55:39 +08:00
|
|
|
"--memgraph-root-dir"
|
2021-10-15 00:58:42 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
2017-12-04 20:56:17 +08:00
|
|
|
)
|
2020-12-21 21:57:43 +08:00
|
|
|
if(MEMGRAPH_VERSION_RESULT AND NOT MEMGRAPH_VERSION_RESULT EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Unable to get Memgraph version.")
|
|
|
|
else()
|
|
|
|
MESSAGE(STATUS "Memgraph version: ${MEMGRAPH_VERSION}")
|
|
|
|
endif()
|
2017-12-04 20:56:17 +08:00
|
|
|
|
2020-02-11 23:39:54 +08:00
|
|
|
# Get version that should be used in the DEB package.
|
|
|
|
execute_process(
|
|
|
|
OUTPUT_VARIABLE MEMGRAPH_VERSION_DEB
|
2020-12-21 21:57:43 +08:00
|
|
|
RESULT_VARIABLE MEMGRAPH_VERSION_DEB_RESULT
|
2021-09-30 01:14:39 +08:00
|
|
|
COMMAND "${get_version_script}" ${get_version_offering}
|
2020-02-11 23:39:54 +08:00
|
|
|
--variant deb
|
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION}"
|
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}"
|
2021-03-15 18:55:39 +08:00
|
|
|
"--memgraph-root-dir"
|
2021-10-15 00:58:42 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
2020-02-11 23:39:54 +08:00
|
|
|
)
|
2020-12-21 21:57:43 +08:00
|
|
|
if(MEMGRAPH_VERSION_DEB_RESULT AND NOT MEMGRAPH_VERSION_DEB_RESULT EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Unable to get Memgraph DEB version.")
|
|
|
|
else()
|
|
|
|
MESSAGE(STATUS "Memgraph DEB version: ${MEMGRAPH_VERSION_DEB}")
|
|
|
|
endif()
|
2020-02-11 23:39:54 +08:00
|
|
|
|
|
|
|
# Get version that should be used in the RPM package.
|
|
|
|
execute_process(
|
|
|
|
OUTPUT_VARIABLE MEMGRAPH_VERSION_RPM
|
2020-12-21 21:57:43 +08:00
|
|
|
RESULT_VARIABLE MEMGRAPH_VERSION_RPM_RESULT
|
2021-09-30 01:14:39 +08:00
|
|
|
COMMAND "${get_version_script}" ${get_version_offering}
|
2020-02-11 23:39:54 +08:00
|
|
|
--variant rpm
|
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION}"
|
|
|
|
"${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}"
|
2021-03-15 18:55:39 +08:00
|
|
|
"--memgraph-root-dir"
|
2021-10-15 00:58:42 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
2020-02-11 23:39:54 +08:00
|
|
|
)
|
2020-12-21 21:57:43 +08:00
|
|
|
if(MEMGRAPH_VERSION_RPM_RESULT AND NOT MEMGRAPH_VERSION_RPM_RESULT EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Unable to get Memgraph RPM version.")
|
|
|
|
else()
|
|
|
|
MESSAGE(STATUS "Memgraph RPM version: ${MEMGRAPH_VERSION_RPM}")
|
|
|
|
endif()
|
2020-02-11 23:39:54 +08:00
|
|
|
|
|
|
|
# We want the above variables to be updated each time something is committed to
|
|
|
|
# the repository. That is why we include a dependency on the current git HEAD
|
|
|
|
# to trigger a new CMake run when the git repository state changes. This is a
|
|
|
|
# hack, as CMake doesn't have a mechanism to regenerate variables when
|
|
|
|
# something changes (only files can be regenerated).
|
|
|
|
# https://cmake.org/pipermail/cmake/2018-October/068389.html
|
|
|
|
#
|
|
|
|
# The hack in the above link is nearly correct but it has a fatal flaw. The
|
|
|
|
# `CMAKE_CONFIGURE_DEPENDS` isn't a `GLOBAL` property, it is instead a
|
|
|
|
# `DIRECTORY` property and as such must be set in the `DIRECTORY` scope.
|
|
|
|
# https://cmake.org/cmake/help/v3.14/manual/cmake-properties.7.html
|
|
|
|
#
|
|
|
|
# Unlike the above mentioned hack, we don't use the `.git/index` file. That
|
|
|
|
# file changes on every `git add` (even on `git status`) so it triggers
|
|
|
|
# unnecessary recalculations of the release version. The release version only
|
|
|
|
# changes on every `git commit` or `git checkout`. That is why we watch the
|
|
|
|
# following files for changes:
|
|
|
|
# - `.git/HEAD` -> changes each time a `git checkout` is issued
|
|
|
|
# - `.git/refs/heads/...` -> the value in `.git/HEAD` is a branch name (when
|
|
|
|
# you are on a branch) and you have to monitor the file of the specific
|
|
|
|
# branch to detect when a `git commit` was issued
|
|
|
|
# More details about the contents of the `.git` directory and the specific
|
|
|
|
# files used can be seen here:
|
|
|
|
# https://git-scm.com/book/en/v2/Git-Internals-Git-References
|
|
|
|
set(git_directory "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
if (EXISTS "${git_directory}")
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY
|
|
|
|
CMAKE_CONFIGURE_DEPENDS "${git_directory}/HEAD")
|
|
|
|
file(STRINGS "${git_directory}/HEAD" git_head_data)
|
|
|
|
if (git_head_data MATCHES "^ref: ")
|
|
|
|
string(SUBSTRING "${git_head_data}" 5 -1 git_head_ref)
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY
|
|
|
|
CMAKE_CONFIGURE_DEPENDS "${git_directory}/${git_head_ref}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-12-18 04:00:32 +08:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2016-05-16 04:43:42 +08:00
|
|
|
|
2016-11-19 00:35:29 +08:00
|
|
|
# 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)
|
2016-12-18 04:00:32 +08:00
|
|
|
# custom function definitions
|
|
|
|
include(functions)
|
|
|
|
# -----------------------------------------------------------------------------
|
2016-06-26 00:26:26 +08:00
|
|
|
|
2017-03-06 23:15:20 +08:00
|
|
|
# We want out of source builds, so that cmake generated files don't get mixed
|
|
|
|
# with source files. This allows for easier clean up.
|
|
|
|
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}")
|
2016-12-18 04:00:32 +08:00
|
|
|
# -----------------------------------------------------------------------------
|
2016-08-08 16:32:34 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
# build flags -----------------------------------------------------------------
|
|
|
|
|
2019-04-23 21:05:17 +08:00
|
|
|
# Export the compile commands so that we can use clang-tidy. Additional benefit
|
|
|
|
# is easier debugging of compilation and linker flags.
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2020-11-17 17:07:31 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2019-04-23 17:00:49 +08:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2020-11-13 03:18:11 +08:00
|
|
|
# c99-designator is disabled because of required mixture of designated and
|
|
|
|
# non-designated initializers in Python Query Module code (`py_module.cpp`).
|
2019-04-23 17:00:49 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
|
2019-09-17 19:33:18 +08:00
|
|
|
-Werror=switch -Werror=switch-bool -Werror=return-type \
|
2020-11-13 03:18:11 +08:00
|
|
|
-Werror=return-stack-address \
|
2022-04-27 16:13:16 +08:00
|
|
|
-Wno-c99-designator \
|
|
|
|
-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT")
|
2017-10-20 22:53:24 +08:00
|
|
|
|
2017-08-30 21:37:00 +08:00
|
|
|
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
|
|
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
Change to gold linker.
Summary:
Benchmark conducted showed positive performance change, a gain of ~20%.
Setup:
ccache disabled (export CCACHE_DISABLE=1)
cd build
rm -rf *
cmake ..
time make -j8
without gold linker
real 3m25,384s
user 11m58,337s
sys 0m37,747s
real 3m48,087s
user 12m57,600s
sys 0m36,837s
real 3m20,116s
user 12m9,570s
sys 0m33,643s
with gold linker
real 2m48,073s
user 10m2,257s
sys 0m27,480s
real 2m55,673s
user 10m13,420s
sys 0m27,233s
real 2m47,866s
user 10m2,377s
sys 0m27,323s
Reviewers: teon.banek, mislav.bradac, florijan, mferencevic
Reviewed By: mferencevic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D903
2017-10-17 17:24:22 +08:00
|
|
|
|
2018-03-20 18:12:20 +08:00
|
|
|
# Statically link libgcc and libstdc++, the GCC allows this according to:
|
2020-11-13 03:18:11 +08:00
|
|
|
# https://gcc.gnu.org/onlinedocs/gcc-10.2.0/libstdc++/manual/manual/license.html
|
2018-03-20 18:12:20 +08:00
|
|
|
# https://www.gnu.org/licenses/gcc-exception-faq.html
|
2020-11-13 03:18:11 +08:00
|
|
|
# Last checked for gcc-10.2 which we are using on the build machines.
|
2018-03-20 18:12:20 +08:00
|
|
|
# ** If we change versions, recheck this! **
|
|
|
|
# ** Static linking is allowed only for executables! **
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
|
Change to gold linker.
Summary:
Benchmark conducted showed positive performance change, a gain of ~20%.
Setup:
ccache disabled (export CCACHE_DISABLE=1)
cd build
rm -rf *
cmake ..
time make -j8
without gold linker
real 3m25,384s
user 11m58,337s
sys 0m37,747s
real 3m48,087s
user 12m57,600s
sys 0m36,837s
real 3m20,116s
user 12m9,570s
sys 0m33,643s
with gold linker
real 2m48,073s
user 10m2,257s
sys 0m27,480s
real 2m55,673s
user 10m13,420s
sys 0m27,233s
real 2m47,866s
user 10m2,377s
sys 0m27,323s
Reviewers: teon.banek, mislav.bradac, florijan, mferencevic
Reviewed By: mferencevic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D903
2017-10-17 17:24:22 +08:00
|
|
|
# Use gold linker to speedup build
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
2016-06-27 06:43:28 +08:00
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
# release flags
|
2017-06-05 22:48:47 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
2017-12-04 20:56:17 +08:00
|
|
|
|
2022-02-14 21:31:27 +08:00
|
|
|
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -pthread")
|
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
#debug flags
|
2017-06-05 22:48:47 +08:00
|
|
|
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()
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
# default build type is debug
|
2017-10-03 19:56:41 +08:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
2017-08-30 21:37:00 +08:00
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
2017-02-17 23:11:57 +08:00
|
|
|
endif()
|
|
|
|
message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2022-02-03 20:03:35 +08:00
|
|
|
set(MG_ARCH "x86_64" CACHE STRING "Host architecture to build Memgraph on. Supported values are x86_64 (default), ARM64.")
|
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
# setup external dependencies -------------------------------------------------
|
2016-05-23 13:51:36 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
# threading
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
# optional readline
|
|
|
|
option(USE_READLINE "Use GNU Readline library if available (default ON). \
|
|
|
|
Set this to OFF to prevent linking with Readline even if it is available." ON)
|
|
|
|
if (USE_READLINE)
|
|
|
|
find_package(Readline)
|
|
|
|
if (READLINE_FOUND)
|
|
|
|
add_definitions(-DHAS_READLINE)
|
|
|
|
endif()
|
2016-06-15 06:06:21 +08:00
|
|
|
endif()
|
2016-12-18 04:00:32 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
set(libs_dir ${CMAKE_SOURCE_DIR}/libs)
|
|
|
|
add_subdirectory(libs EXCLUDE_FROM_ALL)
|
2016-12-18 04:00:32 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
# Optional subproject configuration -------------------------------------------
|
2018-01-15 19:19:55 +08:00
|
|
|
option(TEST_COVERAGE "Generate coverage reports from running memgraph" OFF)
|
2018-03-27 04:35:55 +08:00
|
|
|
option(TOOLS "Build tools binaries" ON)
|
Integrate loading openCypher module procedures
Summary:
All mgp_* symbols are exported from Memgraph executable, no other
symbols should be visible.
The primary C API header, mg_procedure.h, is now part of the
installation. Also, added a shippable query module example.
Directory `query_modules` is meant to contain sources of modules we
write and ship as part of the installation. Currently, there's only an
example module, but there may be potentially more. Some modules could
only be installed as part of the enterprise release.
For Memgraph to load custom procedures, it needs to be started with a
flag pointing to a directory with compiled shared libraries implementing
those procedures.
Reviewers: mferencevic, ipaljak, llugovic, dsantl, buda
Reviewed By: mferencevic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D2538
2019-10-31 23:36:34 +08:00
|
|
|
option(QUERY_MODULES "Build query modules containing custom procedures" ON)
|
2018-05-28 17:04:09 +08:00
|
|
|
option(ASAN "Build with Address Sanitizer. To get a reasonable performance option should be used only in Release or RelWithDebInfo build " OFF)
|
|
|
|
option(TSAN "Build with Thread Sanitizer. To get a reasonable performance option should be used only in Release or RelWithDebInfo build " OFF)
|
|
|
|
option(UBSAN "Build with Undefined Behaviour Sanitizer" OFF)
|
2017-12-04 20:56:17 +08:00
|
|
|
|
2018-01-15 19:19:55 +08:00
|
|
|
if (TEST_COVERAGE)
|
|
|
|
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build_type)
|
|
|
|
if (NOT lower_build_type STREQUAL "debug")
|
|
|
|
message(FATAL_ERROR "Generating test coverage unsupported in non Debug builds. Current build type is '${CMAKE_BUILD_TYPE}'")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
|
|
|
endif()
|
|
|
|
|
2020-02-05 22:05:18 +08:00
|
|
|
if (MG_ENTERPRISE)
|
|
|
|
add_definitions(-DMG_ENTERPRISE)
|
|
|
|
endif()
|
|
|
|
|
2021-09-21 20:43:27 +08:00
|
|
|
set(ENABLE_JEMALLOC ON)
|
|
|
|
|
2018-05-28 17:04:09 +08:00
|
|
|
if (ASAN)
|
2021-09-21 20:43:27 +08:00
|
|
|
message(WARNING "Disabling jemalloc as it doesn't work well with ASAN")
|
|
|
|
set(ENABLE_JEMALLOC OFF)
|
2018-05-28 17:04:09 +08:00
|
|
|
# Enable Addres sanitizer and get nicer stack traces in error messages.
|
|
|
|
# NOTE: AddressSanitizer uses llvm-symbolizer binary from the Clang
|
|
|
|
# distribution to symbolize the stack traces (note that ideally the
|
|
|
|
# llvm-symbolizer version must match the version of ASan runtime library).
|
|
|
|
# Just make sure llvm-symbolizer is in PATH before running the binary or
|
|
|
|
# provide it in separate ASAN_SYMBOLIZER_PATH environment variable.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
|
|
|
# To detect Stack-use-after-return bugs set run-time flag:
|
|
|
|
# ASAN_OPTIONS=detect_stack_use_after_return=1
|
|
|
|
# To check initialization order bugs set run-time flag:
|
|
|
|
# ASAN_OPTIONS=check_initialization_order=true
|
|
|
|
# This mode reports an error if initializer for a global variable accesses
|
|
|
|
# dynamically initialized global from another translation unit, which is
|
|
|
|
# not yet initialized
|
|
|
|
# ASAN_OPTIONS=strict_init_order=true
|
|
|
|
# This mode reports an error if initializer for a global variable accesses
|
|
|
|
# any dynamically initialized global from another translation unit.
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TSAN)
|
|
|
|
# ThreadSanitizer generally requires all code to be compiled with -fsanitize=thread.
|
|
|
|
# If some code (e.g. dynamic libraries) is not compiled with the flag, it can
|
|
|
|
# lead to false positive race reports, false negative race reports and/or
|
|
|
|
# missed stack frames in reports depending on the nature of non-instrumented
|
|
|
|
# code. To not produce false positive reports ThreadSanitizer has to see all
|
|
|
|
# synchronization in the program, some synchronization operations (namely,
|
|
|
|
# atomic operations and thread-safe static initialization) are intercepted
|
|
|
|
# during compilation (and can only be intercepted during compilation).
|
|
|
|
# ThreadSanitizer stack trace collection also relies on compiler instrumentation
|
|
|
|
# (unwinding stack on each memory access is too expensive).
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
|
|
|
|
# By default ThreadSanitizer uses addr2line utility to symbolize reports.
|
|
|
|
# llvm-symbolizer is faster, consumes less memory and produces much better
|
|
|
|
# reports. To use it set runtime flag:
|
|
|
|
# TSAN_OPTIONS="extern-symbolizer-path=~/llvm-symbolizer"
|
|
|
|
# For more runtime flags see: https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (UBSAN)
|
|
|
|
# Compile with UBSAN but disable vptr check. This is disabled because it
|
|
|
|
# requires linking with clang++ to make sure C++ specific parts of the
|
|
|
|
# runtime library and c++ standard libraries are present.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize=vptr")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-sanitize=vptr")
|
2021-04-01 23:08:40 +08:00
|
|
|
# Run program with environment variable UBSAN_OPTIONS=print_stacktrace=1.
|
|
|
|
# Make sure llvm-symbolizer binary is in path.
|
|
|
|
# To make the program abort on undefined behavior, use UBSAN_OPTIONS=halt_on_error=1.
|
2018-05-28 17:04:09 +08:00
|
|
|
endif()
|
|
|
|
|
2022-01-18 15:23:17 +08:00
|
|
|
set(MG_PYTHON_VERSION "" CACHE STRING "Specify the exact Python version used by the query modules")
|
|
|
|
set(MG_PYTHON_PATH "" CACHE STRING "Specify the exact Python path used by the query modules")
|
2020-12-21 20:21:51 +08:00
|
|
|
|
2018-01-15 19:19:55 +08:00
|
|
|
# Add subprojects
|
|
|
|
include_directories(src)
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
2020-02-03 23:22:34 +08:00
|
|
|
# Release configuration
|
|
|
|
add_subdirectory(release)
|
|
|
|
|
2021-10-15 00:58:42 +08:00
|
|
|
option(MG_ENABLE_TESTING "Set this to OFF to disable building test binaries" ON)
|
|
|
|
message(STATUS "MG_ENABLE_TESTING: ${MG_ENABLE_TESTING}")
|
|
|
|
|
|
|
|
if (MG_ENABLE_TESTING)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2016-10-13 21:42:19 +08:00
|
|
|
|
2017-12-04 20:56:17 +08:00
|
|
|
if(TOOLS)
|
|
|
|
add_subdirectory(tools)
|
2016-08-10 16:39:02 +08:00
|
|
|
endif()
|
2017-12-04 20:56:17 +08:00
|
|
|
|
Integrate loading openCypher module procedures
Summary:
All mgp_* symbols are exported from Memgraph executable, no other
symbols should be visible.
The primary C API header, mg_procedure.h, is now part of the
installation. Also, added a shippable query module example.
Directory `query_modules` is meant to contain sources of modules we
write and ship as part of the installation. Currently, there's only an
example module, but there may be potentially more. Some modules could
only be installed as part of the enterprise release.
For Memgraph to load custom procedures, it needs to be started with a
flag pointing to a directory with compiled shared libraries implementing
those procedures.
Reviewers: mferencevic, ipaljak, llugovic, dsantl, buda
Reviewed By: mferencevic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D2538
2019-10-31 23:36:34 +08:00
|
|
|
if(QUERY_MODULES)
|
|
|
|
add_subdirectory(query_modules)
|
|
|
|
endif()
|
2021-05-26 17:59:36 +08:00
|
|
|
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/bin/mgconsole
|
|
|
|
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
|
|
TYPE BIN)
|