-
Notifications
You must be signed in to change notification settings - Fork 260
use CMAKE_CONFIGURATION_TYPES instead of explicitly defining some #713
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
base: develop2
Are you sure you want to change the base?
use CMAKE_CONFIGURATION_TYPES instead of explicitly defining some #713
Conversation
|
By coincidence, I was doing the exact same thing and was thinking, oh #707 can be used for this. |
I'd actually recommend to overwrite CMAKE_CONFIGURATION_TYPES in the actual project (not the conan provider) if needed. If you do so, you will not break any downstream tools |
|
Yes, that's also what I'd do. I'm just wondering, what is the sense in both being able to define CMAKE_CONFIGURATION_TYPES and CONAN_INSTALL_BUILD_CONFIGURATIONS, as they sort of achieve the same thing in conan_provider.cmake, no? I'd prefer to only have CMAKE_CONFIGURATION_TYPES as CONAN_INSTALL_BUILD_CONFIGURATIONS tries to achieve the same thing but in a more convoluted manner unless I'm missing something |
|
Since the default value for the former is the four configurations, it would be overkill to require the 4 configurations for all dependencies. For example, on Linux (where Debug and Release tend to be binary compatible) - users are typically okay using Debug for their own project, but Release for all dependencies (for performance purposes). So I'd say these serve two different purposes. In my experience, I'd say devs who override
It would be useful to know what exactly is broken, preferably with a reproducible example. My intuition tells me that this is either an issue with the I'm not convinced it is a good idea to switching the defaults to require dependencies to be installed with all 4 configurations unless users explicitly opt-out. |
|
consider this simple example: if you are nod modifying CMAKE_CONFIGURATION_TYPES the generated compile_commands.json will contain 4 entries for the file fmt_dummy.cpp For Debug and Release you will get something like this for MinSIzeRel and RelWithDbgInfo you will get something very similar. but without the The same issue occurs when feeding cppcheck the compile_commands.json. Luckily you can tell cppcheck to discard unknown headers, but this did not work for clang tidy. I get your point: If you are bothered with the increased build time i can only think of using these 2 options
I think you can just take the example from this repo and configure it with ninja multi config. Check your compile_commands.json and you will see that this contains for each file 4 versions. Only debug and release contain the correct conan include paths |
For C++, Debug and Release are most definitely not compatible as many std containers have different layouts depending on build configuration. Which is why, for most people that use dependencies with C++ interfaces and that are not header-only, I'd expect the CMAKE_CONFIGURATION_TYPES need to match what conan builds for those configurations? I guess, it could be fine to take the PR as suggested, as when not defining CONAN_INSTALL_BUILD_CONFIGURATIONS would then result conan's install configs to match with CMAKE_CONFIGURATION_TYPES set by the project. |
|
Does it work if the project defines the variables ? |
Regarding the CompileCommands.json case that @JulianH1989 mentions, I'm not sure. |
This is the case with MSVC STL, but not other vendors.
As I mentioned earlier, on Linux and macOS is fairly standard to have your own project built on Debug, and your dependencies in Release. In fact, that's how it works when one uses dependencies provided by the system - they are optimized builds. I'd say - most people don't change the
They are different things. Both can be handled by the consumer project in a presets file without much hassle. Merging this PR will cause all users using multi-config generators (Ninja MultiConfig or Visual Studio) to have to build all dependencies in all 4 configurations due to CMake's default behaviour - when it most cases they won't need them. So we're inclined to not change the current behaviour in a way that would cause unnecessary build times for the vast majority of users. |
|
Ok, I concede the point. For my use case I can just define CONAN_INSTALL_BUILD_CONFIGURATIONS to be the same as CMAKE_CONFIGURATION_TYPES and go that route. Since we do build for Windows with MSVC, we do need separate debug and release conan installs anyways. |
|
Hey, If I add this to my project BEFORE any target is created the compile_commands.json looks good and clangh tidy works. Regarding this PR: So I'd prefer to just use the full CMAKE_CONFIGURATION_TYPES because breaking downstream tools is much worse than only increasing the build time. People can still optimize their build by specifying CONAN_INSTALL_BUILD_CONFIGURATIONS . If you decide to keeps things as they are, at least put a big warning in the readme that users have to set CONAN_INSTALL_BUILD_CONFIGURATIONS to ${CMAKE_CONFIGURATION_TYPES} or set in their project. Otherwise the compile_commands.json is malformed and downstream tools will break if they do not add this to their project. |
I started using this wrapper.
In Our CMake project we are using quite a big list of compilers and additional tools.
Some of these tools (like clang-tidy) rely on a correct (cmake generated) compile_commands.json.
Since this wrapper only invokes conan for debug and release the generated compile_commands.json is malformed which breaks external tools like clang_tidy.
It's fine to exclude unneeded configs for example by overwriting the CMAKE_CONFIGURATION_TYPES list or specifying CONAN_INSTALL_BUILD_CONFIGURATIONS but this should not be done be default.