CPM.cmake icon indicating copy to clipboard operation
CPM.cmake copied to clipboard

Added export of `CPM_LAST_PACKAGE_NAME`

Open CraigHutchinson opened this issue 3 years ago • 5 comments

  • Updated docs respectively

#400

CraigHutchinson avatar Sep 14 '22 07:09 CraigHutchinson

image @iboB @TheLartians Any idea on this one as the style conformance issue is not clear here!?

CraigHutchinson avatar Sep 14 '22 08:09 CraigHutchinson

Confirmed as working: image

CraigHutchinson avatar Sep 20 '22 08:09 CraigHutchinson

Note that you can run the unit tests locally using the following commands.

cmake -Stest -Bbuild/test
cmake --build build/test --target test-verbose

Or, to run a single test, e.g. package_name_from_git_uri.cmake:

cmake -DCPM_PATH=$(pwd)/cmake -P test/unit/package_name_from_git_uri.cmake

And also auto-format the code style style using cmake-format as below.

cmake -Stest/style -Bbuild/style
cmake --build build/style --target fix-format

(this should be added to a contributors readme eventually)

TheLartians avatar Sep 20 '22 21:09 TheLartians

Note that you can run the unit tests locally using the following commands.

@TheLartians Thanks for this info, invaluable :) UPDATE: Now I built the target Visual-Studio test-Explorer integration is working for this.... I will need to investigate how the Cmake unit-tests work as it looks like you've done some nice work here!

EDIT: I would also consider looking at creating a CmakePresets.json to this affect but should save this for a future Pull to keep this one clean.

EDIT2: It would also be useful if the UNit-test used a separate or temporary CPM_Cache location as it will currently be affected if/as there may already be an existing cache for packages of the name used in the test under some circumstances 🐞

CraigHutchinson avatar Sep 21 '22 08:09 CraigHutchinson

I have updated and fixed the additional tests. However, I get failure on this test prior & post my additional changes. HOpefully it is a local issue only TBC image

CraigHutchinson avatar Sep 21 '22 08:09 CraigHutchinson

EDIT2: It would also be useful if the UNit-test used a separate or temporary CPM_Cache location as it will currently be affected if/as there may already be an existing cache for packages of the name used in the test under some circumstances

Sounds like a good idea, though it may be even better to move all "unit-tests" that build a full project into the more extensive integration test suite at this point.

TheLartians avatar Sep 27 '22 19:09 TheLartians

Looks good, could you run cmake-format or the fix-format target to update the code style?

Not made much progress here yet, getting an error and not sure how to proceed 'yet': RuntimeError: Failed to parse C:\development\CPM.cmake\.cmake-format as any of yaml, json, or python

UPDATE: This is not a CPM issue but a cmake-format issue in that errors are not reported when the .cmake-format file does not include the .yaml extension. I went and reported this over at https://github.com/cheshirekow/cmake_format/issues/299

CraigHutchinson avatar Sep 28 '22 11:09 CraigHutchinson

It seems that the style checks are still failing, though to be honest, I don't see why

iboB avatar Sep 28 '22 17:09 iboB

Tried it on my machine and it removed a trailing whitespace. @CraigHutchinson did you install the required dependencies? That should be easy using pip:

pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml

UPDATE: This is not a CPM issue but a cmake-format issue in that errors are not reported when the .cmake-format file does not include the .yaml extension. I went and reported this over at https://github.com/cheshirekow/cmake_format/issues/299

Just saw this, that is indeed a weird error message. Anyways just pushed my change and am happy with the PR now. Thanks!

TheLartians avatar Sep 28 '22 18:09 TheLartians

@TheLartians thanks for sorting the extra space, I shall try harder next time! As it stands I had issues with the fix-cmake in that it was changing line-endings in ALL the source files, I would gather in omitting this the space fix was also lost. I haven't investigated yet, but my expectation is the issue should be git config related as the message is "LF will be replaced by CRLF the next time Git touches it"

CraigHutchinson avatar Sep 29 '22 08:09 CraigHutchinson