diff --git a/cmake/Corrosion.cmake b/cmake/Corrosion.cmake index fbea65f4..0a9b67ea 100644 --- a/cmake/Corrosion.cmake +++ b/cmake/Corrosion.cmake @@ -232,7 +232,7 @@ function(_corrosion_copy_byproduct_legacy target_name cargo_build_dir file_names set(output_dir "${CMAKE_CURRENT_BINARY_DIR}") endif() - string(REPLACE "::" "__" target_name_cmake_underscore ${target_name}) + string(MAKE_C_IDENTIFIER ${target_name} target_name_cmake_underscore) list(TRANSFORM file_names PREPEND "${cargo_build_dir}/" OUTPUT_VARIABLE src_file_names) list(TRANSFORM file_names PREPEND "${output_dir}/" OUTPUT_VARIABLE dst_file_names) @@ -258,7 +258,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name car endif() get_target_property(output_dir ${target_name} "${output_dir_prop_name}") - string(REPLACE "::" "__" target_name_cmake_underscore ${target_name}) + string(MAKE_C_IDENTIFIER ${target_name} target_name_cmake_underscore) # A Genex expanding to the output directory depending on the configuration. set(multiconfig_out_dir_genex "") @@ -445,7 +445,7 @@ function(_corrosion_add_library_target) add_library(${target_name_cmake} INTERFACE IMPORTED GLOBAL) - string(REPLACE "::" "__" target_name_cmake_underscore ${target_name_cmake}) + string(MAKE_C_IDENTIFIER ${target_name_cmake} target_name_cmake_underscore) if(has_staticlib) add_library(${target_name_cmake_underscore}-static STATIC IMPORTED GLOBAL) @@ -529,7 +529,7 @@ function(_corrosion_add_bin_target workspace_manifest_path bin_name target_name_ endif() set(${out_bin_byproduct} "${bin_filename}" PARENT_SCOPE) - string(REPLACE "::" "__" target_name_cmake_underscore ${target_name_cmake}) + string(MAKE_C_IDENTIFIER ${target_name_cmake} target_name_cmake_underscore) # Todo: This is compatible with the way corrosion previously exposed the bin name, # but maybe we want to prefix the exposed name with the package name? @@ -682,7 +682,7 @@ function(_add_cargo_build out_cargo_build_out_dir) set(package_name "${ACB_PACKAGE}") set(target_name "${ACB_TARGET}") set(target_name_cmake "${ACB_TARGET_NAME_CMAKE}") - string(REPLACE "::" "__" target_name_cmake_underscore ${target_name_cmake}) + string(MAKE_C_IDENTIFIER ${target_name_cmake} target_name_cmake_underscore) set(path_to_toml "${ACB_MANIFEST_PATH}") set(target_kinds "${ACB_TARGET_KINDS}") set(workspace_manifest_path "${ACB_WORKSPACE_MANIFEST_PATH}")