I'm the author of some library which gets built using CMake.
If a user specifies a build type they run cmake - I can oblige that, no problem.
But what is the best practice when a user doesn't specify a build type?
- Should I just ignore it?
- Should I choose a build type as a fallback/default myself? If so, which?
- I've read this Kitware blog entry which suggests a certain approach to the matter and places it in a library dependency. The approach is encapsulated into this module. Should I use that?
So far I've been forcing some specific build type and it's been suggested to me perhaps I shouldn't be doing that.
I think there are two good options:
CMAKE_BUILD_TYPE
is unset and the active generator is single-config.To implement (1) correctly, the following code snippet (placed early, ideally after
project()
) will work: