Browse Source
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+.pull/7530/head
23 changed files with 90 additions and 79 deletions
@ -1,11 +1,11 @@ |
|||||||
include(functions/FetchContent_MakeAvailableExcludeFromAll) |
include(functions/FetchContent_ExcludeFromAll_backport) |
||||||
|
|
||||||
include(FetchContent) |
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 https://github.com/cxong/find_steam_game/archive/a2bd6273fc002214052c2ee3bd48d7c1e7d3f366.tar.gz |
||||||
URL_HASH MD5=a6950ce5d9ced8a259752bc2dc7f5311 |
URL_HASH MD5=a6950ce5d9ced8a259752bc2dc7f5311 |
||||||
) |
) |
||||||
FetchContent_MakeAvailableExcludeFromAll(find_steam_game) |
FetchContent_MakeAvailable_ExcludeFromAll(find_steam_game) |
||||||
|
|
||||||
add_library(find_steam_game INTERFACE) |
add_library(find_steam_game INTERFACE) |
||||||
target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) |
target_include_directories(find_steam_game INTERFACE ${find_steam_game_SOURCE_DIR}) |
||||||
|
|||||||
@ -1,13 +1,13 @@ |
|||||||
include(functions/FetchContent_MakeAvailableExcludeFromAll) |
include(functions/FetchContent_ExcludeFromAll_backport) |
||||||
|
|
||||||
set(SOL2_ENABLE_INSTALL OFF) |
set(SOL2_ENABLE_INSTALL OFF) |
||||||
|
|
||||||
include(FetchContent) |
include(FetchContent) |
||||||
FetchContent_Declare(sol2 |
FetchContent_Declare_ExcludeFromAll(sol2 |
||||||
URL https://github.com/ThePhD/sol2/archive/9c882a28fdb6f4ad79a53a4191b43ce48a661175.tar.gz |
URL https://github.com/ThePhD/sol2/archive/9c882a28fdb6f4ad79a53a4191b43ce48a661175.tar.gz |
||||||
URL_HASH MD5=2637c3fcdcce3ff34b36437c1d3b99d1 |
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_include_directories(sol2 SYSTEM BEFORE INTERFACE ${CMAKE_CURRENT_LIST_DIR}/sol_config) |
||||||
target_compile_definitions(sol2 INTERFACE SOL_NO_EXCEPTIONS=1) |
target_compile_definitions(sol2 INTERFACE SOL_NO_EXCEPTIONS=1) |
||||||
|
|||||||
@ -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() |
||||||
@ -1,14 +0,0 @@ |
|||||||
# Like `FetchContent_MakeAvailable` but passes EXCLUDE_FROM_ALL to `add_subdirectory`. |
|
||||||
macro(FetchContent_MakeAvailableExcludeFromAll) |
|
||||||
foreach(contentName IN ITEMS ${ARGV}) |
|
||||||
string(TOLOWER ${contentName} contentNameLower) |
|
||||||
FetchContent_GetProperties(${contentName}) |
|
||||||
if(NOT ${contentNameLower}_POPULATED) |
|
||||||
FetchContent_Populate(${contentName}) |
|
||||||
if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt) |
|
||||||
add_subdirectory(${${contentNameLower}_SOURCE_DIR} |
|
||||||
${${contentNameLower}_BINARY_DIR} EXCLUDE_FROM_ALL) |
|
||||||
endif() |
|
||||||
endif() |
|
||||||
endforeach() |
|
||||||
endmacro() |
|
||||||
Loading…
Reference in new issue