Skip to content

Commit

Permalink
Attempt to limit deferred byproduct .exe suffix handling only to the …
Browse files Browse the repository at this point in the history
…actual bin byproduct and not .pdb files
  • Loading branch information
tronical committed Nov 3, 2023
1 parent b8a6b26 commit 85b8822
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 7 additions & 6 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function(_corrosion_copy_byproduct_legacy target_name cargo_build_dir file_names
)
endfunction()

function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names)
function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names is_binary)
if(ARGN)
message(FATAL_ERROR "Unexpected additional arguments")
endif()
Expand Down Expand Up @@ -323,8 +323,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name car

# Append .exe suffix for executable by-products if the target is windows or if it's a host
# build and the host is Windows.
get_target_property(target_type ${target_name} TYPE)
if(${target_type} STREQUAL "EXECUTABLE")
if(${is_binary})
_corrosion_bin_target_suffix(${target_name} "suffix")
if(suffix)
set(tmp_file_names "${file_names}")
Expand All @@ -351,7 +350,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name car
)
endfunction()

function(_corrosion_call_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names)
function(_corrosion_call_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names is_binary)
cmake_language(EVAL CODE "
cmake_language(DEFER
CALL
Expand All @@ -360,6 +359,7 @@ function(_corrosion_call_copy_byproduct_deferred target_name output_dir_prop_nam
[[${output_dir_prop_name}]]
[[${cargo_build_dir}]]
[[${file_names}]]
[[${is_binary}]]
)
")
endfunction()
Expand All @@ -372,10 +372,11 @@ endfunction()
# `RUNTIME_OUTPUT_DIRECTORY`)
# - cargo_build_dir: the directory cargo build places it's output artifacts in.
# - filenames: the file names of any output artifacts as a list.
function(_corrosion_copy_byproducts target_name output_dir_prop_name cargo_build_dir filenames)
# - is_binary: TRUE if the byproducts are program executables.
function(_corrosion_copy_byproducts target_name output_dir_prop_name cargo_build_dir filenames is_binary)
_corrosion_determine_deferred_byproduct_copying_and_import_location_handling("defer")
if(defer)
_corrosion_call_copy_byproduct_deferred("${target_name}" "${output_dir_prop_name}" "${cargo_build_dir}" "${filenames}")
_corrosion_call_copy_byproduct_deferred("${target_name}" "${output_dir_prop_name}" "${cargo_build_dir}" "${filenames}" "${is_binary}")
else()
_corrosion_copy_byproduct_legacy("${target_name}" "${cargo_build_dir}" "${filenames}")
endif()
Expand Down
10 changes: 5 additions & 5 deletions cmake/CorrosionGenerator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ function(_generator_add_package_targets)
)
if(archive_byproducts)
_corrosion_copy_byproducts(
${target_name} ARCHIVE_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${archive_byproducts}"
${target_name} ARCHIVE_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${archive_byproducts}" FALSE
)
endif()
if(shared_lib_byproduct)
_corrosion_copy_byproducts(
${target_name} LIBRARY_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${shared_lib_byproduct}"
${target_name} LIBRARY_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${shared_lib_byproduct}" FALSE
)
endif()
if(pdb_byproduct)
_corrosion_copy_byproducts(
${target_name} PDB_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${pdb_byproduct}"
${target_name} PDB_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${pdb_byproduct}" FALSE
)
endif()
list(APPEND corrosion_targets ${target_name})
Expand Down Expand Up @@ -174,11 +174,11 @@ function(_generator_add_package_targets)
${no_linker_override}
)
_corrosion_copy_byproducts(
${target_name} RUNTIME_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${bin_byproduct}"
${target_name} RUNTIME_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${bin_byproduct}" TRUE
)
if(pdb_byproduct)
_corrosion_copy_byproducts(
${target_name} PDB_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${pdb_byproduct}"
${target_name} PDB_OUTPUT_DIRECTORY "${cargo_build_out_dir}" "${pdb_byproduct}" FALSE
)
endif()
list(APPEND corrosion_targets ${target_name})
Expand Down

0 comments on commit 85b8822

Please sign in to comment.