# How to install CXX\_MODULES\_BMI right without strange errors?

**URL:** https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675
**Category:** Code
**Created:** [December 19, 2023, 6:48am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675 "2023-12-19T06:48:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [December 19, 2023, 6:48am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675/1 "2023-12-19T06:48:59Z")

</div>

with this code

```cmake
#
# module with partitions
#
add_library(mod3 SHARED)
# cmake-format: off
target_sources(
  mod3
  PRIVATE mod3/mod3price.cpp mod3/mod3io.cpp
  PUBLIC FILE_SET cxx_modules3
         TYPE CXX_MODULES
         FILES
         mod3/mod3.cppm
         mod3/mod3customer.cppm # interface partition
         mod3/mod3order.cppm # internal partition
)
# cmake-format: on
target_compile_features(mod3 PUBLIC cxx_std_20)
target_link_libraries(mod3 PUBLIC fmt::fmt)
if(CMAKE_SKIP_INSTALL_RULES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
  target_link_libraries(mod3 PUBLIC $<BUILD_INTERFACE:project_warnings project_options>)
endif()
add_executable(testmod3 mod3/testmod3.cpp)
target_link_libraries(testmod3 mod3)
add_test(NAME testmod3 COMMAND testmod3)

if(CMAKE_SKIP_INSTALL_RULES)
  return()
endif()

# cmake-format: off
install(
  TARGETS modsimple # TODO(CK) mod1 mod2
          mod3
  EXPORT mymodules
  RUNTIME # Following options apply to runtime artifacts.
          COMPONENT Runtime
  LIBRARY # Following options apply to library artifacts.
          COMPONENT Runtime #
          NAMELINK_COMPONENT Development
  ARCHIVE # Following options apply to archive artifacts.
          COMPONENT Development
          DESTINATION lib/static
  CXX_MODULES_BMI # FIXME CXX_MODULES
          COMPONENT Development
          DESTINATION lib/bmi
  FILE_SET # Following options apply to file set HEADERS.
          HEADERS
          COMPONENT Development
)
# cmake-format: on

install(
  EXPORT mymodules
  NAMESPACE modules
  DESTINATION lib/mymodules
  CXX_MODULES_DIRECTORY lib/bmi
)

```

### I get the following error:

```bash
CMake Error at modules/CMakeLists.txt:109 (install):
  install TARGETS target mod3 is exported but not all of its interface file
  sets are installed

-- Configuring incomplete, errors occurred!

```

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [December 19, 2023, 11:15pm UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675/2 "2023-12-19T23:15:25Z")

</div>

### this works, but it seems complicated to me:

```cmake
#
# module with partitions
#
add_library(mod3 SHARED)
# cmake-format: off
target_sources(
  mod3
  PRIVATE mod3/mod3price.cpp mod3/mod3io.cpp
  PUBLIC FILE_SET cxx_modules3
         TYPE CXX_MODULES
         # BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/mod3
         FILES
         mod3/mod3.cppm
         mod3/mod3customer.cppm # interface partition
         mod3/mod3order.cppm # internal partition
)
# cmake-format: on
target_compile_features(mod3 PUBLIC cxx_std_20)
target_link_libraries(mod3 PUBLIC fmt::fmt)
if(CMAKE_SKIP_INSTALL_RULES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
  target_link_libraries(mod3 PUBLIC $<BUILD_INTERFACE:project_warnings project_options>)
endif()
add_executable(testmod3 mod3/testmod3.cpp)
target_link_libraries(testmod3 mod3)
add_test(NAME testmod3 COMMAND testmod3)

if(CMAKE_SKIP_INSTALL_RULES)
  return()
endif()

install(TARGETS modsimple)

# cmake-format: off
install(
  TARGETS mod3 # TODO(CK): mod2 mod1
  EXPORT CXXModules
  FILE_SET cxx_modules3
          COMPONENT Development
          DESTINATION lib/cxx/miu
  CXX_MODULES_BMI
          COMPONENT Development
          DESTINATION lib/cxx/bmi
)
# cmake-format: on

install(
  EXPORT CXXModules
  NAMESPACE mymodules::
  DESTINATION lib/cmake/mod3
  FILE mod3-targets.cmake
  CXX_MODULES_DIRECTORY mod3-cxx-modules
)

file(
  WRITE "${CMAKE_CURRENT_BINARY_DIR}/mod3-config.cmake"
  "include(\"\${CMAKE_CURRENT_LIST_DIR}/mod3-targets.cmake\")
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mod3-config.cmake" DESTINATION "lib/cmake/mod3")

```

```bash
cmake --build --preset Release --target install
[0/1] Install the project...
-- Install configuration: "Release"
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/libfmt.10.1.0.dylib
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/libfmt.10.dylib
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/libfmt.dylib
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/args.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/chrono.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/color.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/compile.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/core.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/format.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/format-inl.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/os.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/ostream.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/printf.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/ranges.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/std.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/include/fmt/xchar.h
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/fmt/fmt-config.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/fmt/fmt-config-version.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/fmt/fmt-targets.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/fmt/fmt-targets-release.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/pkgconfig/fmt.pc
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/bin/modsimple
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/libmod3.dylib
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/build/Release/_deps/fmt-build found in: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/libmod3.dylib (for architecture x86_64), required for specified option "-delete_rpath /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/build/Release/_deps/fmt-build"
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/miu/mod3/mod3.cppm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/miu/mod3/mod3customer.cppm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/miu/mod3/mod3order.cppm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/bmi/Mod3.pcm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/bmi/Mod3-Customer.pcm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cxx/bmi/Mod3-Order.pcm
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-targets.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-targets-release.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-cxx-modules/cxx-modules.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-cxx-modules/cxx-modules-Release.cmake
-- Up-to-date: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-cxx-modules/target-mod3-Release.cmake
-- Installing: /Users/clausklein/Workspace/cpp/cxx20/cppstd20-code/stagedir/lib/cmake/mod3/mod3-config.cmake
bash-5.2$ 

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 21, 2023, 1:52am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675/3 "2023-12-21T01:52:56Z")

</div>

When targets with non-`PRIVATE` `FILE_SET`s are exported, the generated export files refer to these files. That is why they must be installed when the target itself is installed.

Note that BMI installation is possible, but nothing will do anything with them at the moment (reusing them is…a future endeavor that will likely need compiler assistance). I would avoid BMI installation for now.

---

<div class="post-metadata">

### Author: ![MathiasMagnus](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathiasmagnus/32/431_2.png) [@MathiasMagnus](https://discourse.cmake.org/u/MathiasMagnus)
#### Post date: [October 25, 2024, 7:43am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675/4 "2024-10-25T07:43:52Z")

</div>

Thanks Ben for the heads up. Is it still the same situation now (a year-ish later)? Should BMI installation (or to be precise, reusing/depending on it) still be avoided?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [October 25, 2024, 8:04am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675/5 "2024-10-25T08:04:49Z")

</div>

See [Error install cxx-module on VS 2022 - #2 by ClausKlein](https://discourse.cmake.org/t/error-install-cxx-module-on-vs-2022/12774/2)
