c++windowsconanbuild-system

Conan on windows claims setting isn't set, it is set


I am trying to port a program from Linux to windows. The program is built with conan.

Currently I run:

conan install . -if build -s build_type=Debug 

I get this error:

ERROR: : 'settings.compiler.cppstd' value not defined

I have this in my conan.py:

class ConanFileNeverEngine(ConanFile):
    generators = "pkg_config"
    requires = [
        "eigen/3.4.0",
        "libffi/3.4.2", # Not sure why but without this wayland causes a conflict.
        "wayland/1.19.0",
        "glfw/3.3.4",
        "shaderc/2019.0",
        "freetype/2.10.4",
        "eigen/3.4.0",
        "harfbuzz/2.8.2",
        "vulkan-memory-allocator/2.3.0",
        "gtest/1.10.0",
        "benchmark/1.5.3",
        "tinygltf/2.5.0",
        "stb/20200203",
        "vulkan-headers/1.2.182",
        "vulkan-validationlayers/1.2.182",
        "cereal/1.3.0"
    ]
     
    settings = {
        "os": None,
        "compiler" : None,
        "cppstd": ["20"],
        "build_type" : None}
     ....

I also tried to manually set it:

  def config_options(self):
        # self.output.warn("test")
        self.settings.compiler.cppstd = "20"
        self.settings.compiler.runtime = "dynamic"
        if os_info.is_linux:
            if os_info.linux_distro == 'ubuntu':
                window_system = os.environ['XDG_SESSION_TYPE']
                if window_system == 'wayland':
                    self.output.error("System is using wayland, switch to x11.")

I get the exact same error.

I don't understand I AM setting the value.


Solution

  • Settings are external, project wide configuration, they cannot be defined or assigned values in conanfile.py files.

    Settings are defined in your profile, like the "default", you can see it printed when you type conan install, something like:

    Configuration:
    [settings]
    arch=x86_64
    arch_build=x86_64
    build_type=Release
    compiler=Visual Studio
    

    You can check that your defined value is not there, because you are trying to define its value way later.

    So you can:

    The reason for this is that "recipes/conanfile" describe how things are done, but they are generic, they should work for any configuration. Specific configuration values, like cppstd or used compiler then must be external to recipes.