Build rust modules from the binary directory

Our crates has configuration files:
- config for cargo (see config.toml.in)
- and possibly config for build (build.rs.in)

Previously it uses source directory, and it will overrides files in the
source directory, which will require recompile of crates in case of
multiple builds for one source directory.

To avoid overlaps different builds for one source directory, crate will
be copied from source directory to the binary directory.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-12-30 17:58:18 +01:00
parent bc456feb4b
commit 89c071e291

View File

@ -39,5 +39,21 @@ function(clickhouse_import_crate)
corrosion_import_crate(NO_STD ${ARGN}) corrosion_import_crate(NO_STD ${ARGN})
endfunction() endfunction()
add_subdirectory (BLAKE3) # Add crate from the build directory.
add_subdirectory (skim) #
# Our crates has configuration files:
# - config for cargo (see config.toml.in)
# - and possibly config for build (build.rs.in)
#
# And to avoid overlaps different builds for one source directory, crate will
# be copied from source directory to the binary directory.
file(COPY ".cargo" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
function(add_rust_subdirectory src)
set(dst "${CMAKE_CURRENT_BINARY_DIR}/${src}")
message(STATUS "Copy ${src} to ${dst}")
file(COPY "${src}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
add_subdirectory("${dst}" "${dst}")
endfunction()
add_rust_subdirectory (BLAKE3)
add_rust_subdirectory (skim)