mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

module 'mp_units' not found

Open n0F4x opened this issue 8 months ago • 4 comments

I am integrating mp-units with Clang 20 and C++26. However, mp-units is not available as a module, even when setting cxx_modules to True.

n0F4x avatar May 03 '25 16:05 n0F4x

Minimum reproducable

conan profile with MSYS2

[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.version=20
compiler.libcxx=libc++
compiler.cppstd=26
os=Windows

tools.cmake.cmaketoolchain:generator=Ninja

conanfile.py

from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMake


class TestRecipe(ConanFile):
    name = "test"
    package_type = "application"
    generators = "CMakeDeps", "CMakeToolchain"
    settings = "os", "compiler", "build_type", "arch"

    def requirements(self):
        self.requires("mp-units/2.4.0", options={"cxx_modules": True, "import_std": False})
        self.requires("fmt/11.1.3")

    def layout(self):
        cmake_layout(self)

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

CMakeLists.txt

cmake_minimum_required(VERSION 3.30)

project(test CXX)

add_executable(${PROJECT_NAME})

target_sources(${PROJECT_NAME} PRIVATE main.cpp)

# mp-units
find_package(mp-units CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE mp-units::mp-units)

main.cpp

import mp_units;

int main() {}

n0F4x avatar May 03 '25 17:05 n0F4x

It looks like the recipe on conan-center does not set:

tc.cache_variables["MP_UNITS_BUILD_CXX_MODULES"] = True

and when I install the library from conan, the mp-unitsTargets.cmake file does not mention the module interface units.
When I build this repo myself and specify -DMP_UNITS_BUILD_CXX_MODULES=ON, it seems to work fine.

Compare conan-center and this repo's conanfile.py.

melak47 avatar May 05 '25 18:05 melak47

Can you make a PR to conan center to fix this issue? And if not, what is the recommended way of getting mp-units?

n0F4x avatar May 06 '25 23:05 n0F4x

Thanks! I was on vacation and could not answer before.

Yes, it seems that this line is missing, but I do not remember now why it was left out of conanfile in the last release. I think that at this point, it did not work with the latest CMake available at that time. But I might be wrong...

I expect to release MP-units 2.5.0 this month, and it will contain all the fixes.

mpusz avatar May 07 '25 08:05 mpusz