Skip to content

Commit 615727d

Browse files
committed
Added option to enable flat namespace on macOS.
1 parent e7afed3 commit 615727d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL Compaq)
207207
endif()
208208
endif()
209209

210+
# Add option to enable flat namespace for symbol resolution on macOS
211+
if(APPLE)
212+
option(USE_FLAT_NAMESPACE "Use flat namespaces for symbol resolution during build and runtime." OFF)
213+
214+
if(USE_FLAT_NAMESPACE)
215+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-flat_namespace")
216+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace")
217+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-flat_namespace")
218+
else()
219+
if(BUILD_SHARED_LIBS AND BUILD_TESTING)
220+
message(WARNING
221+
"LAPACK test suite might fail with shared libraries and the default two-level namespace. "
222+
"Disable shared libraries or enable flat namespace for symbol resolution via -DUSE_FLAT_NAMESPACE=ON.")
223+
endif()
224+
endif()
225+
endif()
210226

211227
# --------------------------------------------------
212228
set(LAPACK_INSTALL_EXPORT_NAME ${LAPACKLIB}-targets)

0 commit comments

Comments
 (0)