Skip to content

Commit

Permalink
avoid list expand for genexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Sep 20, 2023
1 parent 06ec1b1 commit a8de72a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if(NOT(ZENOHC_CUSTOM_TARGET STREQUAL ""))
endif()
set(cargo_binary_dir_debug ${cargo_target_dir_debug}/debug)
set(cargo_binary_dir_release ${cargo_target_dir_release}/release)
set_genexpr_condition(cargo_binary_dir DEBUG $<CONFIG:Debug> ${cargo_binary_dir_debug} ${cargo_binary_dir_release}>)
set_genexpr_condition(cargo_binary_dir DEBUG $<CONFIG:Debug> ${cargo_binary_dir_debug} ${cargo_binary_dir_release})
set(source_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)

function(configure_cargo_toml cargo_toml_dir CARGO_PROJECT_VERSION CARGO_LIB_NAME)
Expand Down Expand Up @@ -185,7 +185,7 @@ endif()
status_print(cargo_flags)
status_print(libs)
add_custom_command(
OUTPUT "${libs}"
OUTPUT ${libs}
COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\"
COMMAND ${CMAKE_COMMAND} -E echo \"cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\"
COMMAND cargo +${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}
Expand Down
14 changes: 8 additions & 6 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,24 @@ endfunction()
# - remove visual garbage when generator expressions actually does nothing
# - avoid using generator expression if single-config generator is used
#
macro(set_genexpr_condition dstvar var_condition genexpr_condition srcvar_true srcvar_false)
function(set_genexpr_condition dstvar var_condition genexpr_condition srcvar_true srcvar_false)
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG AND NOT("${srcvar_true}" STREQUAL "${srcvar_false}"))
set(${dstvar} $<IF:${genexpr_condition},${srcvar_true},${srcvar_false}>)
list(JOIN srcvar_true "$<SEMICOLON>" srcvar_true)
list(JOIN srcvar_false "$<SEMICOLON>" srcvar_false)
set(${dstvar} $<IF:${genexpr_condition},${srcvar_true},${srcvar_false}> PARENT_SCOPE)
else()
if(DEFINED ${var_condition})
if (${${var_condition}})
set(${dstvar} "${srcvar_true}")
set(${dstvar} "${srcvar_true}" PARENT_SCOPE)
else()
set(${dstvar} "${srcvar_false}")
set(${dstvar} "${srcvar_false}" PARENT_SCOPE)
endif()
else()
set(${dstvar} "${srcvar_false}")
set(${dstvar} "${srcvar_false}" PARENT_SCOPE)
endif()
endif()
endmacro()
endfunction()

#
# Select default build config with support of multi config generators
Expand Down

0 comments on commit a8de72a

Please sign in to comment.