-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[vcpkg_cmake_config_test] Add function to test the exported cmake configurations #15173
[vcpkg_cmake_config_test] Add function to test the exported cmake configurations #15173
Conversation
@BillyONeal @strega-nil Any suggestions are good. |
I do like this feature a lot. I'm not sure what suggestions you're looking for? |
@strega-nil I think this type of testing should only be carried out in two situations:
Most post checks should follow this policy, because for users, they have been tested in the PRs before being merged into the master, so there is no need to waste more time. |
Close this PR temporary. |
/azp run |
Pull request contains merge conflicts. |
Will this be move to a new port, or merged into an existing vcpkg-cmake... port? I suppose it would also shorten CI runs to not touch ports.cmake. |
@strega-nil I think all the ports whose called |
Can you perhaps test with port geos? I added a usage file recently because the default instructions were somewhat misleading. And now I wonder if automated testing might fail to identify the canonical use in a similar way. |
@dg0yt No errors. |
@dg0yt Please note we should test the following contents:
And I noticed you've done only part of them. For more, we also should allow the maintainer to provide a custom test code to test the binary. |
Yes, because I had a different focus (older versions of cmake). So apart from the pure But given your function's arguments, why not cover find modules? Do you need a proof-of-concept?
I agree. |
Because some ports do not actively provide the find modules and use cmake one, we must add additional parameters to achieve this. |
There could also be a unified signature like this: vcpkg_cmake_package_test(
USAGE Curl CONFIG
TARGET_NAMES CURL::libcurl
HEADERS curl/curl.h
FUNCTIONS curl_global_init
)
vcpkg_cmake_package_test(
USAGE Curl
TARGET_NAMES CURL::libcurl
HEADERS curl/curl.h
FUNCTIONS curl_global_init
) where |
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 feel like this needs a clearer separation of package name and folder name.
endif() | ||
|
||
if (arg_CONFIG_NAME) | ||
set(target_folder "${arg_CONFIG_NAME}") |
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.
A config for Pkg
can be found in different target folders:
Pkg
(asPkg/PkgConfig.cmake
)pkg
(aspkg/pkg-config.cmake
)
But a config for Pkg
is different from a config for pkg
. (Side effects: setting Pkg_FOUND
, Pkg_LIBRARIES
etc.)
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.
- For CONFIG mode, we should use the target name, now I think it's correct.
- For MODULE mode, we need to use the Find module provided cmake macros, we still need to extend this function to add additional option
TARGET_LIBRARIES
,TARGET_INCLUDES
,TARGET_DEFINITIONS
andTARGET_OPTIONS
. Also, we need to consider whether these options are just "extend" cmake test code or "replace" cmake test code. That's why I set up the ability to use the extended cmake test code.
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.
This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout 078f3e51efd5ea6072d0ba28d11baa946519a2ce -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/c-/curl.json b/versions/c-/curl.json
index 5ba5d000..335aaebe 100644
--- a/versions/c-/curl.json
+++ b/versions/c-/curl.json
@@ -1,7 +1,7 @@
{
"versions": [
{
- "git-tree": "b43d25f9b63c3be9d9b67ef81cb4cfc18c75a848",
+ "git-tree": "a6939590c8a4af6b772b6a0a40bf107451e9475e",
"version": "7.79.1",
"port-version": 1
},
diff --git a/versions/v-/vcpkg-cmake-config.json b/versions/v-/vcpkg-cmake-config.json
index 801f78c0..3ae01541 100644
--- a/versions/v-/vcpkg-cmake-config.json
+++ b/versions/v-/vcpkg-cmake-config.json
@@ -1,7 +1,7 @@
{
"versions": [
{
- "git-tree": "4d873c8d4d63892838c407e1b7eb1c297377a8b6",
+ "git-tree": "da185d09123093850dd27c8775df33c20df88ce3",
"version-date": "2021-10-19",
"port-version": 0
},
set(extern_header_checks "") | ||
set(extern_symbol_checks_base "") | ||
set(extern_symbol_check_symbol "") |
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.
These macros are strings, so we shouldn't use vcpkg_list
.
Ping @dg0yt for review again. |
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.
Now here is a lot more.
Disclaimer: I'm not a native English speaker.
list(LENGTH target_folders folder_size) | ||
|
||
if (target_size EQUAL 0 OR folder_size EQUAL 0) | ||
message(WARANING "Found the following cmake configuration file but not found the target.") |
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.
WARNING
... but did not find the target.
Note that the warning text doesn't match the case of folder_size == 0.
I keep wondering if it would be better to start with a glob for *-config.cmake *Config.cmake (otherwise: error "No config file found"), generate the list of package names and directories from this config file list, and only then start collecting targets from these directories (otherwise: error "No targets found for config Xyz").
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.
This is for installing other cmake files instead of cmake configuration entry files.
Please note that the *Cconfig.cmake
file does not provide add_library
in most cases.
endif() | ||
|
||
if (NOT folder_size EQUAL 1 AND NOT arg_USAGE) | ||
message(FATAL_ERROR "More than one folder contains cmake configuration files, please set \"TARGET_NAMES\" to select the certain target name") |
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.
Is there an example case? I don't think this can be assumed to be an error. There can be folder PROJ4 providing PROJ4::PROJ4 (legacy), and there can be folder PROJ, providing PROJ::PROJ (modern).
But probably it is a limitation of the current implementation which would be resolved by splitting identifying folders from processing folders, instead of doing this simultaneously.
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.
In some ports, the upstream provides many targets, and these targets independently generate the corresponding targets.cmake
file. These files may be installed in different folders (named after the target name).
We should avoid this situation.
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.
Your are talking about deep trees within a single package. Here you statement makes sense.
But my focus was separate cmake packages.
This cannot be improved while iterating simultaneously over multiple cmake packages. In my previous comment, I should have used the words "splitting identifying package names from ...". Or better write pseudo code:
- Collect package names by non-recursive looking for
*/*Config.cmake */*-config.cmake
.
(This step could be skipped in case ofarg_USAGE
.) - For each package name, collect targets from the cmake files (maybe recursively).
(This step could be skipped in case ofarg_TARGET_NAMES
, assuming a single package name.)
endmacro() | ||
|
||
function(vcpkg_cmake_config_test) | ||
if (NOT _VCPKG_EDITABLE) |
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 if this is the right indicator for controlling the test.
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 expect this test to run in edit mode or CI mode to reduce user build time.
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 understand the argument about build time, But edit mode is somewhat exceptional in my personal use, and it is propably inactive during CI.
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 hope the ci
command will pass a special VCPKG_
variable to cmake to enable this function.
But for now I think it can be enabled in edit mode first.
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.
This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout 078f3e51efd5ea6072d0ba28d11baa946519a2ce -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/c-/curl.json b/versions/c-/curl.json
index 5ba5d000..335aaebe 100644
--- a/versions/c-/curl.json
+++ b/versions/c-/curl.json
@@ -1,7 +1,7 @@
{
"versions": [
{
- "git-tree": "b43d25f9b63c3be9d9b67ef81cb4cfc18c75a848",
+ "git-tree": "a6939590c8a4af6b772b6a0a40bf107451e9475e",
"version": "7.79.1",
"port-version": 1
},
diff --git a/versions/v-/vcpkg-cmake-config.json b/versions/v-/vcpkg-cmake-config.json
index 801f78c0..cd4fcce4 100644
--- a/versions/v-/vcpkg-cmake-config.json
+++ b/versions/v-/vcpkg-cmake-config.json
@@ -1,7 +1,7 @@
{
"versions": [
{
- "git-tree": "4d873c8d4d63892838c407e1b7eb1c297377a8b6",
+ "git-tree": "b53769d6f8e96ae25f0f8d619cf97e08ad270120",
"version-date": "2021-10-19",
"port-version": 0
},
return() | ||
endif() | ||
|
||
if (NOT folder_size EQUAL 1 AND NOT arg_USAGE) |
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.
ATM this function is called only for NOT arg_USAGE
.
You might actually make use of arg_USAGE
, by picking out the package name Pkg
(first item) and using that to limit the globbing to Pkg/PkgConfig.cmake
and pkg/pkg-config.cmake
. But this is not urgent as for now arg_USAGE
implies arg_TARGET_NAMES
.
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.
Can you please describe more?
As I know, some ports have generated pkg[Cc]onfig.cmake
files corresponding to different targets, so here we should prompt the maintainer for the usage.
endif() | ||
|
||
if (NOT folder_size EQUAL 1 AND NOT arg_USAGE) | ||
message(FATAL_ERROR "More than one folder contains cmake configuration files, please set \"TARGET_NAMES\" to select the certain target name") |
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.
Your are talking about deep trees within a single package. Here you statement makes sense.
But my focus was separate cmake packages.
This cannot be improved while iterating simultaneously over multiple cmake packages. In my previous comment, I should have used the words "splitting identifying package names from ...". Or better write pseudo code:
- Collect package names by non-recursive looking for
*/*Config.cmake */*-config.cmake
.
(This step could be skipped in case ofarg_USAGE
.) - For each package name, collect targets from the cmake files (maybe recursively).
(This step could be skipped in case ofarg_TARGET_NAMES
, assuming a single package name.)
endmacro() | ||
|
||
function(vcpkg_cmake_config_test) | ||
if (NOT _VCPKG_EDITABLE) |
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 understand the argument about build time, But edit mode is somewhat exceptional in my personal use, and it is propably inactive during CI.
endforeach() | ||
endif() | ||
|
||
foreach(target_name IN LISTS target_names) |
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.
That's the loop which is actually limiting us to the single cmake package case.
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.
Ah yes, but it doesn't matter, this function will only be enabled in the official triplet which doesn't include the single configuration triplet yet.
…jack/vcpkg_test_cmake_config
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.
This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout a91bc0c2d4af9a9e521cda0e39a1f108a8d17def -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/baseline.json b/versions/baseline.json
index 24c52c1f..f00e2849 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -1702,7 +1702,7 @@
},
"curl": {
"baseline": "7.80.0",
- "port-version": 0
+ "port-version": 1
},
"curlpp": {
"baseline": "2018-06-15",
@@ -7105,7 +7105,7 @@
"port-version": 0
},
"vcpkg-cmake-config": {
- "baseline": "2021-12-01",
+ "baseline": "2021-12-17",
"port-version": 0
},
"vcpkg-gfortran": {
diff --git a/versions/c-/curl.json b/versions/c-/curl.json
index a73767ce..97a8f51b 100644
--- a/versions/c-/curl.json
+++ b/versions/c-/curl.json
@@ -1,5 +1,10 @@
{
"versions": [
+ {
+ "git-tree": "847baeeb1e54716212cb71f724be3c0df71a4f43",
+ "version": "7.80.0",
+ "port-version": 1
+ },
{
"git-tree": "8e13da05c975cb6f5bed6cf3b8054a817a00b45d",
"version": "7.80.0",
diff --git a/versions/v-/vcpkg-cmake-config.json b/versions/v-/vcpkg-cmake-config.json
index dda29410..de6de278 100644
--- a/versions/v-/vcpkg-cmake-config.json
+++ b/versions/v-/vcpkg-cmake-config.json
@@ -1,5 +1,10 @@
{
"versions": [
+ {
+ "git-tree": "ca4fd79144060953c1a7ec689ccf3feb18b98650",
+ "version-date": "2021-12-17",
+ "port-version": 0
+ },
{
"git-tree": "51df1bbddb22782b9e7f23f9b3588674184e991a",
"version-date": "2021-12-01",
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.
This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout a91bc0c2d4af9a9e521cda0e39a1f108a8d17def -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/baseline.json b/versions/baseline.json
index 68bb36ba..02bd3657 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -1702,7 +1702,7 @@
},
"curl": {
"baseline": "7.80.0",
- "port-version": 0
+ "port-version": 1
},
"curlpp": {
"baseline": "2018-06-15",
@@ -7109,7 +7109,7 @@
"port-version": 0
},
"vcpkg-cmake-config": {
- "baseline": "2021-12-01",
+ "baseline": "2021-12-17",
"port-version": 0
},
"vcpkg-gfortran": {
diff --git a/versions/c-/curl.json b/versions/c-/curl.json
index a73767ce..97a8f51b 100644
--- a/versions/c-/curl.json
+++ b/versions/c-/curl.json
@@ -1,5 +1,10 @@
{
"versions": [
+ {
+ "git-tree": "847baeeb1e54716212cb71f724be3c0df71a4f43",
+ "version": "7.80.0",
+ "port-version": 1
+ },
{
"git-tree": "8e13da05c975cb6f5bed6cf3b8054a817a00b45d",
"version": "7.80.0",
diff --git a/versions/v-/vcpkg-cmake-config.json b/versions/v-/vcpkg-cmake-config.json
index dda29410..a9a78510 100644
--- a/versions/v-/vcpkg-cmake-config.json
+++ b/versions/v-/vcpkg-cmake-config.json
@@ -1,5 +1,10 @@
{
"versions": [
+ {
+ "git-tree": "d6b915f72cc87630c9bd0476314942ef17b2ba44",
+ "version-date": "2021-12-17",
+ "port-version": 0
+ },
{
"git-tree": "51df1bbddb22782b9e7f23f9b3588674184e991a",
"version-date": "2021-12-01",
I experiment with a modified variant of this PR which also covers testing CMake Find modules (eventually replacing the cmake-user test port). I think I can turn this into a proper PR in the next days. With regard to control over enabling certain tests, I would suggest to use a directory like |
In favor of #22258. |
This function will replace
vcpkg_test_cmake
, have the following features:Usage:
vcpkg_cmake_config_test( USAGE Curl CONFIG TARGET_NAMES CURL::libcurl HEADERS curl/curl.h FUNCTIONS curl_global_init )
To test the header file path and function symbols, we can create
vcpkg-test.cpp
/vcpkg-test.c
in PORT_DIR and add test code to it. Example:vcpkg-test.cpp:
For further testing of cmake export variables, we can also create vcpkg-test.cmake in PORT_DIR and write test cmake code.
For exmaple:
Add
vcpkg_cmake_config_test()
to ports/cjson/portfile.cmake, installcjson
with--debug
, the expected error will shows (known bug):log details: