module 'mp_units' not found
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.
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() {}
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.
Can you make a PR to conan center to fix this issue? And if not, what is the recommended way of getting mp-units?
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.