Skip to content

Commit 90eb090

Browse files
committed
Get rid of overengineered macro
While the macro's implementation was fine based on the documentation for CMake 3.16, which we (currently) use, later versions of CMake recommend against this approach. https://gitlab.com/OpenMW/openmw/-/merge_requests/4777 has an implementation that picks between a native feature added later that does the same job if it's available, but uses the one we already had if it isn't. That's not ideal as the implementation ends up complicated and we'd have two code paths to support. There's a simpler approach where we just temporarily set the directory property and call the real function, which would probably be the best approach in the general case. However, as we want to set the directory property for everything in the directory, we can just set it on the `extern` directory, and then we don't need the macro at all.
1 parent 4a062c0 commit 90eb090

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

extern/CMakeLists.txt

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22

3+
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL on)
34
set(CMAKE_CXX_CLANG_TIDY "")
45

5-
# Like `FetchContent_MakeAvailable` but passes EXCLUDE_FROM_ALL to `add_subdirectory`.
6-
macro(FetchContent_MakeAvailableExcludeFromAll)
7-
foreach(contentName IN ITEMS ${ARGV})
8-
string(TOLOWER ${contentName} contentNameLower)
9-
FetchContent_GetProperties(${contentName})
10-
if(NOT ${contentNameLower}_POPULATED)
11-
FetchContent_Populate(${contentName})
12-
if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
13-
add_subdirectory(${${contentNameLower}_SOURCE_DIR}
14-
${${contentNameLower}_BINARY_DIR} EXCLUDE_FROM_ALL)
15-
endif()
16-
endif()
17-
endforeach()
18-
endmacro()
19-
206
if(NOT OPENMW_USE_SYSTEM_BULLET)
217

228
set(BUILD_BULLET3 OFF CACHE BOOL "")
@@ -52,7 +38,7 @@ if(NOT OPENMW_USE_SYSTEM_BULLET)
5238
URL_HASH SHA512=a5105bf5f1dd365a64a350755c7d2c97942f74897a18dcdb3651e6732fd55cc1030a096f5808cf50575281f05e3ac09aa50a48d271a47b94cd61f5167a72b7cc
5339
SOURCE_DIR fetched/bullet
5440
)
55-
FetchContent_MakeAvailableExcludeFromAll(bullet)
41+
FetchContent_MakeAvailable(bullet)
5642

5743
set(BULLET_INCLUDE_DIRS ${bullet_SOURCE_DIR}/src PARENT_SCOPE)
5844

@@ -82,7 +68,7 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI)
8268
URL_HASH SHA512=c804ef665e786076582367f171082cd2181fdbd214300ddcca4a4245c5a0f45e62e72778ee2d96ec46b393e22477dd729f9bb3006e6eecbf536674e34a057721
8369
SOURCE_DIR fetched/mygui
8470
)
85-
FetchContent_MakeAvailableExcludeFromAll(mygui)
71+
FetchContent_MakeAvailable(mygui)
8672

8773
set(MyGUI_INCLUDE_DIRS ${mygui_SOURCE_DIR}/MyGUIEngine/include PARENT_SCOPE)
8874
set(MyGUI_LIBRARIES MyGUIEngine PARENT_SCOPE)
@@ -148,7 +134,7 @@ if(NOT OPENMW_USE_SYSTEM_OSG)
148134
URL_HASH SHA512=9b0a94c1c1d99c767f1857629d43c7a53bfcb74ef760993a121567831e168a1ebbfc10b0c67d7f2241c7b6c6dab2d0e6b876d9f17aca0fabe1a8c86b2279f956
149135
SOURCE_DIR fetched/osg
150136
)
151-
FetchContent_MakeAvailableExcludeFromAll(osg)
137+
FetchContent_MakeAvailable(osg)
152138

153139
set(OPENSCENEGRAPH_INCLUDE_DIRS ${osg_SOURCE_DIR}/include ${osg_BINARY_DIR}/include PARENT_SCOPE)
154140
set(OSG_LIBRARIES OpenThreads osg PARENT_SCOPE)
@@ -179,7 +165,7 @@ if(NOT OPENMW_USE_SYSTEM_RECASTNAVIGATION)
179165
URL_HASH SHA512=48f20cee7a70c2f20f4c68bb74d5af11a1434be85294e37f5fe7b7aae820fbcdff4f35d3be286eaf6f9cbce0aed4201fcc090df409a5bd04aec5fd7c29b3ad94
180166
SOURCE_DIR fetched/recastnavigation
181167
)
182-
FetchContent_MakeAvailableExcludeFromAll(recastnavigation)
168+
FetchContent_MakeAvailable(recastnavigation)
183169
endif()
184170

185171
if (NOT OPENMW_USE_SYSTEM_SQLITE3)
@@ -189,7 +175,7 @@ if (NOT OPENMW_USE_SYSTEM_SQLITE3)
189175
URL_HASH SHA512=7de291709e88fffc693cf24ac675950cfc35c1bf7631cfea95167105720a05cf37fb943c57c5c985db2eeaa57b31894b3c0df98a7bd2939b5746fc5a24b5ae87
190176
SOURCE_DIR fetched/sqlite3
191177
)
192-
FetchContent_MakeAvailableExcludeFromAll(sqlite3)
178+
FetchContent_MakeAvailable(sqlite3)
193179

194180
add_library(sqlite3 STATIC ${sqlite3_SOURCE_DIR}/sqlite3.c)
195181
target_include_directories(sqlite3 INTERFACE ${sqlite3_SOURCE_DIR}/)
@@ -217,7 +203,7 @@ if (BUILD_BENCHMARKS AND NOT OPENMW_USE_SYSTEM_BENCHMARK)
217203
URL_HASH SHA512=d73587ad9c49338749e1d117a6f8c7ff9c603a91a2ffa91a7355c7df7dea82710b9a810d34ddfef20973ecdc77092ec10fb2b4e4cc8d2e7810cbed79617b3828
218204
SOURCE_DIR fetched/benchmark
219205
)
220-
FetchContent_MakeAvailableExcludeFromAll(benchmark)
206+
FetchContent_MakeAvailable(benchmark)
221207
endif()
222208

223209
if (NOT OPENMW_USE_SYSTEM_YAML_CPP)
@@ -233,7 +219,7 @@ if (NOT OPENMW_USE_SYSTEM_YAML_CPP)
233219
URL_HASH MD5=1e8ca0d6ccf99f3ed9506c1f6937d0ec
234220
SOURCE_DIR fetched/yaml-cpp
235221
)
236-
FetchContent_MakeAvailableExcludeFromAll(yaml-cpp)
222+
FetchContent_MakeAvailable(yaml-cpp)
237223

238224
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
239225
target_precompile_headers(yaml-cpp PRIVATE <algorithm>)
@@ -306,7 +292,7 @@ if ((BUILD_COMPONENTS_TESTS OR BUILD_OPENCS_TESTS OR BUILD_OPENMW_TESTS) AND NOT
306292
if (MSVC)
307293
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
308294
endif()
309-
FetchContent_MakeAvailableExcludeFromAll(googletest)
295+
FetchContent_MakeAvailable(googletest)
310296

311297
add_library(GTest::GTest ALIAS gtest)
312298
add_library(GMock::GMock ALIAS gmock)

0 commit comments

Comments
 (0)