-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: FetchContent
EXCLUDE_FROM_ALL
fixes
On CMake v3.28+, `EXCLUDE_FROM_ALL` is supported natively as an argument to `FetchContent_Declare`. On CMake v3.30+, `FetchContent_Populate`, which we use to polyfill `EXCLUDE_FROM_ALL` support for older versions of CMake, is deprecated and triggers a noisy warning. Avoids the warning by using the native `EXCLUDE_FROM_ALL` support on CMake v3.28+.
- Loading branch information
Showing
23 changed files
with
90 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
include(functions/FetchContent_MakeAvailableExcludeFromAll) | ||
include(functions/FetchContent_ExcludeFromAll_backport) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare(find_steam_game | ||
FetchContent_Declare_ExcludeFromAll(find_steam_game | ||
URL https://github.com/cxong/find_steam_game/archive/a2bd6273fc002214052c2ee3bd48d7c1e7d3f366.tar.gz | ||
URL_HASH MD5=a6950ce5d9ced8a259752bc2dc7f5311 | ||
) | ||
FetchContent_MakeAvailableExcludeFromAll(find_steam_game) | ||
FetchContent_MakeAvailable_ExcludeFromAll(find_steam_game) | ||
|
||
add_library(find_steam_game INTERFACE) | ||
target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
include(functions/FetchContent_MakeAvailableExcludeFromAll) | ||
include(functions/FetchContent_ExcludeFromAll_backport) | ||
|
||
set(SOL2_ENABLE_INSTALL OFF) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare(sol2 | ||
FetchContent_Declare_ExcludeFromAll(sol2 | ||
URL https://github.com/ThePhD/sol2/archive/9c882a28fdb6f4ad79a53a4191b43ce48a661175.tar.gz | ||
URL_HASH MD5=2637c3fcdcce3ff34b36437c1d3b99d1 | ||
) | ||
FetchContent_MakeAvailableExcludeFromAll(sol2) | ||
FetchContent_MakeAvailable_ExcludeFromAll(sol2) | ||
|
||
target_include_directories(sol2 SYSTEM BEFORE INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sol_config) | ||
target_compile_definitions(sol2 INTERFACE SOL_NO_EXCEPTIONS=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
include(functions/FetchContent_MakeAvailableExcludeFromAll) | ||
include(functions/FetchContent_ExcludeFromAll_backport) | ||
include(FetchContent) | ||
|
||
set(unordered_dense_URL "https://github.com/martinus/unordered_dense/archive/refs/tags/v4.4.0.tar.gz") | ||
set(unordered_dense_HASH "f33c294a010540434b272754f937decf") | ||
|
||
if(MINGW_CROSS) | ||
find_package(Patch REQUIRED) | ||
FetchContent_Declare(unordered_dense | ||
FetchContent_Declare_ExcludeFromAll(unordered_dense | ||
URL ${unordered_dense_URL} | ||
URL_HASH MD5=${unordered_dense_HASH} | ||
PATCH_COMMAND "${Patch_EXECUTABLE}" -p1 -N < "${CMAKE_CURRENT_LIST_DIR}/0001-Disable-PMR-support-for-mingw-std-threads-compat.patch" || true | ||
) | ||
else() | ||
FetchContent_Declare(unordered_dense | ||
FetchContent_Declare_ExcludeFromAll(unordered_dense | ||
URL ${unordered_dense_URL} | ||
URL_HASH MD5=${unordered_dense_HASH} | ||
) | ||
endif() | ||
FetchContent_MakeAvailableExcludeFromAll(unordered_dense) | ||
FetchContent_MakeAvailable_ExcludeFromAll(unordered_dense) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
CMake/functions/FetchContent_ExcludeFromAll_backport.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
if(CMAKE_VERSION VERSION_LESS "3.28.0") | ||
macro(FetchContent_Declare_ExcludeFromAll) | ||
FetchContent_Declare(${ARGV}) | ||
endmacro() | ||
# Like `FetchContent_MakeAvailable` but passes EXCLUDE_FROM_ALL to `add_subdirectory`. | ||
macro(FetchContent_MakeAvailable_ExcludeFromAll) | ||
foreach(name ${ARGV}) | ||
string(TOLOWER ${name} nameLower) | ||
FetchContent_GetProperties(${name}) | ||
if(NOT ${${nameLower}_POPULATED}) | ||
FetchContent_Populate(${name}) | ||
if(EXISTS ${${nameLower}_SOURCE_DIR}/CMakeLists.txt) | ||
add_subdirectory(${${nameLower}_SOURCE_DIR} ${${nameLower}_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
endif() | ||
endif() | ||
endforeach() | ||
endmacro() | ||
else() | ||
macro(FetchContent_Declare_ExcludeFromAll) | ||
FetchContent_Declare(${ARGV} EXCLUDE_FROM_ALL) | ||
endmacro() | ||
macro(FetchContent_MakeAvailable_ExcludeFromAll) | ||
FetchContent_MakeAvailable(${ARGV}) | ||
endmacro() | ||
endif() |
Oops, something went wrong.