Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate version files and more #763

Merged
merged 8 commits into from
Jun 30, 2024

Conversation

uilianries
Copy link
Contributor

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:

find_package(faker-cxx 2.0.0 EXACT REQUIRED CONFIG)

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:

$ pkg-config --libs faker-cxx
-L/usr/local/lib -lfaker-cxx

To pkg-config be able to know that information, it needed to load the file faker-cxx.pc. That file was generated CMake, and the feature is in this pull request. So, for any cmake --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.

Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
Signed-off-by: Uilian Ries <[email protected]>
CMakeLists.txt Show resolved Hide resolved
cmake/Version.h.in Show resolved Hide resolved
cmake/faker-cxx.pc.in Outdated Show resolved Hide resolved
src/CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
tests/CMakeLists.txt Outdated Show resolved Hide resolved
@uilianries uilianries marked this pull request as draft June 30, 2024 10:52
@uilianries uilianries marked this pull request as ready for review June 30, 2024 11:06
@cieslarmichal cieslarmichal merged commit a8d0282 into cieslarmichal:main Jun 30, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants