mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-22 12:17:36 -05:00
Default to remote packages (#38)
* Update CPM.cmake * Update CPM.cmake * Update README.md
This commit is contained in:
@@ -52,7 +52,7 @@ To update CPM to the newest version, simply update the script in the project's c
|
||||
|
||||
# Options
|
||||
|
||||
If you set the CMake option `CPM_REMOTE_PACKAGES_ONLY` to `On`, packages will always be fetched via the URL. Setting `CPM_LOCAL_PACKAGES_ONLY` to `On` will only add packages via `find_package`.
|
||||
Setting the CMake option `CPM_USE_LOCAL_PACKAGES` will activate finding packages via `find_package`. If the option `CPM_LOCAL_PACKAGES_ONLY` is set, CPM will only use local packages.
|
||||
|
||||
# Advantages
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ endif()
|
||||
set(CPM_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")
|
||||
set(CPM_PACKAGES "" CACHE INTERNAL "")
|
||||
|
||||
option(CPM_USE_LOCAL_PACKAGES "Use locally installed packages (find_package)" OFF)
|
||||
option(CPM_LOCAL_PACKAGES_ONLY "Use only locally installed packages" OFF)
|
||||
option(CPM_REMOTE_PACKAGES_ONLY "Always download packages" OFF)
|
||||
|
||||
include(FetchContent)
|
||||
include(CMakeParseArguments)
|
||||
@@ -83,7 +83,7 @@ function(CPMAddPackage)
|
||||
|
||||
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (CPM_ARGS_VERSION AND NOT CPM_ARGS_OPTIONS AND NOT ${CPM_REMOTE_PACKAGES_ONLY})
|
||||
if(${CPM_USE_LOCAL_PACKAGES} OR ${CPM_LOCAL_PACKAGES_ONLY})
|
||||
find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION} QUIET)
|
||||
|
||||
if(${CPM_PACKAGE_FOUND})
|
||||
@@ -94,10 +94,10 @@ function(CPMAddPackage)
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${CPM_LOCAL_PACKAGES_ONLY})
|
||||
message(SEND_ERROR "CPM: ${CPM_ARGS_NAME} not found via findpackage(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})")
|
||||
message(SEND_ERROR "CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT CPM_ARGS_VERSION)
|
||||
|
||||
Reference in New Issue
Block a user