|
| 1 | +# |
| 2 | +# Copyright 2025 Adobe. All rights reserved. |
| 3 | +# This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | +# of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | +# OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | +# governing permissions and limitations under the License. |
| 11 | +# |
| 12 | +include_guard(GLOBAL) |
| 13 | + |
| 14 | +# Using full path because this is included early in our root CMakeLists.txt |
| 15 | +include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) |
| 16 | +CPMAddPackage( |
| 17 | + NAME CMakeExtraUtils |
| 18 | + GITHUB_REPOSITORY LecrisUT/CMakeExtraUtils |
| 19 | + GIT_TAG v0.4.1 |
| 20 | + |
| 21 | + # There is a bug in CPM when using DOWNLOAD_ONLY that before the first project() call. |
| 22 | + # Because CPM attempts to bypass FetchContent, subsequent calls to FetchContent_GetProperties() |
| 23 | + # may not give any result. This seems to only happen when the package is added with DOWNLOAD_ONLY. |
| 24 | + # |
| 25 | + # https://github.com/cpm-cmake/CPM.cmake/issues/227 |
| 26 | + # |
| 27 | + SOURCE_SUBDIR cmake |
| 28 | +) |
| 29 | + |
| 30 | +# Due to the bug mentioned above, ${cmakeextrautils_SOURCE_DIR} can point to either the subdir or |
| 31 | +# the root dir of the CMakeExtraUtils, depending on whether the cache is already populated. This is |
| 32 | +# really ugly, but have to work around it for now. |
| 33 | +FetchContent_GetProperties(CMakeExtraUtils) |
| 34 | +if(EXISTS ${cmakeextrautils_SOURCE_DIR}/DynamicVersion.cmake) |
| 35 | + include(${cmakeextrautils_SOURCE_DIR}/DynamicVersion.cmake) |
| 36 | +else() |
| 37 | + include(${cmakeextrautils_SOURCE_DIR}/cmake/DynamicVersion.cmake) |
| 38 | +endif() |
0 commit comments