install(TARGETS ... CXX_MODULES_BMI ...) does not always install a file?

I struggle over the CXX_MODULES install BMI. Sometimes this has no effect or some BMI files are missing?

see to Why are the build and installed BMI files not used?

I use always this cmake install function call:

            install(
                TARGETS "${_tgt}"
                EXPORT ${BOOST_EXPORT_NAME}
                ARCHIVE
                    ${_lib_install_dir}
                    COMPONENT "${install_component_name}_Development"
                LIBRARY
                    ${_lib_install_dir}
                    COMPONENT "${install_component_name}_Runtime"
                    NAMELINK_COMPONENT "${install_component_name}_Development"
                RUNTIME
                    ${_bin_install_dir}
                    COMPONENT "${install_component_name}_Runtime"
                ${_install_header_set_args}
                FILE_SET ${_module_sets}
                    DESTINATION "${BOOST_DESTINATION}"
                    COMPONENT "${install_component_name}_Development"
                # NOTE: There's currently no convention for this location! CK
                CXX_MODULES_BMI
                    DESTINATION
                        ${_config_install_dir}/bmi-${CMAKE_CXX_COMPILER_ID}_$<CONFIG>
                    COMPONENT "${install_component_name}_Development"
            )

/Users/clausklein/.local/lib/cmake/modules_triangle/
β”œβ”€β”€ cxx-modules
β”‚   β”œβ”€β”€ cxx-modules-modules_triangle-targets-Release.cmake
β”‚   β”œβ”€β”€ cxx-modules-modules_triangle-targets.cmake
β”‚   β”œβ”€β”€ target-library__a-Release.cmake
β”‚   └── target-library__c-Release.cmake
β”œβ”€β”€ modules
β”‚   β”œβ”€β”€ library_a.cppm
β”‚   └── library_c.cppm
β”œβ”€β”€ modules_triangle-config-version.cmake
β”œβ”€β”€ modules_triangle-config.cmake
β”œβ”€β”€ modules_triangle-targets-release.cmake
└── modules_triangle-targets.cmake

3 directories, 10 files
iMac:modules-triangle clausklein$ 

or i.e. 2 CXX_MODULES, but only 1 BMI?

bash-5.3$ tree /Users/clausklein/.local/lib/cmake/modules_playground
/Users/clausklein/.local/lib/cmake/modules_playground
β”œβ”€β”€ bmi-Clang_Release
β”‚   └── mylib.pcm
β”œβ”€β”€ cxx-modules
β”‚   β”œβ”€β”€ cxx-modules-modules_playground-targets-Release.cmake
β”‚   β”œβ”€β”€ cxx-modules-modules_playground-targets.cmake
β”‚   β”œβ”€β”€ target-play__hello-Release.cmake
β”‚   └── target-play__mylib-Release.cmake
β”œβ”€β”€ modules
β”‚   β”œβ”€β”€ M.cppm
β”‚   β”œβ”€β”€ interface_part.cppm
β”‚   └── mylib.cppm
β”œβ”€β”€ modules_playground-config-version.cmake
β”œβ”€β”€ modules_playground-config.cmake
β”œβ”€β”€ modules_playground-targets-release.cmake
└── modules_playground-targets.cmake

4 directories, 12 files
bash-5.3$ 

@vito.gamberini is it intended that NOT always the BMI files are installed?

You can install them, there is no purpose in doing so.

Neither CMake nor any other build system will ever use installed BMI files. In the future, CMake may use these as a minor optimization but it’s mostly pointless.

I know it is optional, but why this different behaviour?

No idea, this isn’t an minimum reproducible example it just the tree of some install folders.

But the point is if it has bugs I wouldn’t be surprised. They cannot be used for anything under any circumstances. This is tested in CMake, under RunCMake/CXXModules are a bunch of BMI tests @ben.boeckel wrote but I have no idea how complete their coverage or how they diverge from what you’re trying to do.

In any case, trying to make sense of BMI installation without any consumers is a lost cause. CPS will never support BMI installation, so this will forever be an obscure CMake-ism.

1 Like