Skip to content

Commit 98b0045

Browse files
committed
Use "scm" conan recipe revision, since hash is line-ending sensitive.
1 parent d3cc560 commit 98b0045

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- ComponentPackageRootConfig.cmake uses a package name with capitalization
1010
matching capitalization in find_package() invocation.
1111
- Conan test package cpp source explicitly returns success from main function.
12+
- Conan recipe revision is computed from commit ID instead of recipe hash,
13+
because recipe hash is sensitive to line-endings.
1214

1315
## [0.7.3] - 2021-02-24
1416
### Fixed

README.adoc

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,16 @@ class MyRepositoryConan(ConanFile):
15061506
description = "A Conan recipe for {Sonat} sample repository"
15071507
topics = ("demonstration")
15081508

1509+
# Which generators are run when obtaining the code dependencies, before build()
1510+
generators = "cmake_paths", "cmake"
1511+
1512+
# The default "hash" mode would result in different recipe revisions for Linux and Windows
1513+
# because of difference in line endings
1514+
revision_mode = "scm"
1515+
1516+
# (overridable) defaults for consumers
1517+
build_policy = "missing"
1518+
15091519
# Package variability:
15101520
# Changing those values will result in distinct packages for the same recipe
15111521
settings = "os", "compiler", "build_type", "arch"
@@ -1528,12 +1538,6 @@ class MyRepositoryConan(ConanFile):
15281538
# And if it was installed in a non-compatible version, this will take precedence anyway
15291539
build_requires = "cmake_installer/3.15.4@conan/stable"
15301540

1531-
# Which generators are run when obtaining the code dependencies, before build()
1532-
generators = "cmake_paths", "cmake"
1533-
1534-
# (overridable) defaults for consumers
1535-
build_policy = "missing"
1536-
15371541

15381542
# Build procedure: code retrieval
15391543
# Git's repository origin remote and its current revision are captured by recipe export
@@ -1582,6 +1586,15 @@ Invoking `conan install`, Conan will copy the content of its source folder direc
15821586
If we did not clone in a subfolder, the different files at the root of the repository would appear directly at the root of the build folder, which could augment the risk of filename collision.
15831587
In other words, it ensures an _out of source build_, with the specificity that the source folder is nested under the build folder.
15841588
1589+
CAUTION: The recipe revision mode is explicitly set to `revision_mode = scm`, instead of the default `hash` mode.
1590+
As its value indicates, the default mode computes the recipe revision by hashing the recipe file. +
1591+
Since hashing notably takes line endings into account, this might result in different revisions being computed
1592+
depending on the host system (CRLF vs CR vs LF line endings) and git's configuration. +
1593+
Having different revisions for what is actually the exact same recipe would be conceptually wrong,
1594+
and could also break the actual distribution via Conan repositories:
1595+
if prebuilt packages for all systems are expected to live under a single recipe revision in the central repository (as is intended),
1596+
then a for systems with a non-matching line ending, the package might not be found under the correct revision.
1597+
15851598
NOTE: The `shared` option and `build_type` setting are common in recipes, thus Conan implicitly forwards the corresponding definitions to the CMake object.
15861599
On the other hand, the custom `build_tests` option is manually forwarded. This explicit approach allows complete customisation of the CMake variables.
15871600
The documentation provides link:https://docs.conan.io/en/latest/reference/build_helpers/cmake.html#definitions[the list of automatic variables].

0 commit comments

Comments
 (0)