summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FetchContent.cmake49
-rw-r--r--Modules/GNUInstallDirs.cmake4
2 files changed, 46 insertions, 7 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 5ca296e..83aafa8 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1159,9 +1159,12 @@ function(FetchContent_Declare contentName)
set(options "")
set(oneValueArgs
+ SVN_REPOSITORY
+ DOWNLOAD_NO_EXTRACT
+ DOWNLOAD_EXTRACT_TIMESTAMP
+ URL
BINARY_DIR
SOURCE_DIR
- SVN_REPOSITORY
)
set(multiValueArgs "")
@@ -1188,13 +1191,47 @@ function(FetchContent_Declare contentName)
string(SHA1 urlSHA ${ARG_SVN_REPOSITORY})
string(SUBSTRING ${urlSHA} 0 7 urlSHA)
string(APPEND ARG_SOURCE_DIR "-${urlSHA}")
- list(PREPEND ARG_UNPARSED_ARGUMENTS SVN_REPOSITORY "${ARG_SVN_REPOSITORY}")
endif()
- list(PREPEND ARG_UNPARSED_ARGUMENTS
- SOURCE_DIR "${ARG_SOURCE_DIR}"
- BINARY_DIR "${ARG_BINARY_DIR}"
- )
+ # The ExternalProject_Add() call in the sub-build won't see the CMP0135
+ # policy setting of our caller. Work out if that policy will be needed and
+ # explicitly set the relevant option if not already provided. The condition
+ # here is essentially an abbreviated version of the logic in
+ # ExternalProject's _ep_add_download_command() function.
+ if(ARG_URL AND
+ NOT IS_DIRECTORY "${ARG_URL}" AND
+ NOT ARG_DOWNLOAD_NO_EXTRACT AND
+ NOT DEFINED ARG_DOWNLOAD_EXTRACT_TIMESTAMP)
+ cmake_policy(GET CMP0135 _FETCHCONTENT_CMP0135
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if(_FETCHCONTENT_CMP0135 STREQUAL "")
+ message(AUTHOR_WARNING
+ "The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy "
+ "CMP0135 is not set. The policy's OLD behavior will be used. "
+ "When using a URL download, the timestamps of extracted files "
+ "should preferably be that of the time of extraction, otherwise "
+ "code that depends on the extracted contents might not be "
+ "rebuilt if the URL changes. The OLD behavior preserves the "
+ "timestamps from the archive instead, but this is usually not "
+ "what you want. Update your project to the NEW behavior or "
+ "specify the DOWNLOAD_EXTRACT_TIMESTAMP option with a value of "
+ "true to avoid this robustness issue."
+ )
+ set(ARG_DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+ elseif(_FETCHCONTENT_CMP0135 STREQUAL "NEW")
+ set(ARG_DOWNLOAD_EXTRACT_TIMESTAMP FALSE)
+ else()
+ set(ARG_DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+ endif()
+ endif()
+
+ # Add back in the keyword args we pulled out and potentially tweaked/added
+ foreach(key IN LISTS oneValueArgs)
+ if(DEFINED ARG_${key})
+ list(PREPEND ARG_UNPARSED_ARGUMENTS ${key} "${ARG_${key}}")
+ endif()
+ endforeach()
set(__argsQuoted)
foreach(__item IN LISTS ARG_UNPARSED_ARGUMENTS)
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index bd72901..9796854 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -112,6 +112,8 @@ The following values of :variable:`CMAKE_INSTALL_PREFIX` are special:
For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``.
This is defined by the `Filesystem Hierarchy Standard`_.
+ This behavior does not apply to paths under ``/opt/homebrew/...``.
+
.. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
Macros
@@ -400,7 +402,7 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var)
else()
set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
- elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*")
+ elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/" AND NOT "${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/homebrew/")
if("${GGAID_dir}" STREQUAL "SYSCONFDIR" OR "${GGAID_dir}" STREQUAL "LOCALSTATEDIR" OR "${GGAID_dir}" STREQUAL "RUNSTATEDIR")
set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}")
else()