conan
conan copied to clipboard
[question] Setting CFLAGS RELEASE correctly in profiles
Dear Conan Folks,
I have an issue that I use build_type Release in my profile, However it adds -O3 -DNDEBUG in CMakeCache.txt.
Is it possible to set it correctly in profiles so that CMAKE_C_FLAGS_RELEASE doesnot use the default -O3 -DNDEBUG?
CMakeCache.txt:CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
Also this doesnot seem to work
def generate(self): tc = CMakeToolchain(self) if self.settings.build_type == "Release": tc.preprocessor_definitions["CMAKE_C_FLAGS_RELEASE"] = "-O2"
- [x] I've read the CONTRIBUTING guide.
This doesn't seem a Conan issue, but a CMake issue, as -O3 is the CMake default for Release. Maybe this should be addressed directly in your CMakeLists.txt, and not injected by Conan, as Conan is not the one defining this flag.
If you still want to try it, the preprocessor_definitions is not the way to go, as those are not CMake variables but directly preprocessor definitions. You could try the cache_variables or variables, but also changing those is risky, because the optimization flag is not the only one, so you might be dropping other necessary variables, so I would still recommend trying a pure CMake solution.
For the proof of concept with conan , can i Build wih build_type=None , will that work ? As right now we are still in the proof of concept stage
For the proof of concept with conan , can i Build wih build_type=None , will that work ? As right now we are still in the proof of concept stage
No, most build systems need the build_type defined, definitely the CMake integration needs it.
Ah ok , then cmake is the only way . Thanks for helping me out. Is it fine to use: set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}") We still are not at the phase where we know if we could use conan for our use-cases. So for now, i do this in the CMakeLists.txt The other option would be to use Debug build type for all the packages so then we donot have this -O3 coming in.
We are using debug builds as of now as we do not need -O3.
This issue can be closed, no longer an issue.