Unable to determine Name from Single-arg call to `CPMAddPackage`
Situation
A URI is provided from external/user CMAKE in CPM single-argument format e.g.
set( USER_CPM_URI "gh:jbeder/yaml-cpp#[email protected]"
CPMAddPackage( ${USER_CPM_URI} )
if ( ???_ADDED ) ## Unable to implement check as `NAME` is necessary
Issue
Some logic needs to check if the package _ADDED has been set and also use the _SOURCE_DIR for further modification and checks.
The name of the package isn't sent to the parent scope it appears.
if ( ???_ADDED )
Propose Solution
One idea is if CPM_PACKAGE_NAME were added to parent scope representing the Name of the last package that was added . This would be consistent with behavior like PROJECT_NAME is the last name for CMake project()
I agree that it would be good to have a way to obtain the inferred name for a package.
I don't mind the proposal. CPM_LAST_PACKAGE_NAME sounds better to me as a name but I'm also ok with the proposed one.
Two lines around here should do the trick: https://github.com/cpm-cmake/CPM.cmake/blob/master/cmake/CPM.cmake#L597
@TheLartians what you think?
I can see how this would be useful, and don't have anything against it. For naming I agree that CPM_LAST_PACKAGE_NAME makes the intent more clear.
@CraigHutchinson do you want to make a PR for this?
Pull-confirmed as working:

Closed by #403