Skip to content

Commit f1d1692

Browse files
committed
Merge branch 'develop'
2 parents e307211 + 43f848e commit f1d1692

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

CHANGELOG.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.7.4] - 2021-03-04
10+
### Fixed
11+
- ComponentPackageRootConfig.cmake uses a package name with capitalization
12+
matching capitalization in find_package() invocation.
13+
- Conan test package cpp source explicitly returns success from main function.
14+
- Conan recipe revision is computed from commit ID instead of recipe hash,
15+
because recipe hash is sensitive to line-endings.
16+
917
## [0.7.3] - 2021-02-24
1018
### Fixed
1119
- Clarify the text in different locations after proofreading.
@@ -15,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1523
### Added
1624
- A changelog following [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
1725
- Automate release and Github page publication, based on Github Actions.
18-
- A script to pepare and trigger the release+publish process (repo-admin/release.py)
26+
- A script to pepare and trigger the release+publish process (repo-admin/release.py).
1927

2028
### Fixed
2129
- Fix Conan test_package executable location for multi-config generators
@@ -33,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3341
### Added
3442
- Initial release of the document
3543

36-
[Unreleased]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.3...HEAD
44+
[Unreleased]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.4...HEAD
45+
[0.7.4]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.3...v0.7.4
3746
[0.7.3]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.2...v0.7.3
3847
[0.7.2]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.1...v0.7.2
3948
[0.7.1]: https://github.com/Adnn/ModernCppComponent/compare/v0.7.0...v0.7.1

README.adoc

+42-24
Original file line numberDiff line numberDiff line change
@@ -1007,43 +1007,45 @@ to exist in `cmake` folder:
10071007
.cmake/ComponentPackageRootConfig.cmake.in
10081008
[source, cmake]
10091009
----
1010-
if (NOT @CMAKE_PROJECT_NAME@_FIND_COMPONENTS)
1011-
set(@CMAKE_PROJECT_NAME@_NOT_FOUND_MESSAGE "The \"@CMAKE_PROJECT_NAME@\" package requires at least one component")
1012-
set(@CMAKE_PROJECT_NAME@_FOUND False)
1010+
if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
1011+
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "The '${CMAKE_FIND_PACKAGE_NAME}' package requires at least one component")
1012+
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
10131013
return()
10141014
endif()
10151015

10161016
include(CMakeFindDependencyMacro)
1017-
foreach(module ${@CMAKE_PROJECT_NAME@_FIND_COMPONENTS})
1017+
foreach(module ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
10181018
set (_config_location "${CMAKE_CURRENT_LIST_DIR}")
10191019
# find_dependency should forward the QUIET and REQUIRED arguments
10201020
find_dependency(${module} CONFIG
10211021
PATHS "${_config_location}"
10221022
NO_DEFAULT_PATH)
1023-
unset(_config_location)
10241023
if (NOT ${module}_FOUND)
1025-
if (@CMAKE_PROJECT_NAME@_FIND_REQUIRED_${module})
1026-
string(CONCAT _@CMAKE_PROJECT_NAME@_NOTFOUND_MESSAGE
1027-
"Failed to find @CMAKE_PROJECT_NAME@ component \"${module}\" "
1024+
if (${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${module})
1025+
string(CONCAT _${CMAKE_FIND_PACKAGE_NAME}_NOTFOUND_MESSAGE
1026+
"Failed to find ${CMAKE_FIND_PACKAGE_NAME} component \"${module}\" "
10281027
"config file at \"${_config_location}\"\n")
1029-
elseif(NOT @CMAKE_PROJECT_NAME@_FIND_QUIETLY)
1030-
message(WARNING "Failed to find @CMAKE_PROJECT_NAME@ component \"${module}\" "
1028+
elseif(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
1029+
message(WARNING "Failed to find ${CMAKE_FIND_PACKAGE_NAME} component \"${module}\" "
10311030
"config file at \"${_config_location}\"")
10321031
endif()
10331032
endif()
1033+
1034+
unset(_config_location)
10341035
endforeach()
10351036

1036-
if (_@CMAKE_PROJECT_NAME@_NOTFOUND_MESSAGE)
1037-
set(@CMAKE_PROJECT_NAME@_NOT_FOUND_MESSAGE "${_@CMAKE_PROJECT_NAME@_NOTFOUND_MESSAGE}")
1038-
set(@CMAKE_PROJECT_NAME@_FOUND False)
1037+
if (_${CMAKE_FIND_PACKAGE_NAME}_NOTFOUND_MESSAGE)
1038+
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${_${CMAKE_FIND_PACKAGE_NAME}_NOTFOUND_MESSAGE}")
1039+
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
10391040
endif()
10401041
----
10411042
1042-
NOTE: Execution of this Config script might be recursive via the find_dependency call,
1043-
in cases where components in the same project depend on each other.
1044-
Since all invocations occur in the same "variable scope", the `unset(_config_location)` would also
1045-
erase the value in the "calling context", even if unset would occur after the loop completes.
1046-
For this reason, re-set `_config_location` variable at each iteration.
1043+
NOTE: Execution of this Config script might be recursive via the `find_dependency` call,
1044+
in cases where components of a given CMake package depend on other components inside the same package.
1045+
Since the different recursive invocations occur in the same "variable scope",
1046+
the `unset(_config_location)` occurring in a nested call before returning to its caller would also erase this value for said caller.
1047+
For this reason, re-set `_config_location` variable at each iteration of the `foreach` loop
1048+
(in case a nested call in a previous iteration of the loop has unset `_config_location`).
10471049
10481050
This template leverages the config files still produced and installed by each individual component in order to locate them,
10491051
via the call to link:https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html[`find_dependency()`].
@@ -1504,6 +1506,16 @@ class MyRepositoryConan(ConanFile):
15041506
description = "A Conan recipe for {Sonat} sample repository"
15051507
topics = ("demonstration")
15061508

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+
15071519
# Package variability:
15081520
# Changing those values will result in distinct packages for the same recipe
15091521
settings = "os", "compiler", "build_type", "arch"
@@ -1526,12 +1538,6 @@ class MyRepositoryConan(ConanFile):
15261538
# And if it was installed in a non-compatible version, this will take precedence anyway
15271539
build_requires = "cmake_installer/3.15.4@conan/stable"
15281540

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

15361542
# Build procedure: code retrieval
15371543
# Git's repository origin remote and its current revision are captured by recipe export
@@ -1580,6 +1586,15 @@ Invoking `conan install`, Conan will copy the content of its source folder direc
15801586
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.
15811587
In other words, it ensures an _out of source build_, with the specificity that the source folder is nested under the build folder.
15821588
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+
15831598
NOTE: The `shared` option and `build_type` setting are common in recipes, thus Conan implicitly forwards the corresponding definitions to the CMake object.
15841599
On the other hand, the custom `build_tests` option is manually forwarded. This explicit approach allows complete customisation of the CMake variables.
15851600
The documentation provides link:https://docs.conan.io/en/latest/reference/build_helpers/cmake.html#definitions[the list of automatic variables].
@@ -1810,10 +1825,13 @@ Such folder usually consists of 3 files:
18101825
#include <A/accumulate.h>
18111826
#include <A/sum.h>
18121827

1828+
#include <cstdlib>
1829+
18131830
int main()
18141831
{
18151832
myns::accumulate(3);
18161833
myns::sum(myns::sum(3, 2), 1);
1834+
return EXIT_SUCCESS;
18171835
}
18181836
----
18191837

0 commit comments

Comments
 (0)