I want to define a minimum version to CMake with "cmake_minimum_required" facility. I have seen that some project set minimum version 2.8 some others set 3.0 or 3.2. I would like to learn your opinions and best practices about the topic.
相关问题
- Avoid cmake to add the flags -search_paths_first a
- CMakeList file to generate LLVM bitcode file from
- create a data frame based on the minimum value of
- How to fix NDK build error for HelloCardboard samp
- Linking against GLEW with CMake
相关文章
- Target requires the language dialect “CXX17” (with
- How do I tell cmake not to create a console window
- Mongoose schema to require array that can be empty
- Swift 4 - Setting a minimum deployment target
- Set highcharts y-axis min value to 0, unless there
- Do something for all targets
- CMake: Replace compile flags of an INTERFACE targe
- Generate Web Assembly from CMake Project with a Sp
The
cmake_minimum_required()
function is used to avoid any cryptic error messages due to theCMakeLists.txt
assuming a later version of CMake than the one installed on the current host.As an example, failing early, and with a clear message...
...is to be preferred over something more cryptic (much) later on...
...just because, in this example, the older CMake version does not support
set( CMAKE_CXX_STANDARD 11 )
. I am sure you'll agree.The ideal setting would be:
Maximal compatibility with people running older versions, as well as with your script. But it requires testing which version exactly it was that first supported your constructs. So it usually boils down to:
That's probably good enough for most projects. And if you are the only one actually working on the project, and testing for CMake compatibility is really low on your list, you will probably end up with:
This latter approach has a serious drawback once somebody else attempts to compile your project. Quite a few people are not using the latest version of everything. On Linux in particular, the default is to use whatever the package manager gives you. Ubuntu wily, for example, is currently at version 3.2.2 -- you may have a later version, but unless you need a later version, you shouldn't require it (as that means people won't be able to build your project without first installing a newer version of CMake, manually).
What you should not be doing is...
The reasons should be obvious -- building could fail, without the user getting any hint as to why things went wrong.