<snipped>

>
> Closes tarantool/tarantool#5688
> ---
> CMakeLists.txt | 8 +++++---
> src/CMakeLists.txt | 5 +++++
> src/lj_tools_conf.h.in | 6 ++++++
> src/luajit.c | 36 ++++++++++++++++++++++++++++--------
> tools/CMakeLists.txt | 2 ++
> 5 files changed, 46 insertions(+), 11 deletions(-)
> create mode 100644 src/lj_tools_conf.h.in
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 5348e043..619e9441 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -250,6 +250,11 @@ endif()
> # related compiler and linker flags passed. This should be done
> # the right way later.
>
> +# --- Tools --------------------------------------------------------------------
> +
> +add_subdirectory(tools)
> +set(LUAJIT_TOOLS_DIR "${LUAJIT_TOOLS_DIR}")
> +
> # --- Main source tree ---------------------------------------------------------
>
> add_subdirectory(src)
> @@ -258,9 +263,6 @@ add_subdirectory(src)
>
> add_subdirectory(etc)
>
> -# --- Tools --------------------------------------------------------------------
> -
> -add_subdirectory(tools)
Why do we need this code movement?
We need this because there is a template file, which CMake generates during the
build process.
>
> # --- Testing source tree ------------------------------------------------------
>
> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> index 809aac68..d9debccf 100644
> --- a/src/CMakeLists.txt
> +++ b/src/CMakeLists.txt
> @@ -142,6 +142,8 @@ make_source_list(SOURCES_CORE_NO_JIT_FFI
> ${SOURCES_UTILS}
> )
>
> +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lj_tools_conf.h.in ${CMAKE_CURRENT_SOURCE_DIR}/lj_tools_conf.h)
> +
> set(SOURCES_CORE ${SOURCES_CORE_NO_JIT_FFI})
>
> # Build JIT sources if JIT support is enabled.
> @@ -248,6 +250,9 @@ add_custom_target(
> jit/vmdef.lua
> )
>
> +# --- Generate luajit tools config header -------------------------------------
> +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lj_tools_conf.h.in ${CMAKE_CURRENT_SOURCE_DIR}/lj_tools_conf.h)
> +
> # --- Generate core and VM object files ---------------------------------------
>
> # Virtual machine.
> diff --git a/src/lj_tools_conf.h.in b/src/lj_tools_conf.h.in
> new file mode 100644
> index 00000000..366c3ec4
> --- /dev/null
> +++ b/src/lj_tools_conf.h.in
> @@ -0,0 +1,6 @@
> +#ifndef LJ_TOOLS_CONF_H
> +#define LJ_TOOLS_CONF_H
> +
> +#define PARSER_PATH "@LUAJIT_TOOLS_DIR@/memprof.lua"
> +
> +#endif
As I already said, this is a template file, which holds a path to
memprof.lua script after build completion. Thanks to this template,
the flag will properly work regardless of whether the luajit was
installed or not.
For what do we need this file?
<snipped>