@@ -103,10 +103,7 @@ if(NOT UMF_LINK_HWLOC_STATICALLY)
103
103
set (DLL_PATH_LIST
104
104
"${DLL_PATH_LIST} ;PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS} /../bin"
105
105
)
106
- else ()
107
- if (NOT WINDOWS )
108
- message (FATAL_ERROR "hwloc can be statically linked only on Windows" )
109
- endif ()
106
+ elseif (WINDOWS )
110
107
include (FetchContent )
111
108
set (HWLOC_ENABLE_TESTING OFF )
112
109
set (HWLOC_SKIP_LSTOPO ON )
@@ -130,6 +127,46 @@ else()
130
127
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
131
128
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
132
129
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
130
+ else ()
131
+ include (FetchContent )
132
+ FetchContent_Declare (
133
+ hwloc_targ
134
+ GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
135
+ GIT_TAG hwloc-2.10.0 )
136
+
137
+ FetchContent_GetProperties (hwloc_targ )
138
+ if (NOT hwloc_targ_POPULATED )
139
+ FetchContent_MakeAvailable (hwloc_targ )
140
+ endif ()
141
+
142
+ add_custom_command (
143
+ COMMAND ./autogen.sh
144
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
145
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /configure )
146
+ add_custom_command (
147
+ COMMAND
148
+ ./configure --prefix=${hwloc_targ_BINARY_DIR} --enable-static=yes
149
+ --enable-shared=no --disable-libxml2 --disable-levelzero
150
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
151
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /Makefile
152
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /configure )
153
+
154
+ add_custom_command (
155
+ COMMAND make
156
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
157
+ OUTPUT ${hwloc_targ_SOURCE_DIR} /libhwloc.la
158
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /Makefile )
159
+ add_custom_command (
160
+ COMMAND make install
161
+ WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
162
+ OUTPUT ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a
163
+ DEPENDS ${hwloc_targ_SOURCE_DIR} /Makefile )
164
+
165
+ add_custom_target (hwloc DEPENDS ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
166
+
167
+ set (LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR} /lib )
168
+ set (LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR} /include )
169
+ set (LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR} /lib/libhwloc.a )
133
170
endif ()
134
171
135
172
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
0 commit comments