rust: fix buidling modules with CMAKE_BUILD_TYPE in a different case

Before this patch corrosion requires that CMAKE_BUILD_TYPE matches the
CMAKE_CONFIGURATION_TYPES, which is
"RelWithDebInfo;Debug;Release;MinSizeRel", so that said, that if you
were using CMAKE_BUILD_TYPE=debug, it will not work.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-12-14 11:51:46 +01:00
parent f8c17d4a66
commit e7c5b48d84
3 changed files with 20 additions and 4 deletions

View File

@ -1,4 +1,3 @@
corrosion_import_crate(MANIFEST_PATH Cargo.toml NO_STD) clickhouse_import_crate(MANIFEST_PATH Cargo.toml)
target_include_directories(_ch_rust_blake3 INTERFACE include) target_include_directories(_ch_rust_blake3 INTERFACE include)
add_library(ch_rust::blake3 ALIAS _ch_rust_blake3) add_library(ch_rust::blake3 ALIAS _ch_rust_blake3)

View File

@ -22,5 +22,22 @@ macro(configure_rustc)
endmacro() endmacro()
configure_rustc() configure_rustc()
function(clickhouse_import_crate)
# This is a workaround for Corrosion case sensitive build type matching in
# _generator_add_cargo_targets(), that leads to different paths in
# IMPORTED_LOCATION and real path of the library.
#
# It uses CMAKE_CONFIGURATION_TYPES and $<CONFIG>, so here we preserve the
# case of ${CMAKE_BUILD_TYPE} in ${CMAKE_CONFIGURATION_TYPES}.
if ("${CMAKE_BUILD_TYPE_UC}" STREQUAL "DEBUG")
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE};release")
else()
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE};debug")
endif()
# NOTE: we may use LTO for rust too
corrosion_import_crate(NO_STD ${ARGN})
endfunction()
add_subdirectory (BLAKE3) add_subdirectory (BLAKE3)
add_subdirectory (skim) add_subdirectory (skim)

View File

@ -14,7 +14,7 @@ if (OS_FREEBSD)
return() return()
endif() endif()
corrosion_import_crate(MANIFEST_PATH Cargo.toml NO_STD) clickhouse_import_crate(MANIFEST_PATH Cargo.toml)
# -Wno-dollar-in-identifier-extension: cxx bridge complies names with '$' # -Wno-dollar-in-identifier-extension: cxx bridge complies names with '$'
# -Wno-unused-macros: unused CXXBRIDGE1_RUST_STRING # -Wno-unused-macros: unused CXXBRIDGE1_RUST_STRING