XXX:

This could lead to problems if there are different versions that are not
compatible with one another.

- Avoid an error occurring if the version of MODCARGO_CRATES (cxxbridge-cmd,
  cxx) and the ports version of devel/cxxbridge-cmd are different.

Index: cmake/Corrosion.cmake
--- cmake/Corrosion.cmake.orig
+++ cmake/Corrosion.cmake
@@ -1813,16 +1813,18 @@ function(corrosion_add_cxxbridge cxx_target)
 
     get_filename_component(manifest_dir ${manifest_path} DIRECTORY)
 
-    _corrosion_check_cxx_version("${manifest_dir}" cxx_required_version)
+    if(NOT DEFINED ENV{MODCMAKE_PORT_BUILD})
+        _corrosion_check_cxx_version("${manifest_dir}" cxx_required_version)
+    endif()
 
-    if(NOT cxx_required_version)
+    if(NOT cxx_required_version AND NOT DEFINED ENV{MODCMAKE_PORT_BUILD})
         message(FATAL_ERROR
                 "Failed to find a dependency on `cxxbridge-cmd` / `cxx` for crate ${_arg_CRATE}"
         )
     endif()
 
     # First check if a suitable version of cxxbridge is installed
-    find_program(INSTALLED_CXXBRIDGE cxxbridge PATHS "$ENV{HOME}/.cargo/bin/")
+    find_program(INSTALLED_CXXBRIDGE cxxbridge PATHS "${LOCALBASE}/bin/")
     mark_as_advanced(INSTALLED_CXXBRIDGE)
     if(INSTALLED_CXXBRIDGE)
         execute_process(COMMAND ${INSTALLED_CXXBRIDGE} --version OUTPUT_VARIABLE cxxbridge_version_output)
@@ -1832,15 +1834,19 @@ function(corrosion_add_cxxbridge cxx_target)
             set(cxxbridge_version "")
         endif()
     endif()
-
-    set(cxxbridge "")
-    if(cxxbridge_version)
-        if(cxxbridge_version VERSION_EQUAL cxx_required_version)
-            set(cxxbridge "${INSTALLED_CXXBRIDGE}")
-            if(NOT TARGET "cxxbridge_v${cxx_required_version}")
-                # Add an empty target.
-                add_custom_target("cxxbridge_v${cxx_required_version}"
-                    )
+    if(DEFINED ENV{MODCMAKE_PORT_BUILD})
+        set(cxxbridge "${INSTALLED_CXXBRIDGE}")
+        add_custom_target("cxxbridge_v${cxx_version}")
+    else()
+        set(cxxbridge "")
+        if(cxxbridge_version)
+            if(cxxbridge_version VERSION_EQUAL cxx_required_version)
+                set(cxxbridge "${INSTALLED_CXXBRIDGE}")
+                if(NOT TARGET "cxxbridge_v${cxx_required_version}")
+                    # Add an empty target.
+                    add_custom_target("cxxbridge_v${cxx_required_version}"
+                        )
+                endif()
             endif()
         endif()
     endif()
