From 30e18026a5a38bf99201c16caa2336333e7ce049 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Thu, 25 Oct 2018 16:36:05 +0200 Subject: [PATCH] Regenerate LCP files if the LCP itself changed Summary: Unfortunately, CMake macros cannot access variables defined in the file where macro is defined. This means that we have to repeat the values by hand in order to track the correct dependency of LCP. Reviewers: mtomic, llugovic, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1701 --- src/lisp/CMakeLists.txt | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lisp/CMakeLists.txt b/src/lisp/CMakeLists.txt index cad769efd..b84f14660 100644 --- a/src/lisp/CMakeLists.txt +++ b/src/lisp/CMakeLists.txt @@ -1,12 +1,13 @@ # Lisp C++ Preprocessing -set(lcp_exe ${CMAKE_SOURCE_DIR}/tools/lcp) +# 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/package.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp - ${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp - ${lcp_exe}) + ${CMAKE_SOURCE_DIR}/src/lisp/lcp.asd + ${CMAKE_SOURCE_DIR}/src/lisp/lcp-compile + ${CMAKE_SOURCE_DIR}/src/lisp/package.lisp + ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp + ${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp + ${CMAKE_SOURCE_DIR}/tools/lcp) add_custom_target(lcp DEPENDS ${lcp_src_files} @@ -46,10 +47,19 @@ macro(define_add_lcp name main_src_files generated_lcp_files) # Update *global* main_src_files set(${main_src_files} ${${main_src_files}} ${cpp_file} PARENT_SCOPE) endif() + # 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/lcp-compile + ${CMAKE_SOURCE_DIR}/src/lisp/package.lisp + ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp + ${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp + ${CMAKE_SOURCE_DIR}/tools/lcp) add_custom_command(OUTPUT ${h_file} ${cpp_file} ${capnp_file} COMMAND ${CMAKE_SOURCE_DIR}/tools/lcp ${lcp_file} ${capnp_id} VERBATIM - DEPENDS ${lcp_file} lcp ${capnp_depend} ${KW_DEPENDS} + DEPENDS ${lcp_src_files} lcp ${lcp_file} ${capnp_depend} ${KW_DEPENDS} 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)