@@ -48,8 +48,10 @@ option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
48
48
option (UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF )
49
49
option (UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF )
50
50
option (UMF_DEVELOPER_MODE "Enable additional developer checks" OFF )
51
- option (UMF_LINK_HWLOC_STATICALLY
52
- "Link UMF with HWLOC library statically (Windows+Release only)" OFF )
51
+ option (
52
+ UMF_LINK_HWLOC_STATICALLY
53
+ "Link UMF with HWLOC library statically (supported for Linux, MacOS and Release build on Windows)"
54
+ OFF )
53
55
option (UMF_FORMAT_CODE_STYLE
54
56
"Add clang, cmake, and black -format-check and -format-apply targets"
55
57
OFF )
@@ -98,6 +100,14 @@ else()
98
100
message (FATAL_ERROR "Unknown OS type" )
99
101
endif ()
100
102
103
+ if (NOT DEFINED UMF_HWLOC_REPO )
104
+ set (UMF_HWLOC_REPO "https://github.com/open-mpi/hwloc.git" )
105
+ endif ()
106
+
107
+ if (NOT DEFINED UMF_HWLOC_TAG )
108
+ set (UMF_HWLOC_TAG hwloc-2.10.0 )
109
+ endif ()
110
+
101
111
if (NOT UMF_LINK_HWLOC_STATICALLY )
102
112
if (NOT UMF_DISABLE_HWLOC )
103
113
pkg_check_modules (LIBHWLOC hwloc>=2.3.0 )
@@ -110,18 +120,22 @@ if(NOT UMF_LINK_HWLOC_STATICALLY)
110
120
"${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
111
121
)
112
122
endif ()
113
- else ()
114
- if (NOT WINDOWS )
115
- message (FATAL_ERROR "hwloc can be statically linked only on Windows" )
116
- endif ()
123
+ # add PATH to DLL on Windows
124
+ set (DLL_PATH_LIST
125
+ "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
126
+ )
127
+ elseif (WINDOWS )
117
128
include (FetchContent )
118
129
set (HWLOC_ENABLE_TESTING OFF )
119
130
set (HWLOC_SKIP_LSTOPO ON )
120
131
set (HWLOC_SKIP_TOOLS ON )
132
+
133
+ message (STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO} " )
134
+
121
135
FetchContent_Declare (
122
136
hwloc_targ
123
- GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
124
- GIT_TAG hwloc-2.10.0
137
+ GIT_REPOSITORY ${UMF_HWLOC_REPO}
138
+ GIT_TAG ${UMF_HWLOC_TAG}
125
139
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS )
126
140
127
141
FetchContent_GetProperties (hwloc_targ )
@@ -134,6 +148,57 @@ else()
134
148
set (LIBHWLOC_LIBRARY_DIRS
135
149
${hwloc_targ_BINARY_DIR} /Release;${hwloc_targ_BINARY_DIR}/Debug )
136
150
151
+ message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
152
+ message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
153
+ message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
154
+ else ()
155
+ include (FetchContent )
156
+ message (STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO} " )
157
+
158
+ FetchContent_Declare (
159
+ hwloc_targ
160
+ GIT_REPOSITORY ${UMF_HWLOC_REPO}
161
+ GIT_TAG ${UMF_HWLOC_TAG} )
162
+
163
+ FetchContent_GetProperties (hwloc_targ )
164
+ if (NOT hwloc_targ_POPULATED )
165
+ FetchContent_MakeAvailable (hwloc_targ )
166
+ endif ()
167
+
168
+ add_custom_command (
169
+ COMMAND ./autogen.sh
170
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
171
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /configure )
172
+ add_custom_command (
173
+ COMMAND
174
+ ./configure --prefix=${hwloc_targ_BINARY_DIR} --enable-static=yes
175
+ --enable-shared=no --disable-libxml2 --disable-levelzero
176
+ CFLAGS=-fPIC CXXFLAGS=-fPIC
177
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
178
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /Makefile
179
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /configure )
180
+ add_custom_command (
181
+ COMMAND make
182
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
183
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la
184
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /Makefile )
185
+ add_custom_command (
186
+ COMMAND make install
187
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
188
+ OUTPUT ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a
189
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la )
190
+
191
+ add_custom_target (hwloc_prod
192
+ DEPENDS ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
193
+ add_library (hwloc INTERFACE )
194
+ target_link_libraries (hwloc
195
+ INTERFACE ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
196
+ add_dependencies (hwloc hwloc_prod )
197
+
198
+ set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR} /lib )
199
+ set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
200
+ set (LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
201
+
137
202
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
138
203
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
139
204
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
0 commit comments