-
Notifications
You must be signed in to change notification settings - Fork 150
Add CMake Config-file package #260
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
base: master
Are you sure you want to change the base?
Add CMake Config-file package #260
Conversation
This is intended to make the installed package relocatable.
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
utf8proc appears to use SemVer. Do not consider different major versions compatible.
Thank you for the review @kou. Feedback has been applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
(But I'm not a maintainer of this project. I just an user of this project.)
@stevengj may I request merging this PR? This may help using utf8proc with CMake. |
This is a nice modernization of the cmake file. However, I see that these changes are not tested in CI. Did you test them? Do you have a package that uses If a package is undergoing regular development, then changes to the build system are automatically tested. I know that it is very uncommon to have CI test the packaging mechanism. I argue it should in general, but I'm not going to insist since this would be a lot of work. I still would like you to confirm that you tested all the features you're introducing. (Kudos for updating the documentation explaining how to use cmake in a modern way.) |
We can add a CI job for the CMake package by just creating a small CMake project something like: /* app.c */
#include <stdio.h>
#include <utf8proc.h>
int
main(void)
{
printf("%s\n", utf8proc_version());
return 0;
} # CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(utf8proc-test)
find_package(utf8proc REQUIRED)
add_executable(app app.c)
target_link_libraries(app utf8proc::utf8proc) $ cmake -S . -B build -DCMAKE_PREFIX_PATH=${UTF8PROC_PREFIX}
$ make -C build @kevinAlbs Can you add a CI job for this CMake package? (Or I can work work on it.) FYI: I'm using utf8proc in https://github.com/apache/arrow . But we use our |
Done. 8ed21d9 adds a test to GitHub actions for consuming the package with CMake. Thank you for the starter code. |
.github/workflows/cmake.yml
Outdated
- name: Test Consuming (Windows) | ||
if: ${{ matrix.os == 'windows-latest' }} | ||
run: | | ||
cmake --install build --prefix tmp/install --config Debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding -DCMAKE_INSTALL_PREFIX=tmp/install
to cmake -S . ...
in the name: Build
step instead of using --prefix tmp/install
here?
.gitignore
Outdated
@@ -28,6 +28,7 @@ | |||
/test/case | |||
/test/iscase | |||
/test/custom | |||
/test/app/build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need this.
@eschnett Do you want to add this? If we want to use cmake -S test/app -B test/app/build ...
for local development, this will be helpful. If we want to use cmake -S test/app -B ../test-app-build ...
or something for local development, this is needless.
FYI: Our README has cmake -S . -B build
but we don't have /build/
in this list.
https://github.com/JuliaStrings/utf8proc?tab=readme-ov-file#quick-start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not add this. I would only add directories or files that are generated by the build system. The path where cmake builds is under user control and I frequently use different paths than those suggested in a packages's documentation. I have, however, no strong opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed with 60205e4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Use capital `$Env` instead of `$env` to match conventions. Prefix `PATH` to avoid referring unintentional binaries. Prefer `\` over `/` to match conventions. Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
To allows future Windows additions to the test matrix. Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Remove unneeded export. Prefix `PATH` to avoid referring unintentional binaries. Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Summary
This PR resolves #250 by creating CMake Config-file Package.
Motivation
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages notes:
Including a CMake Config-file Package enables CMake consumers to use
find_package
to find and use utf8proc:The absence of a CMake Config-file Package may add difficulty using utf8proc in a CMake project. For example: the MongoDB C driver includes FindUtf8Proc.cmake using pkg-config. However, using pkg-config is not suitable for consumers building with MSVC (the
-l
and-L
flags are unrecognized).Use of relative paths in 422de38 is intended to make the installed package relocatable.