Skip to content

Commit

Permalink
cxxbridge: Link to static and shared crate
Browse files Browse the repository at this point in the history
This is a convenience for the user, as this is usually needed anyway.
  • Loading branch information
LeonMatthesKDAB committed Nov 27, 2024
1 parent b3dab27 commit 3f96705
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,13 @@ function(corrosion_add_cxxbridge cxx_target)
# cxx generated code is using c++11 features in headers, so propagate c++11 as minimal requirement
target_compile_features(${cxx_target} PUBLIC cxx_std_11)

if (TARGET "${_arg_CRATE}-static")
target_link_libraries(${cxx_target} PRIVATE "${_arg_CRATE}-static")
endif()
if (TARGET "${_arg_CRATE}-shared")
target_link_libraries(${cxx_target} PRIVATE "${_arg_CRATE}-shared")
endif()

file(MAKE_DIRECTORY "${generated_dir}/include/rust")
add_custom_command(
OUTPUT "${generated_dir}/include/rust/cxx.h"
Expand Down
1 change: 0 additions & 1 deletion test/cxxbridge/cxxbridge_rust2cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED 1)

corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml)
corrosion_add_cxxbridge(cxxbridge-cpp CRATE cxxbridge_crate MANIFEST_PATH rust FILES lib.rs foo/mod.rs)
target_link_libraries(cxxbridge-cpp PRIVATE cxxbridge_crate)

add_executable(cxxbridge-exe main.cpp)
target_link_libraries(cxxbridge-exe PUBLIC cxxbridge-cpp)
Expand Down

0 comments on commit 3f96705

Please sign in to comment.