'Select build type at conan build step

This is a simple need of selecting build type when calling conan build.

Normally we have to call conan install with the desired build type and then conan build with the following commands :

conan install conanfile.py install -s build_type=Debug
conan build conanfile.py

I have seen that we can force conan to do an install with the build command using --intall. I have tried the following command but it does not update the settings.build_type value.

conan build conanfile.py --install -s build_type=Release

Does any one have an idea how to change the build type with conan build command or at least pass a variables to be checked later in the conanfile.py

Thanks in advance



Solution 1:[1]

The conan build command will use whatever configuration was provided to the conan install command. So the way to change configuration (settings, options, etc) is to do a conan install with the right configuration.

When a conan install command is executed it will create information about dependencies for the current configuration (profile, settings, options), and will generate files as conanbuildinfo.cmake as defined by the Conan generators. The conan build command will use those files to find the right dependencies binaries for that configuration. Trying to conan build with a different configuration without updating the dependencies generated files will typically result in compile or link errors for using the incorrect dependencies binaries.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 drodri