Make antlr4 ExternalProject
Summary: There's no need to rebuild antlr every time we recompile memgraph. This should speed up the `make clean all` cycle. Reviewers: mislav.bradac, mferencevic, buda Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D817
This commit is contained in:
parent
f060ad3f43
commit
a390d0994c
@ -195,7 +195,6 @@ include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# openCypher parser -----------------------------------------------------------
|
||||
set(antlr_src ${CMAKE_SOURCE_DIR}/libs/antlr4/runtime/Cpp/runtime/src)
|
||||
set(opencypher_frontend ${CMAKE_SOURCE_DIR}/src/query/frontend/opencypher)
|
||||
set(opencypher_generated ${opencypher_frontend}/generated)
|
||||
set(opencypher_grammar ${opencypher_frontend}/grammar/Cypher.g4)
|
||||
@ -223,17 +222,11 @@ add_custom_target(generate_opencypher_parser
|
||||
DEPENDS ${antlr_opencypher_generated_src})
|
||||
|
||||
# include antlr header files
|
||||
include_directories(
|
||||
${antlr_src}
|
||||
${antlr_src}/misc
|
||||
${antlr_src}/atn
|
||||
${antlr_src}/dfa
|
||||
${antlr_src}/tree
|
||||
${antlr_src}/support
|
||||
)
|
||||
include_directories(${ANTLR4_INCLUDE_DIR})
|
||||
|
||||
add_library(antlr_opencypher_parser_lib STATIC ${antlr_opencypher_generated_src})
|
||||
target_link_libraries(antlr_opencypher_parser_lib antlr4_static)
|
||||
add_dependencies(antlr_opencypher_parser_lib antlr4)
|
||||
target_link_libraries(antlr_opencypher_parser_lib ${ANTLR4_LIBRARY})
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# all memgraph src files
|
||||
|
@ -1,9 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
include(ExternalProject)
|
||||
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(NPROC)
|
||||
if (NPROC EQUAL 0)
|
||||
set(NPROC 1)
|
||||
endif()
|
||||
|
||||
# setup antlr
|
||||
option(WITH_LIBCXX "" OFF) # because of debian bug
|
||||
# http://stackoverflow.com/questions/37096062/get-a-basic-c-program-to-compile-using-clang-on-ubuntu-16/38385967#38385967
|
||||
add_subdirectory(antlr4/runtime/Cpp)
|
||||
ExternalProject_Add(antlr4
|
||||
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp
|
||||
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp
|
||||
# http://stackoverflow.com/questions/37096062/get-a-basic-c-program-to-compile-using-clang-on-ubuntu-16/38385967#38385967
|
||||
-DWITH_LIBCXX=OFF # because of debian bug
|
||||
BUILD_COMMAND make -j${NPROC}
|
||||
# Make a License.txt out of thin air, so that antlr4.6 knows how to build.
|
||||
# When we upgrade antlr, this will no longer be needed.
|
||||
INSTALL_COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp/License.txt
|
||||
COMMAND make install)
|
||||
set(ANTLR4_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp/lib/libantlr4-runtime.a
|
||||
CACHE FILEPATH "Path to antlr4 library" FORCE)
|
||||
set(ANTLR4_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp/include/antlr4-runtime
|
||||
CACHE PATH "Path to antlr4 include directory" FORCE)
|
||||
mark_as_advanced(ANTLR4_LIBRARY ANTLR4_INCLUDE_DIR)
|
||||
|
||||
# setup google benchmark
|
||||
add_subdirectory(benchmark)
|
||||
@ -29,15 +52,15 @@ add_subdirectory(gflags)
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVED})
|
||||
|
||||
# Setup google logging after gflags (so that glog can use it).
|
||||
# We need to use `ExternalProject`, because currently glog's CMakeLists.txt
|
||||
# doesn't detect gflags if we do `add_subdirectory`.
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(glog DEPENDS gflags
|
||||
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/glog
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glog
|
||||
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/glog
|
||||
-Dgflags_DIR=${CMAKE_CURRENT_BINARY_DIR}/gflags)
|
||||
-Dgflags_DIR=${CMAKE_CURRENT_BINARY_DIR}/gflags
|
||||
BUILD_COMMAND make -j${NPROC})
|
||||
set(GLOG_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/glog/lib/libglog.a CACHE FILEPATH
|
||||
"Path to glog library" FORCE)
|
||||
set(GLOG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glog/include CACHE PATH
|
||||
|
Loading…
Reference in New Issue
Block a user