@@ -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 )
@@ -110,10 +112,11 @@ if(NOT UMF_LINK_HWLOC_STATICALLY)
110
112
"${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
111
113
)
112
114
endif ()
113
- else ()
114
- if (NOT WINDOWS )
115
- message (FATAL_ERROR "hwloc can be statically linked only on Windows" )
116
- endif ()
115
+ # add PATH to DLL on Windows
116
+ set (DLL_PATH_LIST
117
+ "${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
118
+ )
119
+ elseif (WINDOWS )
117
120
include (FetchContent )
118
121
set (HWLOC_ENABLE_TESTING OFF )
119
122
set (HWLOC_SKIP_LSTOPO ON )
@@ -134,6 +137,55 @@ else()
134
137
set (LIBHWLOC_LIBRARY_DIRS
135
138
${hwloc_targ_BINARY_DIR} /Release;${hwloc_targ_BINARY_DIR}/Debug )
136
139
140
+ message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
141
+ message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
142
+ message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
143
+ else ()
144
+ include (FetchContent )
145
+ FetchContent_Declare (
146
+ hwloc_targ
147
+ GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
148
+ GIT_TAG hwloc-2.10.0 )
149
+
150
+ FetchContent_GetProperties (hwloc_targ )
151
+ if (NOT hwloc_targ_POPULATED )
152
+ FetchContent_MakeAvailable (hwloc_targ )
153
+ endif ()
154
+
155
+ add_custom_command (
156
+ COMMAND ./autogen.sh
157
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
158
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /configure )
159
+ add_custom_command (
160
+ COMMAND
161
+ ./configure --prefix=${hwloc_targ_BINARY_DIR} --enable-static=yes
162
+ --enable-shared=no --disable-libxml2 --disable-levelzero
163
+ CFLAGS=-fPIC CXXFLAGS=-fPIC
164
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
165
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /Makefile
166
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /configure )
167
+ add_custom_command (
168
+ COMMAND make
169
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
170
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la
171
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /Makefile )
172
+ add_custom_command (
173
+ COMMAND make install
174
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
175
+ OUTPUT ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a
176
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /lib/libhwloc.la )
177
+
178
+ add_custom_target (hwloc_prod
179
+ DEPENDS ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
180
+ add_library (hwloc INTERFACE )
181
+ target_link_libraries (hwloc
182
+ INTERFACE ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
183
+ add_dependencies (hwloc hwloc_prod )
184
+
185
+ set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR} /lib )
186
+ set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
187
+ set (LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
188
+
137
189
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
138
190
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
139
191
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
0 commit comments