Rufous

[question] Build time optimization level · Issue #9366 · conan-io/conan

Format: markdownScore: 0Link: https://github.com

    


      

      

          
ericriff




        changed the title
[question] Build tyme optimization level

[question] Build time optimization levelAug 2, 2021

    

      

  




  

        

          Hi!
We don't have a setting nor something similar to adjust the optimization level.
Sometimes the build system (cmake for example) does some adjustments depending on the build_type and we have some old generator like the compiler_args that made some adjustments too.
Currently, it is not possible to introduce it globally for all the dependency tree with a Conan mechanism.
Some users are typically setting a CFLAGS or CXXFLAGS environment variable in a profile.
There could be other approaches to manage it globally (if you control the recipes) you could use a custom conf entry in the profile read here and make every recipe to adjust that flag when the variable is set or something like that.
Adjusting a flag globally has been requested several times and we probably introduce something using the conf objects, but it is still an idea.
Hope it helps!
      



        
      




      

  




  

        

          Thanks for the quick reply.
Does conan's build_type gets mapped to CMAKE_BUILD_TYPE? Because I think that, if not overridden, CMake will add optimization flags based on that variable. Particularly, -O3 for Release, -O0 for Debug and -Os for MinRelSize.
If it does get mapped, does that happen on conan_basic_config()? Or Through the cmake generator? Somewhere else?
      



        
      




      

  




  

        

          Yes, Conan maps the build type for cmake. With the old cmake generators that are done in the conan_basic_setup() and with the new model (the only will be kept in Conan 2.0) it is managed by the conan_toolchain.cmake file generated by the CMakeToolchain generator.
You can read about the new (and future) cmake integrations here: https://docs.conan.io/en/latest/reference/conanfile/tools/cmake.html
      



        
      




      

      

  




  

        

          Closing as responded back then, thanks for the feedback.