From df689dccd5071781e44370e732a3ca7c36036968 Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Thu, 14 Oct 2021 18:58:42 +0200 Subject: [PATCH] Make Memgraph work with fetch content (#256) --- CMakeLists.txt | 17 ++++++++----- src/lisp/CMakeLists.txt | 54 ++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5036165fa..62fd92cef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ if (MG_ENTERPRISE) else() set(get_version_offering "--open-source") endif() -set(get_version_script "${CMAKE_SOURCE_DIR}/release/get_version.py") +set(get_version_script "${CMAKE_CURRENT_SOURCE_DIR}/release/get_version.py") # Get version that should be used in the binary. execute_process( @@ -76,7 +76,7 @@ execute_process( "${MEMGRAPH_OVERRIDE_VERSION}" "${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}" "--memgraph-root-dir" - "${CMAKE_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" ) if(MEMGRAPH_VERSION_RESULT AND NOT MEMGRAPH_VERSION_RESULT EQUAL 0) message(FATAL_ERROR "Unable to get Memgraph version.") @@ -93,7 +93,7 @@ execute_process( "${MEMGRAPH_OVERRIDE_VERSION}" "${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}" "--memgraph-root-dir" - "${CMAKE_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" ) if(MEMGRAPH_VERSION_DEB_RESULT AND NOT MEMGRAPH_VERSION_DEB_RESULT EQUAL 0) message(FATAL_ERROR "Unable to get Memgraph DEB version.") @@ -110,7 +110,7 @@ execute_process( "${MEMGRAPH_OVERRIDE_VERSION}" "${MEMGRAPH_OVERRIDE_VERSION_SUFFIX}" "--memgraph-root-dir" - "${CMAKE_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" ) if(MEMGRAPH_VERSION_RPM_RESULT AND NOT MEMGRAPH_VERSION_RPM_RESULT EQUAL 0) message(FATAL_ERROR "Unable to get Memgraph RPM version.") @@ -331,8 +331,13 @@ add_subdirectory(src) # Release configuration add_subdirectory(release) -enable_testing() -add_subdirectory(tests) +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() if(TOOLS) add_subdirectory(tools) diff --git a/src/lisp/CMakeLists.txt b/src/lisp/CMakeLists.txt index 474bcc674..f23f04cfe 100644 --- a/src/lisp/CMakeLists.txt +++ b/src/lisp/CMakeLists.txt @@ -2,19 +2,19 @@ # Don't forget to repeat this list below in `define_add_lcp`. set(lcp_src_files - ${CMAKE_SOURCE_DIR}/src/lisp/lcp.asd - ${CMAKE_SOURCE_DIR}/src/lisp/compile-lcp - ${CMAKE_SOURCE_DIR}/src/lisp/package.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/names.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/types.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/clone.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/code-gen.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/slk.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/debug.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/test.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/util.lisp - ${CMAKE_SOURCE_DIR}/tools/lcp) + ${PROJECT_SOURCE_DIR}/src/lisp/lcp.asd + ${PROJECT_SOURCE_DIR}/src/lisp/compile-lcp + ${PROJECT_SOURCE_DIR}/src/lisp/package.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/names.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/types.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/clone.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/code-gen.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/slk.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/lcp.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/debug.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/test.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/util.lisp + ${PROJECT_SOURCE_DIR}/tools/lcp) # Make `lcp_src_files` a persistent (cache) variable so that # tests/unit/CMakeLists.txt can see it. @@ -65,21 +65,21 @@ macro(define_add_lcp name main_src_files generated_lcp_files) # Repeat the `lcp_src_files` because this is a macro and the variable is # not visible when invoked in another file. set(lcp_src_files - ${CMAKE_SOURCE_DIR}/src/lisp/lcp.asd - ${CMAKE_SOURCE_DIR}/src/lisp/compile-lcp - ${CMAKE_SOURCE_DIR}/src/lisp/package.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/names.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/types.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/clone.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/code-gen.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/slk.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/debug.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/test.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/util.lisp - ${CMAKE_SOURCE_DIR}/tools/lcp) + ${PROJECT_SOURCE_DIR}/src/lisp/lcp.asd + ${PROJECT_SOURCE_DIR}/src/lisp/compile-lcp + ${PROJECT_SOURCE_DIR}/src/lisp/package.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/names.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/types.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/clone.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/code-gen.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/slk.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/lcp.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/debug.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/test.lisp + ${PROJECT_SOURCE_DIR}/src/lisp/util.lisp + ${PROJECT_SOURCE_DIR}/tools/lcp) add_custom_command(OUTPUT ${h_file} ${cpp_file} - COMMAND ${CMAKE_SOURCE_DIR}/tools/lcp ${lcp_file} ${slk_serialize} + COMMAND ${PROJECT_SOURCE_DIR}/tools/lcp ${lcp_file} ${slk_serialize} VERBATIM DEPENDS ${lcp_src_files} lcp ${lcp_file} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})