mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-24 05:08:01 -05:00
SOURCE_DIR option disable call to find_package() (#456)
This commit is contained in:
@@ -199,11 +199,14 @@ This can be controlled on a per package basis with the `CPM_DOWNLOAD_<dependency
|
|||||||
### CPM_USE_LOCAL_PACKAGES
|
### CPM_USE_LOCAL_PACKAGES
|
||||||
|
|
||||||
CPM can be configured to use `find_package` to search for locally installed dependencies first by setting the CMake option `CPM_USE_LOCAL_PACKAGES`.
|
CPM can be configured to use `find_package` to search for locally installed dependencies first by setting the CMake option `CPM_USE_LOCAL_PACKAGES`.
|
||||||
|
|
||||||
If the option `CPM_LOCAL_PACKAGES_ONLY` is set, CPM will emit an error if the dependency is not found locally.
|
If the option `CPM_LOCAL_PACKAGES_ONLY` is set, CPM will emit an error if the dependency is not found locally.
|
||||||
These options can also be set as environmental variables.
|
These options can also be set as environmental variables.
|
||||||
|
|
||||||
In the case that `find_package` requires additional arguments, the parameter `FIND_PACKAGE_ARGUMENTS` may be specified in the `CPMAddPackage` call. The value of this parameter will be forwarded to `find_package`.
|
In the case that `find_package` requires additional arguments, the parameter `FIND_PACKAGE_ARGUMENTS` may be specified in the `CPMAddPackage` call. The value of this parameter will be forwarded to `find_package`.
|
||||||
|
|
||||||
|
Note that this does not apply to dependencies that have been defined with a truthy `FORCE` parameter. These will be added as defined.
|
||||||
|
|
||||||
### CPM_USE_NAMED_CACHE_DIRECTORIES
|
### CPM_USE_NAMED_CACHE_DIRECTORIES
|
||||||
|
|
||||||
If set, CPM use additional directory level in cache to improve readability of packages names in IDEs like CLion. It changes cache structure, so all dependencies are downloaded again. There is no problem to mix both structures in one cache directory but then there may be 2 copies of some dependencies.
|
If set, CPM use additional directory level in cache to improve readability of packages names in IDEs like CLion. It changes cache structure, so all dependencies are downloaded again. There is no problem to mix both structures in one cache directory but then there may be 2 copies of some dependencies.
|
||||||
|
|||||||
@@ -648,19 +648,21 @@ function(CPMAddPackage)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
|
if(NOT CPM_ARGS_FORCE)
|
||||||
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
|
if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
|
||||||
|
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
|
||||||
|
|
||||||
if(CPM_PACKAGE_FOUND)
|
if(CPM_PACKAGE_FOUND)
|
||||||
cpm_export_variables(${CPM_ARGS_NAME})
|
cpm_export_variables(${CPM_ARGS_NAME})
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CPM_LOCAL_PACKAGES_ONLY)
|
if(CPM_LOCAL_PACKAGES_ONLY)
|
||||||
message(
|
message(
|
||||||
SEND_ERROR
|
SEND_ERROR
|
||||||
"${CPM_INDENT} ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
|
"${CPM_INDENT} ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user