[scripts-audit] add guidelines for cmake#18319
[scripts-audit] add guidelines for cmake#18319strega-nil wants to merge 12 commits intomicrosoft:masterfrom
Conversation
|
Any hint about the min version of CMake scripts must be compatible with / the version scripts may assume without checks? |
get_cmake_vars requires version 3.17, thus all scripts should require 3.17 update cmake_minimum_required in scripts/ports.cmake
Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
|
How about not allowing because it is a common trap (in particular with initialization of lists) that the real intention is but the actual effect is which unhides cache variables. So there are two explicit alternatives which are not ugly. I would also encourage use of over because it makes accidental stand out more clearly. |
|
|
This is what I thought until recently. But it is wrong, and that's why I'm bringing it up: $ cat demo.cmake
set(FOO "Initial")
set(FOO "Cached value" CACHE STRING "doc")
message(STATUS "${FOO}")
set(FOO )
message(STATUS "${FOO}")
list(APPEND FOO "bar")
message(STATUS "${FOO}")
set(FOO "")
list(APPEND FOO "bar")
message(STATUS "${FOO}")
$ cmake -P demo.cmake
-- Cached value
-- Cached value
-- Cached value;bar
-- bar |
|
After adding one more |
|
The result doesn't change when I wrap the code in
I'm aware that there is no persistent cache in script mode but there are still the different types of variables. I opened https://gitlab.kitware.com/cmake/cmake/-/issues/22285. |
A fix is already merged for CMake 3.21, and there will be a new policy, CMP0126. My original point stands: |
thanks robert! Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
what about guidelines for vcpkg-cmake-wrapper.cmake? |
Fair, but the dominant problem is that documentation is completely missing vcpkg-cmake-wrapper.cmake and vcpkg-cmake-config.cmake. |
| - This `cmake_minimum_required` should be bumped every time a new version | ||
| of CMake is added to `vcpkgTools.xml`, as should the | ||
| `cmake_minimum_required` in all of the helper `CMakeLists.txt` files. | ||
| - `vcpkg.cmake` must assume a version of CMake back to 3.1 in general |
There was a problem hiding this comment.
For vcpkg-cmake-wrapper.cmake scripts, version 3.1 even excludes if("value" IN_LIST FEATURES). This makes it more complicated to deal with port features or even with arguments to find_package (e.g. port tiff).
There was a problem hiding this comment.
vcpkg.cmakemust assume a version of CMake back to 3.1 in general
Is sentence is nonsense and should be ignored. I think the correct phrasing would be that vcpkg.cmake must assume that the toplevel CMakeLists.txt might not have a cmake_minimum_required or a very low cmake_minimum_required. As such, setting appropriate cmake policies are a requirement. vcpkg assume that it is at least executed with a cmake binary of <some cmake version|preferly the cmake version used by vcpkg>.
If there is somebody really arguing for a cmake binary of 3.1 I would like to have him/her invent vcpkg.old.cmake .....
There was a problem hiding this comment.
No, we really do support CMake version back to CMake 3.1 in vcpkg.cmake. There are extra features that require more recent versions, but we do support back to CMake 3.1 (or there's a bug.)
There was a problem hiding this comment.
What is the reason to keep it at 3.1?
What is the threshold for moving it to another version?
As I already wrote:
For vcpkg-cmake-wrapper.cmake scripts, version 3.1 even excludes if("value" IN_LIST FEATURES).
which is relevant for dealing with transitive dependencies.
There was a problem hiding this comment.
we do not consider ports as having to support any specific version of CMake; they can support whatever they want. All we need is that, if a port supports CMake 3.1, and the user uses 3.1 for their build, it works.
As to upgrading, not sure.
|
@dg0yt @Neumann-A that would be good guidelines, but these are meant more for the scripts under the scripts tree. |
eb2215f to
957c851
Compare
docs/maintainers/cmake-guidelines.md
Outdated
| - `include()`s are only allowed in `ports.cmake` or `vcpkg-port-config.cmake`. | ||
| - `foreach(RANGE)`'s arguments _must always be_ natural numbers, | ||
| and `<start>` _must always be_ less than or equal to `<stop>`. | ||
| - This must be checked. |
There was a problem hiding this comment.
| - This must be checked. | |
| - This must be checked by <insert copypaste code snippet here>. |
|
Tensorflow:x64-osx failure would be fixed by PR #18812 |
|
Closed for rollup PR #18838 |
[scripts-audit] add guidelines for cmake
* [rollup:2021-07-06 1/8] PR #18272 (@strega-nil) [scripts-audit] vcpkg_from_* * [rollup:2021-07-06 2/8] PR #18319 (@strega-nil) [scripts-audit] add guidelines for cmake * [rollup 2021-07-06 3/8] PR #18410 (@mheyman) [vcpkg-cmake-config] documentation fix * [rollup:2021-07-06 4/8] PR #18488 (@strega-nil) [scripts-audit] vcpkg_execute_* * [rollup:2021-07-06 5/8] PR #18517 (@strega-nil) [scripts-audit] vcpkg_extract_source_archive * [rollup:2021-07-06 6/8] PR #18674 (@NancyLi1013) [vcpkg doc] Update examples * [rollup:2021-07-06 7/8] PR #18695 (@JackBoosY) [vcpkg] Update the minimum version of vcpkg * [rollup:2021-07-06 8/8] PR #18758 (@ras0219-msft) [vcpkg_from_git] Fix error if downloads folder does not exist * build docs! * fix bond:*-windows * fix nmap Co-authored-by: nicole mazzuca <mazzucan@outlook.com> Co-authored-by: Michael Heyman <Michael.Heyman@jhuapl.edu> Co-authored-by: NancyLi1013 <lirui09@beyondsoft.com> Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com> Co-authored-by: Robert Schumacher <ras0219@outlook.com>
No description provided.