Allow customizing the name of add_lcp in cmake

Summary:
This change should allow for multiple `add_lcp` functions to exist in a
single CMakeLists.txt, each adding LCP files to a different target.
Supporting this feature allows us to separate LCP files for single node
and distributed.

Reviewers: mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1613
This commit is contained in:
Teon Banek 2018-09-26 10:18:48 +02:00
parent 10556f0d3d
commit 23d712321b
3 changed files with 8 additions and 7 deletions

View File

@ -114,9 +114,10 @@ endmacro(define_add_capnp)
set(lcp_exe ${CMAKE_SOURCE_DIR}/tools/lcp)
set(lcp_src_files ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp ${lcp_exe})
# Define `add_lcp` function for registering a lcp file for generation.
# Define `add_lcp` function named `name` for registering a lcp file for generation.
#
# The `define_add_lcp` expects 2 arguments:
# The `define_add_lcp` expects 3 arguments:
# * name -- name for the function, you usually want `add_lcp`
# * main_src_files -- variable to be updated with generated cpp files
# * generated_lcp_files -- variable to be updated with generated hpp, cpp and capnp files
#
@ -130,8 +131,8 @@ set(lcp_src_files ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp ${lcp_exe})
# information will break RPC between different compilations of memgraph.
# Instead of CAPNP_SCHEMA, you may pass the CAPNP_DECLARATION option. This will
# generate serialization declarations but not the implementation.
macro(define_add_lcp main_src_files generated_lcp_files)
function(add_lcp lcp_file)
macro(define_add_lcp name main_src_files generated_lcp_files)
function(${name} lcp_file)
set(options CAPNP_DECLARATION)
set(one_value_kwargs CAPNP_SCHEMA)
set(multi_value_kwargs DEPENDS)
@ -159,5 +160,5 @@ macro(define_add_lcp main_src_files generated_lcp_files)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Update *global* generated_lcp_files
set(${generated_lcp_files} ${${generated_lcp_files}} ${h_file} ${cpp_file} ${capnp_file} PARENT_SCOPE)
endfunction(add_lcp)
endfunction(${name})
endmacro(define_add_lcp)

View File

@ -85,7 +85,7 @@ set(memgraph_src_files
define_add_capnp(memgraph_src_files generated_capnp_files)
define_add_lcp(memgraph_src_files generated_lcp_files)
define_add_lcp(add_lcp memgraph_src_files generated_lcp_files)
add_lcp(database/counters_rpc_messages.lcp CAPNP_SCHEMA @0x95a2c3ea3871e945)
add_capnp(database/counters_rpc_messages.capnp)

View File

@ -3,7 +3,7 @@ set(stats_src_files
stats.cpp)
define_add_capnp(stats_src_files stats_capnp_files)
define_add_lcp(stats_src_files stats_lcp_files)
define_add_lcp(add_lcp stats_src_files stats_lcp_files)
add_lcp(stats_rpc_messages.lcp CAPNP_SCHEMA @0xc19a87c81b9b4512)
add_capnp(stats_rpc_messages.capnp)