Skip to content

Commit 1e8511b

Browse files
authored
Update corrosion verion to 0.5.1 (#93)
* Squashed 'corrosion/' changes from a597833..b1fab72 b1fab72 Update release notes for v0.5.1 015ca09 fix: update `FindRust` to work with rustup v1.28.0 a91e171 Fix FindRust setting Rust_Found=false in wrong scope 221de5e Create CMake targets earlier efbafe8 Legacy CMake: Respect `CMAKE_<XYZ>_OUTPUT_DIRECTORY` 64289b1 Prepare v0.5 release fd400a1 Breaking: Replace dashes with underscores in lib names 9943de7 Remove duplicate line from Release notes 04f378c Prepare v0.4.10 release 9d20d4e Remove duplicate line c21fb5f Set `_CORROSION_VERBOSE_OUTPUT_FLAG` as cache entry e050826 Simplify `_corrosion_copy_byproducts()` 528cb7d msvc: handle flags that come from native-static-libs (#511) 91b2aaf Combine -framework arg flags to avoid linker errors 75f6d5b corrosion_link_libraries: Forward static libraries dependencies 8b04e05 Set AR_<triple> for cc-rs 05ca9d9 Backport recent cbindgen changes c86290c Consider vxworks executable suffix 8a443bb Fix hostbuild when crosscompiling to windows ff5a236 Prepare v0.4.9 release 2e2893e make find_package portable 118e926 Detect OpenHarmony Rust target 6f64bfb ci: bump actions to avoid deprecation notice 23c61fa Prepare v0.4.8 fa8b6f9 corrosion_import_crate: Fix PROFILE argument in combination with CRATES (#496) 8ddd6d5 Prepare v0.4.7 112c63e Fix _CORROSION_RUST_CARGO_TARGET_UNDERSCORE c8cd6ba Prepare v0.4.6 release 9d85753 Fix hostbuild when crosscompiling to windows be76480 Bump version number to v0.4.5 734102a Backport #437 windows hostbuild fix to v0.4 (#462) 38bd4dc Release v0.4.4 6381eaa Add unikraft to known vendors 8af2bfc Add "chimera" as a known triple vendor 91289e3 Clarify version v0.4 in documentation fed96bb Update version number to v0.4.3 c3b2411 Update release notes for v0.4.3 a758d22 Legacy Generator: Bump cargo metadata bb77bd5 Legacy Generator: Update serde past problematic version 7b51951 Legacy Generator: Pin Serde to 1.0.171 19a288a Select Legacy Generator lockfile based on Rust version 1752605 Move Legacy Generator CMake code b092ad7 CI: Test legacy CMake with nightly Rust 8187bec Fix PROFILE option on CMake 3.15 498c8c7 CI: Test legacy with stable. a9af44c Adjust target triple parsing warning message eb7998f Relax espressif vendor parsing cd50a12 Remove unused legacy fn _corrosion_determine_libs 3ff339a Refactor detecting required link libraries 1912677 Update release notes for v0.4.2 89841b2 Fix detecting required libraries with cargo 1.71 and workspaces 419f615 Use lockfile for legacy generator 9eb2931 Add documentation to global corrosion options 317e53a Add test to FindRust with Rust_USE_RUSTUP_PROXY 5be52d4 Add option to compile with the rustup proxy binaries fc8dd40 Add debug output indicating the Corrosion version. 32e9af5 Add some instances of CMAKE_MESSAGE_CONTEXT c9141f2 Fix passing target when linking via clang 4a134df Add an issue template 6ae04cf Bump version and update docs 58126f6 Fix: Improve Multi-Config checks 51d3f6a Prepare v0.4 release notes de3f2f5 Improve Multi-Config checks d84acf8 Fix cargo tree to use the correct rustc executable bd196a3 Improve Multi-Config error message ea2d71b Fix determining required link libraries 3ae71ce Adjust release notes for v0.4 beta 1 96f6ccb Remove bors configuration 37ecd97 Add documentation on soname / install_name issue dc1e4e5 Rename cache variables for Rust Host info b64681a Fix cbindgen output name on windows 76577bb Improve required library detection for staticlibs b2f408c Improve error message if no package is imported 2542e2f Compare VS platform name case insensitively 4c36abf cxxbridge: set `cxx_std_11` as PUBLIC compile feature e516737 Fix cargo tree to use the correct cargo executable 14d5ecf Add some documentation on experimental cxxbridge integration eb003f2 cxxbridge: Always create bindings as a staticlib fbd599c Fix upstream toolchain toml issue for cxxbridge 63043bc Fix the cxxbridge test 0553bbc cxxbridge: Generate rust/cxx.h bce99c6 Add Release notes for v0.3.5 4567617 Fix generator build on older Rust versions 0032ad4 Move target detection to FindRust 9dc7ad6 adjust test rust version cbd3d82 tests: Add a build-script 7947f23 Cleanup Linker selection code 9aba08e Simplify NO_STD code 0d40fc8 Remove another unused internal variable cfd7ab9 Remove unused internal variable 411a7f3 Simplify Argument handling 7cf98bb Downgrade log-level for potentially erroneous arguments b9b8f92 Improve the cbindgen integration 04b2658 Set CARGO_BUILD_RUSTC when building the Legacy Generator ff6b1dc Prevent RUSTFLAGS from breaking Corrosion's own build-time code (#354) f212db0 Update corrosion_import_crate documentation bd03800 Fix cxxbridge test on windows MSVC a770f60 Document msvcrt linking issues. 17e6316 test: Fix passing through Generator in install test 15f7b31 Fix Windows CI failure e2451ae CI: chain commands to detect failures on windows 717fc2c Add status messages when building Corrosion generator e0eda70 Support more options on legacy generator 4f2cd17 Fix cbindgen dependency when cbindgen is not installed. 74edbbc Add test for `IMPORTED_CRATES` option a8a4d6c Add "alpine" as a known triple vendor 32d6c20 Replace legacy Generator print-root subcommand d4c3b0f Add --locked and --frozen options 325f5e0 Add v0.3.4 Release notes. d67dbc8 Merge #337 5c57821 Fix hostbuild with clang as the linker 82037f5 Simplify hostbuild genex 735bdec Set IMPORTED_NO_SONAME for shared libraries f41501f Refactor _corrosion_add_library argument parsing a17666f tests: Remove unused parameters from gensource test 009b87c Improve Argument checking and forwarding 1985ea2 Bump the legacy generator dependencies 83d7664 Pass --no-deps to cargo metadata 46a19fb CI: Reduce cxxbridge job runtime 5f8ca01 Add some documentation on linking c4e6acb Add an experimental cbindgen integration 61cbb71 CI: Use stable-2 toolchain for cxxbridge ed191d2 Add target property to override rustc/cargo d46bf3b FindRust: Expose discovered rustup toolchains a093f42 Slightly improve the documentation. 97dffef Add gitlab pages job for mdbook abd758b Migrate documentation to mdbook 2d71b99 Add v0.3.3 Release notes 67232bc Fix imported location target property when target contains dashes and CORROSION_RESPECT_OUTPUT_DIRECTORY is true d605f2c Merge #308 f7fe45a CI: improve status check job. 6c3b53d Fix misspelled corrosion_set_cargo_flags 25308e5 Improve cxxbridge test 56f6900 cxxbridge: Relax build dependency 6694349 Fix build status badge (#318) 65dda75 Fix links to rust2cpp code in README 1b1dae3 Fix custom json targets aac8772 Fix PROFILE documentation 430b3cf Fix generator debug message 204927a Output Error if IMPORTED_CRATES is selected with CORROSION_NATIVE_TOOLING 44749a9 Add parameter to corrosion_import_crate to return list of added targets (#312) 34473df Allow overriding the cargo profile per target 7940cab tests: Add option to pass through arguments e3d8d20 Update Releases.md 86eedc0 Don't force enable a language when cross_compiling 3bd5ab2 Improve Windows target detection 4551db9 Merge #307 e604cab Add bors configuration b505ba6 CI: Prepare yaml config for bors 648f263 Fix profile output directory detection f2daee9 improve internal tests flexibility 49842f8 Warn when modifying linker options for static libs f750550 CI: Add job to test MSVC with clang++ (Gnu CLI) 10a29bb CI: Add explicit option to choose a "default" compiler 155e51c Fix multitarget test for Windows MSVC with clang e329b43 Raise error on corrosion_set_linker_language usage fda7c29 Update Readme to point to v0.3.2 0ba0021 Update Release notes for v0.3.2 c5bfc5d Skip `crate_type` test before CMake 3.19 47f905f FindRust: Fix version detection bd20aec FindRust: Fix trying to find rustup in Quiet mode bc1c817 Add fn to parse package version from Cargo.toml 58d979b Fix NO_LINKER_OVERRIDE e9a453d Fix clean target when cross-compiling bd53646 Update legacy generator dependencies 1923e34 CI: Test legacy jobs in parallel e0e7a7e Merge legacy jobs 11ef31c CI: Cache MSVC build directory ee7227d CI: group apt install log lines a687734 CI: Run tests in parallel d9da746 Fix install test fixture requirements d0e2c0f Restrict multitarget test to serial execution bece325 Properly cleanup after tests f02c651 Fix parallel tests 4d0b864 CI: Only run apt-update when necessary daf1aca CI: Cache cargo registry 4109a12 Do not build/install the Legacy Generator by default anymore 92a5a59 Get metadata with --locked if possible 87f8a16 tests: commit missing lock files 5f2c604 CI: fix cxxbridge caching fa4e241 Don't set linker for Rust static libraries 949ded9 CI: Add option to choose compiler 8eca76b Fix Multi-Config default out dir 4a3f940 Increase test log-level to Debug 80d58d0 Fix typo 91bcb5e tests: Only set System name when cross-compiling 8141452 Require CMake 3.20 for MSVC Generator (#265) 0cfe7e5 Add no linker override flag to corrosion_import_crate. (#272) 85fde50 Support CRATE_TYPES argument for corrosion_import_crate 90ed7e0 Update the Readme to point to 0.3.1 d19475a Update the Release notes for 0.3.1 f03517a Don't set linker for MSVC abi 7426f4a Fix output_directory support when not used as target property ae043e1 CI: only test MSRV with legacy generator 712dfcc CI: Simplify cxxbridge test 65a0bc2 CI: Reduce test time for legacy generator 1eb3bef CI: Add action option to specify install prefix c4a023a CI: Make abi optional for internal action b6297a8 Specify build/install interface for cxx target include directory so that the include directory is portable. 3691e80 cxxbridge: Remove Manifest dir parameter d7c7959 Build cxxbridge if necessary b921fd0 Do not set LIBRARY_PATH on macOS 13 6e49ba1 Fix windows abi detection cd55dc3 cxxbridge test: Require C++11 15a328c CI: Add caching for cxxbridge 449eff3 Fix cxxbridge CI job 625fd43 CI: Add simple CI test for cxxbridge b8b79fb Add test for cxxbridge 61cf13f Use TARGET signature on cargo-build_<target> to ensure up to date 04331ed Introduce function to create a cxxbridge target 0eea0cf CI: Replace actions-rs/toolchain 8897a29 CI: bump actions/checkout to v3 473e120 CI: Update install-cmake 4cd3263 CI: Upgrade actions/checkout to v3 c6508ab CI: Use reusable action 6e34e10 Convert CI step outputs to new syntax 9904002 Update Release Notes for v0.3 70c019a Document OUTPUT_DIRECTORY limitations 373a391 Document linking C/C++ into Rust 9c7dbab Add error message for unsupported configuration 7078af5 Fix Windows-latest CI issues 23603e8 Prepare for next Release 2091468 Add OUTPUT_DIRECTORY regression test 1e556cf Read OUTPUT_DIRECTORY property from main library target 533da78 Fix output directory test fixtures 5f97051 Update Release notes 847c0af FindRust: Remove unused `CARGO_RUST_FLAGS` 3d3181a Check if target is installed 2e5874e Find suitable rust version 01c8973 Improve Fallibility of FindRust bff8710 Update Release notes cd7f594 Remove deprecated functions/options a2a4fae Fix `POST_BUILD` custom commands accessing build artifacts 8c6ad3a Add test for post build custom command 6d5b680 Warn if CMake target exists 7fba4ab Update release notes a04260e Test OUTPUT_DIRECTORY relocations 6d37ca0 Add a Ninja Multi-Config test to CI. e04d2de Fix MSVC support pre 3.20 with `OUTPUT_DIRECTORY` 61bba7a Respect OUTPUT_DIRECTORY properties (CMake >= 3.19) 5401c57 Add test for Rustflags in .cargo/config.toml 5830bc9 CI: Reduce tested nightly combinations b8c24bb Increase macos-12 MSRV 67cd719 Fix Generator test fd081c1 Do not set HOST_CC c6743ea Refactor Corrosion tests to use ctest f6d2ab7 Fix target-triple parsing for thumbv8m targets d5c5fd5 Test linking shared Rust lib into cpp exe. 9f92fc3 Fix multitarget test 56469c4 FindRust: quote paths 55007a3 Fix target detection 0eb1eb8 Enable multitarget test for native generator a65e0ad Bump cargo metadata 6b154cb Simplify native CMake generator c55ac88 Move sharable generator functions to corrosion d88f8df Don't set `INTERFACE_LINK_LIBRARIES_<CONFIG>` 96d0804 Improve target-triple parsing a39685b Link system libraries depending on Rust version 29a999a Simplify adding targets in package 07562b0 Add test with multiple bins and library 7d5708c Support multiple targets per package d9dfdef Update release notes and readme b0b16b9 Use local_rustflags where appropriate 54096b6 Add support for local Rustflags 0bd27ca Rename rustflags variable to make global scope clear 63ba831 Always set IMPORTED_LOCATION e573f1b Improve cpp2rust test 1ed34be Revert: Remove --target linker arg f253909 Update Release notes for v0.2.2 cb4e49e Remove --target linker arg 858ed88 Allow explicitly setting the linker for rust executables a28109d Use VERBATIM for cargo build ba77065 Let Cargo choose the linker for corrosion-generator 196b99e CI: test PRs to all branches 5553297 Switch cargo build working directory to Manifest directory 3432875 Fix Rustflags test af3e0d6 Generator: Remove unused metadata command in 8798eb3 Silence warning for unused function parameter a6d8b6f Don't generate .cargo/config f63b87f Pass additonal argument to cargo build (#197) ca21ae1 Increase the MSRV for Corrosion to 1.46 ce00696 Use macos-12 in github actions d5330b3 Fix finding cargo on NixOS REVERT: a597833 Renamed "LINKER_LANGUAGE" parameter to "LINK_AS" to avoid clashing with CMake's variable. REVERT: 3500297 Adding option to specify linker language when compiling crate. This is to allow a crate to not have dependencies on the C++ standard lib when compiled from corrosion. git-subtree-dir: corrosion git-subtree-split: b1fab721655c5c4b1b08a083d3cd29f163af75d0 * add git ignore * fix accoring to clippy * fix check http up in tests
1 parent ace6db7 commit 1e8511b

File tree

10 files changed

+97
-142
lines changed

10 files changed

+97
-142
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cmake-build-release
55
.vs
66
.vscode
77
.idea
8+
.cache
89
questdb-rs/Cargo.lock
910
include/questdb/ingress/line_sender.gen.h
1011
cython/questdb/ingress/line_sender.pxd

corrosion/RELEASES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v0.5.1 (2024-12-29)
2+
3+
### Fixes
4+
5+
- Update FindRust to support `rustup` v1.28.0. Support for older rustup versions is retained,
6+
so updating corrosion quickly is recommended to all rustup users.
7+
18
# v0.5.0 (2024-05-11)
29

310
### Breaking Changes

corrosion/cmake/Corrosion.cmake

Lines changed: 27 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,6 @@ get_property(
107107
TARGET Rust::Cargo PROPERTY IMPORTED_LOCATION
108108
)
109109

110-
# Note: Legacy function, used when respecting the `XYZ_OUTPUT_DIRECTORY` target properties is not
111-
# possible.
112-
function(_corrosion_set_imported_location_legacy target_name base_property filename)
113-
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
114-
set(binary_root "${CMAKE_CURRENT_BINARY_DIR}/${config_type}")
115-
string(TOUPPER "${config_type}" config_type_upper)
116-
message(DEBUG "Setting ${base_property}_${config_type_upper} for target ${target_name}"
117-
" to `${binary_root}/${filename}`.")
118-
# For Multiconfig we want to specify the correct location for each configuration
119-
set_property(
120-
TARGET ${target_name}
121-
PROPERTY "${base_property}_${config_type_upper}"
122-
"${binary_root}/${filename}"
123-
)
124-
endforeach()
125-
if(NOT COR_IS_MULTI_CONFIG)
126-
set(binary_root "${CMAKE_CURRENT_BINARY_DIR}")
127-
endif()
128-
129-
message(DEBUG "Setting ${base_property} for target ${target_name}"
130-
" to `${binary_root}/${filename}`.")
131-
132-
# IMPORTED_LOCATION must be set regardless of possible overrides. In the multiconfig case,
133-
# the last configuration "wins".
134-
set_property(
135-
TARGET ${target_name}
136-
PROPERTY "${base_property}" "${binary_root}/${filename}"
137-
)
138-
endfunction()
139-
140110

141111
# Sets out_var to true if the byproduct copying and imported location is done in a deferred
142112
# manner to respect target properties, etc. that may be set later.
@@ -171,6 +141,9 @@ function(_corrosion_set_imported_location_deferred target_name base_property out
171141
else()
172142
set(output_dir_prop_target_name "${target_name}")
173143
endif()
144+
if(CORROSION_NATIVE_TOOLING)
145+
set(output_directory_property "INTERFACE_${output_directory_property}")
146+
endif()
174147

175148
# Append .exe suffix for executable by-products if the target is windows or if it's a host
176149
# build and the host is Windows.
@@ -262,39 +235,12 @@ function(_corrosion_set_imported_location target_name base_property output_direc
262235
if(defer)
263236
_corrosion_call_set_imported_location_deferred("${target_name}" "${base_property}" "${output_directory_property}" "${filename}")
264237
else()
265-
_corrosion_set_imported_location_legacy("${target_name}" "${base_property}" "${filename}")
238+
# We can't actually call the function in a deferred way, but we can still respect the output directory
239+
# variables that were set **before** importing the crate.
240+
_corrosion_set_imported_location_deferred("${target_name}" "${base_property}" "${output_directory_property}" "${filename}")
266241
endif()
267242
endfunction()
268243

269-
function(_corrosion_copy_byproduct_legacy target_name cargo_build_dir file_names)
270-
if(ARGN)
271-
message(FATAL_ERROR "Unexpected additional arguments")
272-
endif()
273-
274-
if(COR_IS_MULTI_CONFIG)
275-
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
276-
else()
277-
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}")
278-
endif()
279-
280-
list(TRANSFORM file_names PREPEND "${cargo_build_dir}/" OUTPUT_VARIABLE src_file_names)
281-
list(TRANSFORM file_names PREPEND "${output_dir}/" OUTPUT_VARIABLE dst_file_names)
282-
message(DEBUG "Adding command to copy byproducts `${file_names}` to ${dst_file_names}")
283-
add_custom_command(TARGET _cargo-build_${target_name}
284-
POST_BUILD
285-
COMMAND ${CMAKE_COMMAND} -E make_directory "${output_dir}"
286-
COMMAND
287-
${CMAKE_COMMAND} -E copy_if_different
288-
# tested to work with both multiple files and paths with spaces
289-
${src_file_names}
290-
"${output_dir}"
291-
BYPRODUCTS ${dst_file_names}
292-
COMMENT "Copying byproducts `${file_names}` to ${output_dir}"
293-
VERBATIM
294-
COMMAND_EXPAND_LISTS
295-
)
296-
endfunction()
297-
298244
function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names)
299245
if(ARGN)
300246
message(FATAL_ERROR "Unexpected additional arguments")
@@ -395,7 +341,7 @@ function(_corrosion_copy_byproducts target_name output_dir_prop_name cargo_build
395341
if(defer)
396342
_corrosion_call_copy_byproduct_deferred("${target_name}" "${output_dir_prop_name}" "${cargo_build_dir}" "${filenames}")
397343
else()
398-
_corrosion_copy_byproduct_legacy("${target_name}" "${cargo_build_dir}" "${filenames}")
344+
_corrosion_copy_byproduct_deferred("${target_name}" "${output_dir_prop_name}" "${cargo_build_dir}" "${filenames}")
399345
endif()
400346
endfunction()
401347

@@ -500,8 +446,6 @@ function(_corrosion_add_library_target)
500446
endif()
501447
set("${CALT_OUT_ARCHIVE_OUTPUT_BYPRODUCTS}" "${archive_output_byproducts}" PARENT_SCOPE)
502448

503-
add_library(${target_name} INTERFACE)
504-
505449
if(has_staticlib)
506450
add_library(${target_name}-static STATIC IMPORTED GLOBAL)
507451
add_dependencies(${target_name}-static cargo-build_${target_name})
@@ -583,20 +527,7 @@ function(_corrosion_add_bin_target workspace_manifest_path bin_name out_bin_bypr
583527

584528
set(bin_filename "${bin_name}")
585529
_corrosion_determine_deferred_byproduct_copying_and_import_location_handling("defer")
586-
if(defer)
587-
# .exe suffix will be added later, also depending on possible hostbuild
588-
# target property
589-
else()
590-
if(Rust_CARGO_TARGET_OS STREQUAL "windows")
591-
set(bin_filename "${bin_name}.exe")
592-
endif()
593-
endif()
594530
set(${out_bin_byproduct} "${bin_filename}" PARENT_SCOPE)
595-
596-
597-
# Todo: This is compatible with the way corrosion previously exposed the bin name,
598-
# but maybe we want to prefix the exposed name with the package name?
599-
add_executable(${bin_name} IMPORTED GLOBAL)
600531
add_dependencies(${bin_name} cargo-build_${bin_name})
601532

602533
if(Rust_CARGO_TARGET_OS STREQUAL "darwin")
@@ -1931,6 +1862,26 @@ function(corrosion_parse_package_version package_manifest_path out_package_versi
19311862
endif()
19321863
endfunction()
19331864

1865+
function(_corrosion_initialize_properties target_name)
1866+
set(prefix "")
1867+
if(CORROSION_NATIVE_TOOLING)
1868+
set(prefix "INTERFACE_")
1869+
endif()
1870+
# Initialize the `<XYZ>_OUTPUT_DIRECTORY` properties based on `CMAKE_<XYZ>_OUTPUT_DIRECTORY`.
1871+
foreach(output_var RUNTIME_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY)
1872+
if (DEFINED "CMAKE_${output_var}")
1873+
set_property(TARGET ${target_name} PROPERTY "${prefix}${output_var}" "${CMAKE_${output_var}}")
1874+
endif()
1875+
1876+
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
1877+
string(TOUPPER "${config_type}" config_type_upper)
1878+
if (DEFINED "CMAKE_${output_var}_${config_type_upper}")
1879+
set_property(TARGET ${target_name} PROPERTY "${prefix}${output_var}_${config_type_upper}" "${CMAKE_${output_var}_${config_type_upper}}")
1880+
endif()
1881+
endforeach()
1882+
endforeach()
1883+
endfunction()
1884+
19341885
# Helper macro to pass through an optional `OPTION` argument parsed via `cmake_parse_arguments`
19351886
# to another function that takes the same OPTION.
19361887
# If the option was set, then the variable <var_name> will be set to the same option name again,

corrosion/cmake/CorrosionGenerator.cmake

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ function(_generator_add_package_targets)
116116
set(shared_lib_byproduct "")
117117
set(pdb_byproduct "")
118118

119+
add_library(${target_name} INTERFACE)
120+
_corrosion_initialize_properties(${target_name})
119121
_corrosion_add_library_target(
120122
WORKSPACE_MANIFEST_PATH "${workspace_manifest_path}"
121123
TARGET_NAME "${target_name}"
@@ -161,6 +163,8 @@ function(_generator_add_package_targets)
161163
elseif("bin" IN_LIST kinds)
162164
set(bin_byproduct "")
163165
set(pdb_byproduct "")
166+
add_executable(${target_name} IMPORTED GLOBAL)
167+
_corrosion_initialize_properties(${target_name})
164168
_corrosion_add_bin_target("${workspace_manifest_path}" "${target_name}"
165169
"bin_byproduct" "pdb_byproduct"
166170
)
@@ -306,21 +310,4 @@ function(_generator_add_cargo_targets)
306310
if(GGC_IMPORTED_CRATES)
307311
set(${GGC_IMPORTED_CRATES} "${created_targets}" PARENT_SCOPE)
308312
endif()
309-
310-
foreach(target_name ${created_targets})
311-
foreach(output_var RUNTIME_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY)
312-
get_target_property(output_dir ${target_name} "${output_var}")
313-
if (NOT output_dir AND DEFINED "CMAKE_${output_var}")
314-
set_property(TARGET ${target_name} PROPERTY ${output_var} "${CMAKE_${output_var}}")
315-
endif()
316-
317-
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
318-
string(TOUPPER "${config_type}" config_type_upper)
319-
get_target_property(output_dir ${target_name} "${output_var}_${config_type_upper}")
320-
if (NOT output_dir AND DEFINED "CMAKE_${output_var}_${config_type_upper}")
321-
set_property(TARGET ${target_name} PROPERTY "${output_var}_${config_type_upper}" "${CMAKE_${output_var}_${config_type_upper}}")
322-
endif()
323-
endforeach()
324-
endforeach()
325-
endforeach()
326313
endfunction()

corrosion/cmake/FindRust.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ include(FindPackageHandleStandardArgs)
1717

1818
list(APPEND CMAKE_MESSAGE_CONTEXT "FindRust")
1919

20-
# Print error message and return.
20+
# Print error message and return. Should not be used from inside functions
2121
macro(_findrust_failed)
2222
if("${Rust_FIND_REQUIRED}")
2323
message(FATAL_ERROR ${ARGN})
2424
elseif(NOT "${Rust_FIND_QUIETLY}")
2525
message(WARNING ${ARGN})
2626
endif()
27-
# Note: PARENT_SCOPE is the scope of the caller of the caller of this macro.
28-
set(Rust_FOUND "" PARENT_SCOPE)
27+
set(Rust_FOUND "")
2928
return()
3029
endmacro()
3130

@@ -320,18 +319,18 @@ if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
320319
set(_DISCOVERED_TOOLCHAINS_VERSION "")
321320

322321
foreach(_TOOLCHAIN_RAW ${_TOOLCHAINS_RAW})
323-
if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
322+
if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(active\\)|\\(active, default\\)|\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
324323
set(_TOOLCHAIN "${CMAKE_MATCH_1}")
325324
set(_TOOLCHAIN_TYPE "${CMAKE_MATCH_2}")
326325

327326
set(_TOOLCHAIN_PATH "${CMAKE_MATCH_3}")
328327
set(_TOOLCHAIN_${_TOOLCHAIN}_PATH "${CMAKE_MATCH_3}")
329328

330-
if (_TOOLCHAIN_TYPE MATCHES ".*\\(default\\).*")
329+
if (_TOOLCHAIN_TYPE MATCHES ".*\\((active, )?default\\).*")
331330
set(_TOOLCHAIN_DEFAULT "${_TOOLCHAIN}")
332331
endif()
333332

334-
if (_TOOLCHAIN_TYPE MATCHES ".*\\(override\\).*")
333+
if (_TOOLCHAIN_TYPE MATCHES ".*\\((active|override)\\).*")
335334
set(_TOOLCHAIN_OVERRIDE "${_TOOLCHAIN}")
336335
endif()
337336

corrosion/generator/src/subcommands/gen_cmake/target.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ impl CargoTarget {
134134
writeln!(
135135
out_file,
136136
"
137+
add_library({target_name} INTERFACE)
138+
_corrosion_initialize_properties({target_name})
137139
_corrosion_add_library_target(
138140
WORKSPACE_MANIFEST_PATH \"{workspace_manifest_path}\"
139141
TARGET_NAME \"{target_name}\"
@@ -157,6 +159,8 @@ impl CargoTarget {
157159
writeln!(
158160
out_file,
159161
"
162+
add_executable({target_name} IMPORTED GLOBAL)
163+
_corrosion_initialize_properties({target_name})
160164
_corrosion_add_bin_target(\"{workspace_manifest_path}\" \"{target_name}\"
161165
bin_byproduct pdb_byproduct
162166
)
@@ -189,22 +193,22 @@ impl CargoTarget {
189193
190194
if(archive_byproducts)
191195
_corrosion_copy_byproducts(
192-
{target_name} ARCHIVE_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{archive_byproducts}}\" FALSE
196+
{target_name} INTERFACE_ARCHIVE_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{archive_byproducts}}\" FALSE
193197
)
194198
endif()
195199
if(shared_lib_byproduct)
196200
_corrosion_copy_byproducts(
197-
{target_name} LIBRARY_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{shared_lib_byproduct}}\" FALSE
201+
{target_name} INTERFACE_LIBRARY_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{shared_lib_byproduct}}\" FALSE
198202
)
199203
endif()
200204
if(pdb_byproduct)
201205
_corrosion_copy_byproducts(
202-
{target_name} PDB_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{pdb_byproduct}}\" FALSE
206+
{target_name} INTERFACE_PDB_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{pdb_byproduct}}\" FALSE
203207
)
204208
endif()
205209
if(bin_byproduct)
206210
_corrosion_copy_byproducts(
207-
{target_name} RUNTIME_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{bin_byproduct}}\" TRUE
211+
{target_name} INTERFACE_RUNTIME_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{bin_byproduct}}\" TRUE
208212
)
209213
endif()
210214
set_property(TARGET {target_name} PROPERTY INTERFACE_COR_CARGO_PACKAGE_NAME {package_name} )

corrosion/test/output directory/CMakeLists.txt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if(CMAKE_VERSION VERSION_LESS 3.19.0)
2-
return()
3-
endif()
4-
51
if(CMAKE_C_COMPILER)
62
set(TEST_C_COMPILER "C_COMPILER" "${CMAKE_C_COMPILER}")
73
endif()
@@ -33,7 +29,12 @@ if(CORROSION_TESTS_INSTALL_CORROSION)
3329
set_tests_properties("output_directory_build" PROPERTIES FIXTURES_REQUIRED "fixture_corrosion_install")
3430
endif()
3531

36-
foreach(output_approach targetprop var)
32+
set(test_variants "var")
33+
if(NOT CORROSION_NATIVE_TOOLING)
34+
list(APPEND test_variants "targetprop")
35+
endif()
36+
37+
foreach(output_approach ${test_variants})
3738
if(output_approach STREQUAL "targetprop")
3839
set(rust_proj_suffix "1")
3940
elseif(output_approach STREQUAL "var")
@@ -128,13 +129,15 @@ foreach(output_approach targetprop var)
128129

129130
endforeach()
130131

131-
add_test(NAME postbuild_custom_command
132-
COMMAND
133-
"${CMAKE_COMMAND}"
134-
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
135-
"${CMAKE_CURRENT_BINARY_DIR}/build/another_dir/moved_bin"
136-
)
137-
set_tests_properties("postbuild_custom_command" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
132+
if(NOT CORROSION_NATIVE_TOOLING)
133+
add_test(NAME postbuild_custom_command
134+
COMMAND
135+
"${CMAKE_COMMAND}"
136+
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
137+
"${CMAKE_CURRENT_BINARY_DIR}/build/another_dir/moved_bin"
138+
)
139+
set_tests_properties("postbuild_custom_command" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
140+
endif()
138141

139142
add_test(NAME "output_directory_cleanup" COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/build")
140143
set_tests_properties("output_directory_cleanup" PROPERTIES FIXTURES_CLEANUP "build_fixture_output_directory")

0 commit comments

Comments
 (0)