-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration not propagated to compiler defines #581
Comments
Hi @AnthonyVH, I am not sure if the syntax self.dependencies["mp-units"].options.std_format = False ? Please also note that as described here, setting BTW, Clang 17 does not provide |
You are right. This is a bug on my side. I have to think about how to fix it. |
I'm not trying to get rid of text formatting. We're using
The conan manual states that The thing is that the following "kind of" seems to work, because the default ( self.options["mp-units"].contracts = "ms-gsl" I also found this which seems to indicate I'm using the right way to configure the option: conan-io/conan#13467. I should note that I find the whole conan documentation pretty terrible though. A lot of things don't seem to be explained very well if at all. Edit: All |
Hmmm, strange. |
I do not think that you should set the options of dependencies in the Conan |
I'll dig more into this later this week. I'm wondering about something that seem related though. All the examples depend on |
The definitions in the |
…ition in different separate targets Refers to #581
I've tried a bunch more things, but can't get this to work. Below is a minimal example that reproduces the issue for me. The Is there something obvious missing here? -- conanfile.py
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
required_conan_version = ">=1.59.0"
class HelloConan(ConanFile):
name = "hello"
settings = "os", "compiler", "build_type", "arch"
build_policy = "missing"
options = { "build_folder": ["ANY"] }
default_options = { "build_folder": "build" }
def layout(self):
cmake_layout(self, build_folder=self.options.build_folder.value)
def configure(self):
self.options["mp-units"].std_format = False
def requirements(self):
self.requires("fmt/10.2.1")
self.requires("mp-units/2.2.0@mpusz/testing")
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = CMakeToolchain(self, generator="Ninja")
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build() # CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(conan-mp-units LANGUAGES CXX VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(fmt REQUIRED)
find_package(mp-units REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt mp-units::mp-units) // main.cpp
#include <mp-units/format.h>
#include <mp-units/systems/si.h>
#include <fmt/format.h>
#include <iostream>
int main() {
using namespace mp_units;
using namespace mp_units::si::unit_symbols;
constexpr quantity v1 = 110 * km / h;
std::cout << fmt::format("{}", v1) << '\n';
} |
You are right. There is a bug in I should fix it soon. |
Thanks a lot for the super fast fix! Looking forward to trying it out. |
I hope it fixes your problem. If not, please feel encouraged to reopen. |
Some bugs were found with the CI. I will fix them in a few minutes. |
I'm trying to disable the
std::format
support when compiling with Clang 17 in C++23 mode (i.e.std::format
is definitely supported). I have been trying multiple things for hours now, and can't find any way to make this work.Here's (part of) my
conanfile.py
:And part of the
CMakeLists.txt
file:No matter what I try,
MP_UNITS_API_STD_FORMAT
doesn't get defined when compiling. This then causesMP_UNITS_STD_FMT
to be set tostd
, instead offmt
which is what I want. I tested this by adding some extra preprocessor checks/prints to src/core/include/mp-units/compat_macros.hI tried setting
MP_UNITS_API_STD_FORMAT
via my project'sCMakeLists.txt
file to"FALSE"
, orOFF
, but neither does the trick. I'm very confused, because it seems theset_feature_flag()
function in src/core/CMakeLists.txt should defineMP_UNITS_API_STD_FORMAT
. And as far as I understand, I shouldn't need to do this anyway, because mp-units'conanfile.py
sets these variables in itsgenerate()
function.Although I'm a bit confused that the manual states that
MP_UNITS_API_STD_FORMAT
should be set to"AUTO"
/"ON"
/"OFF"
, but then theset_feature_flag()
checks that it's one of"TRUE"
or"FALSE"
. But again, this shouldn't matter when using conan, because it will set it to either"FALSE"
or"TRUE"
.I hope I'm just making a silly mistake, because I have no clue what I'm doing wrong and what else to try.
The text was updated successfully, but these errors were encountered: