Skip to content

Commit 210b03b

Browse files
authored
Merge pull request #1792 from martin-frbg/cmakesuffix
Improve CMake help output and add SYMBOLPREFIX and -SUFFIX options
2 parents c0d7cd3 + 41951da commit 210b03b

File tree

1 file changed

+78
-6
lines changed

1 file changed

+78
-6
lines changed

CMakeLists.txt

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ include(CMakePackageConfigHelpers)
1717

1818
#######
1919
if(MSVC)
20-
option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON)
20+
option(BUILD_WITHOUT_LAPACK "Do not build LAPACK and LAPACKE (Only BLAS or CBLAS)" ON)
2121
endif()
22-
option(BUILD_WITHOUT_CBLAS "Without CBLAS" OFF)
23-
option(DYNAMIC_ARCH "Build with DYNAMIC_ARCH" OFF)
24-
option(DYNAMIC_OLDER "Support older cpus with DYNAMIC_ARCH" OFF)
25-
option(BUILD_RELAPACK "Build with ReLAPACK (recursive LAPACK" OFF)
22+
option(BUILD_WITHOUT_CBLAS "Do not build the C interface (CBLAS) to the BLAS functions" OFF)
23+
option(DYNAMIC_ARCH "Include support for multiple CPU targets, with automatic selection at runtime (x86/x86_64 only)" OFF)
24+
option(DYNAMIC_OLDER "Include specific support for older cpu models (Penryn,Dunnington,Atom,Nano,Opteron) with DYNAMIC_ARCH" OFF)
25+
option(BUILD_RELAPACK "Build with ReLAPACK (recursive implementation of several LAPACK functions on top of standard LAPACK)" OFF)
26+
27+
# Add a prefix or suffix to all exported symbol names in the shared library.
28+
# Avoids conflicts with other BLAS libraries, especially when using
29+
# 64 bit integer interfaces in OpenBLAS.
30+
31+
set(SYMBOLPREFIX "" CACHE STRING "Add a prefix to all exported symbol names in the shared library to avoid conflicts with other BLAS libraries" )
32+
set(SYMBOLSUFFIX "" CACHE STRING "Add a suffix to all exported symbol names in the shared library, e.g. _64 for INTERFACE64 builds" )
2633
#######
2734
if(BUILD_WITHOUT_LAPACK)
2835
set(NO_LAPACK 1)
@@ -36,7 +43,7 @@ endif()
3643
#######
3744

3845

39-
message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.")
46+
message(WARNING "CMake support is experimental. It does not yet support all build options and may not produce the same Makefiles that OpenBLAS ships with.")
4047

4148
include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake")
4249
include("${PROJECT_SOURCE_DIR}/cmake/system.cmake")
@@ -210,6 +217,71 @@ set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
210217
SOVERSION ${OpenBLAS_MAJOR_VERSION}
211218
)
212219

220+
if (BUILD_SHARED_LIBS AND NOT ${SYMBOLPREFIX}${SYMBOLSUFIX} STREQUAL "")
221+
if (NOT DEFINED ARCH)
222+
set(ARCH_IN "x86_64")
223+
else()
224+
set(ARCH_IN ${ARCH})
225+
endif()
226+
227+
if (${CORE} STREQUAL "generic")
228+
set(ARCH_IN "GENERIC")
229+
endif ()
230+
231+
if (NOT DEFINED EXPRECISION)
232+
set(EXPRECISION_IN 0)
233+
else()
234+
set(EXPRECISION_IN ${EXPRECISION})
235+
endif()
236+
237+
if (NOT DEFINED NO_CBLAS)
238+
set(NO_CBLAS_IN 0)
239+
else()
240+
set(NO_CBLAS_IN ${NO_CBLAS})
241+
endif()
242+
243+
if (NOT DEFINED NO_LAPACK)
244+
set(NO_LAPACK_IN 0)
245+
else()
246+
set(NO_LAPACK_IN ${NO_LAPACK})
247+
endif()
248+
249+
if (NOT DEFINED NO_LAPACKE)
250+
set(NO_LAPACKE_IN 0)
251+
else()
252+
set(NO_LAPACKE_IN ${NO_LAPACKE})
253+
endif()
254+
255+
if (NOT DEFINED NEED2UNDERSCORES)
256+
set(NEED2UNDERSCORES_IN 0)
257+
else()
258+
set(NEED2UNDERSCORES_IN ${NEED2UNDERSCORES})
259+
endif()
260+
261+
if (NOT DEFINED ONLY_CBLAS)
262+
set(ONLY_CBLAS_IN 0)
263+
else()
264+
set(ONLY_CBLAS_IN ${ONLY_CBLAS})
265+
endif()
266+
267+
if (NOT DEFINED BU)
268+
set(BU _)
269+
endif()
270+
271+
if (NOT ${SYMBOLPREFIX} STREQUAL "")
272+
message(STATUS "adding prefix ${SYMBOLPREFIX} to names of exported symbols in ${OpenBLAS_LIBNAME}")
273+
endif()
274+
if (NOT ${SYMBOLSUFFIX} STREQUAL "")
275+
message(STATUS "adding suffix ${SYMBOLSUFFIX} to names of exported symbols in ${OpenBLAS_LIBNAME}")
276+
endif()
277+
add_custom_command(TARGET ${OpenBLAS_LIBNAME} POST_BUILD
278+
COMMAND perl ${PROJECT_SOURCE_DIR}/exports/gensymbol "objcopy" "${ARCH}" "${BU}" "${EXPRECISION_IN}" "${NO_CBLAS_IN}" "${NO_LAPACK_IN}" "${NO_LAPACKE_IN}" "${NEED2UNDERSCORES_IN}" "${ONLY_CBLAS_IN}" \"${SYMBOLPREFIX}\" \"${SYMBOLSUFFIX}\" "${BUILD_LAPACK_DEPRECATED}" > ${PROJECT_BINARY_DIR}/objcopy.def
279+
COMMAND objcopy -v --redefine-syms ${PROJECT_BINARY_DIR}/objcopy.def ${PROJECT_BINARY_DIR}/lib/lib${OpenBLAS_LIBNAME}.so
280+
COMMENT "renaming symbols"
281+
)
282+
endif()
283+
284+
213285
# Install project
214286
215287
# Install libraries

0 commit comments

Comments
 (0)