feat: Generate version files and more #763
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
When consuming the project, it's hard to know what's the current library version without external references. So, in this PR I added the new feature of generating
faker-cxx/Version.h
automatically, based on the project version listed in CMakeLists.txt.The same is applied for bazel, but it's duplicated (otherwise, it would complicate by a lot to extract from another file).
Consuming Version.h may be enough in case you want to validate in runtime, but when consuming Faker-cxx via CMake, and you want to be sure about which version is available and that you want version 2.0.0, you should do:
CMake has no magic mechanism to detect the version, but we can export it via
faker-cxxConfigVersion.cmake
. So, in this PR I added too this feature, to be able to detect the project version in CMake configuration time.CMake is capable to generate many different types of build and dependencies scripts. Some people still use autotools + pkgconfig in Linux to build projects. For instance, if I want to know the library arguments that should be passed to my compiler, when consuming faker-cxx:
To
pkg-config
be able to know that information, it needed to load the filefaker-cxx.pc
. That file was generated CMake, and the feature is in this pull request. So, for anycmake --build build --target install
executed, CMake will install .pc file too.As the CMakeLists.txt is bigger and bigger, I moved divided the file, moved part of content to src/CMakeLists.txt and preserved general configuration in the root CMake file.