summaryrefslogtreecommitdiff
path: root/Modules/FetchContent.cmake
diff options
context:
space:
mode:
authorHarald Fernengel <59298-harry1701@users.noreply.gitlab.kitware.com>2022-08-12 20:43:49 +0200
committerCraig Scott <craig.scott@crascit.com>2022-08-13 09:44:45 +1000
commitb57681dc3431f44ad4a27a6a38fb68a5c6ca097f (patch)
treea79574e15cad8b614cf65dfff05441ee9b1da298 /Modules/FetchContent.cmake
parentc4a07be9262f12ea075736dcd8dda4a030e37e89 (diff)
downloadcmake-b57681dc3431f44ad4a27a6a38fb68a5c6ca097f.tar.gz
FetchContent: Fix protobuf example to avoid CMP0077 warning
The protobuf example would raise a "Policy CMP0077" warning and protobuf tests would still be built, e.g. setting the variable is ignored in latest CMake. Set an INTERNAL cache variable instead so that CMP0077 warnings won't be triggered.
Diffstat (limited to 'Modules/FetchContent.cmake')
-rw-r--r--Modules/FetchContent.cmake7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index d016fb5aed..9747cd9559 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -881,9 +881,10 @@ Overriding Where To Find CMakeLists.txt
If the sub-project's ``CMakeLists.txt`` file is not at the top level of its
source tree, the ``SOURCE_SUBDIR`` option can be used to tell ``FetchContent``
-where to find it. The following example shows how to use that option and
+where to find it. The following example shows how to use that option, and
it also sets a variable which is meaningful to the subproject before pulling
-it into the main build:
+it into the main build (set as an ``INTERNAL`` cache variable to avoid
+problems with policy :policy:`CMP0077`):
.. code-block:: cmake
@@ -894,7 +895,7 @@ it into the main build:
GIT_TAG ae50d9b9902526efd6c7a1907d09739f959c6297 # v3.15.0
SOURCE_SUBDIR cmake
)
- set(protobuf_BUILD_TESTS OFF)
+ set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(protobuf)
Complex Dependency Hierarchies