@@ -131,12 +131,6 @@ else()
131131 set (HWLOC_ENABLE_TESTING OFF )
132132 set (HWLOC_SKIP_LSTOPO ON )
133133 set (HWLOC_SKIP_TOOLS ON )
134- set (HWLOC_PATCH
135- git
136- apply
137- ${PROJECT_SOURCE_DIR} /cmake/fix_coverity_issues.patch
138- ||
139- (exit 0))
140134
141135 message (
142136 STATUS
@@ -147,23 +141,16 @@ else()
147141 hwloc_targ
148142 GIT_REPOSITORY ${UMF_HWLOC_REPO}
149143 GIT_TAG ${UMF_HWLOC_TAG}
150- PATCH_COMMAND ${HWLOC_PATCH} SOURCE_SUBDIR contrib/windows-cmake/
151- FIND_PACKAGE_ARGS)
144+ SOURCE_SUBDIR contrib/windows-cmake/
145+ FIND_PACKAGE_ARGS)
152146 FetchContent_MakeAvailable(hwloc_targ)
153147
154148 set (LIBHWLOC_INCLUDE_DIRS
155149 ${hwloc_targ_SOURCE_DIR} /include ;${hwloc_targ_BINARY_DIR} /include )
156150 set (LIBHWLOC_LIBRARY_DIRS
157151 ${hwloc_targ_BINARY_DIR} /Release;${hwloc_targ_BINARY_DIR} /Debug)
158- else ()
152+ else () # NOT WINDOWS
159153 include (FetchContent)
160- set (HWLOC_PATCH
161- git
162- apply
163- ${PROJECT_SOURCE_DIR} /cmake/fix_coverity_issues.patch
164- ||
165- (exit 0))
166-
167154 message (
168155 STATUS
169156 "Will fetch hwloc from ${UMF_HWLOC_REPO} (tag: ${UMF_HWLOC_TAG} )"
@@ -172,8 +159,7 @@ else()
172159 FetchContent_Declare(
173160 hwloc_targ
174161 GIT_REPOSITORY ${UMF_HWLOC_REPO}
175- GIT_TAG ${UMF_HWLOC_TAG}
176- PATCH_COMMAND ${HWLOC_PATCH} )
162+ GIT_TAG ${UMF_HWLOC_TAG} )
177163 FetchContent_MakeAvailable(hwloc_targ)
178164
179165 add_custom_command (
@@ -217,6 +203,21 @@ else()
217203 message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
218204endif ()
219205
206+ if (hwloc_targ_SOURCE_DIR)
207+ # apply security patch for HWLOC
208+ execute_process (COMMAND git apply ${PROJECT_SOURCE_DIR} /cmake/fix_coverity_issues.patch
209+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
210+ OUTPUT_VARIABLE UMF_HWLOC_PATCH_OUTPUT
211+ ERROR_VARIABLE UMF_HWLOC_PATCH_ERROR)
212+
213+ if (UMF_HWLOC_PATCH_OUTPUT)
214+ message (STATUS "HWLOC patch:\n ${UMF_HWLOC_PATCH_OUTPUT} " )
215+ endif ()
216+ if (UMF_HWLOC_PATCH_ERROR)
217+ message (WARNING "HWLOC patch:\n ${UMF_HWLOC_PATCH_ERROR} " )
218+ endif ()
219+ endif ()
220+
220221# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
221222# set, because in this case the build type is determined after a CMake
222223# configuration is done (at the build time)
0 commit comments