@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.8.5)
66project (OpenBLAS C ASM)
77set (OpenBLAS_MAJOR_VERSION 0)
88set (OpenBLAS_MINOR_VERSION 3)
9- set (OpenBLAS_PATCH_VERSION 5 )
9+ set (OpenBLAS_PATCH_VERSION 6 )
1010set (OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION} .${OpenBLAS_MINOR_VERSION} .${OpenBLAS_PATCH_VERSION} " )
1111
1212# Adhere to GNU filesystem layout conventions
@@ -42,6 +42,19 @@ endif()
4242
4343#######
4444
45+ if (MSVC AND MSVC_STATIC_CRT)
46+ set (CompilerFlags
47+ CMAKE_CXX_FLAGS
48+ CMAKE_CXX_FLAGS_DEBUG
49+ CMAKE_CXX_FLAGS_RELEASE
50+ CMAKE_C_FLAGS
51+ CMAKE_C_FLAGS_DEBUG
52+ CMAKE_C_FLAGS_RELEASE
53+ )
54+ foreach (CompilerFlag ${CompilerFlags} )
55+ string (REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag} }" )
56+ endforeach ()
57+ endif ()
4558
4659message (WARNING "CMake support is experimental. It does not yet support all build options and may not produce the same Makefiles that OpenBLAS ships with." )
4760
@@ -62,10 +75,10 @@ endif ()
6275
6376set (SUBDIRS ${BLASDIRS} )
6477if (NOT NO_LAPACK)
65- list (APPEND SUBDIRS lapack)
6678 if (BUILD_RELAPACK)
6779 list (APPEND SUBDIRS relapack/src)
6880 endif ()
81+ list (APPEND SUBDIRS lapack)
6982endif ()
7083
7184# set which float types we want to build for
@@ -134,7 +147,7 @@ endif ()
134147
135148# Only generate .def for dll on MSVC and always produce pdb files for debug and release
136149if (MSVC )
137- if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} LESS 3.4)
150+ if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)
138151 set (OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR} /openblas.def" )
139152 endif ()
140153 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi" )
@@ -149,15 +162,9 @@ if (${DYNAMIC_ARCH})
149162 endforeach ()
150163endif ()
151164
152- # Only build shared libs for MSVC
153- if (MSVC )
154- set (BUILD_SHARED_LIBS ON )
155- endif ()
156-
157-
158165# add objects to the openblas lib
159166add_library (${OpenBLAS_LIBNAME} ${LA_SOURCES} ${LAPACKE_SOURCES} ${RELA_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE} )
160- target_include_directories (${OpenBLAS_LIBNAME} INTERFACE $<INSTALL_INTERFACE:include >)
167+ target_include_directories (${OpenBLAS_LIBNAME} INTERFACE $<INSTALL_INTERFACE:include /openblas ${SUFFIX64} >)
161168
162169# Android needs to explicitly link against libm
163170if (ANDROID)
@@ -166,7 +173,7 @@ endif()
166173
167174# Handle MSVC exports
168175if (MSVC AND BUILD_SHARED_LIBS )
169- if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} LESS 3.4)
176+ if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)
170177 include ("${PROJECT_SOURCE_DIR} /cmake/export.cmake" )
171178 else ()
172179 # Creates verbose .def file (51KB vs 18KB)
@@ -217,6 +224,14 @@ set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
217224 SOVERSION ${OpenBLAS_MAJOR_VERSION}
218225)
219226
227+ if (BUILD_SHARED_LIBS AND BUILD_RELAPACK)
228+ if (NOT MSVC )
229+ target_link_libraries (${OpenBLAS_LIBNAME} "-Wl,-allow-multiple-definition" )
230+ else ()
231+ target_link_libraries (${OpenBLAS_LIBNAME} "/FORCE:MULTIPLE" )
232+ endif ()
233+ endif ()
234+
220235if (BUILD_SHARED_LIBS AND NOT ${SYMBOLPREFIX}${SYMBOLSUFIX} STREQUAL "" )
221236if (NOT DEFINED ARCH)
222237 set (ARCH_IN "x86_64" )
@@ -314,7 +329,7 @@ install (FILES ${OPENBLAS_CONFIG_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
314329if (NOT NOFORTRAN)
315330 message (STATUS "Generating f77blas.h in ${CMAKE_INSTALL_INCLUDEDIR} " )
316331
317- set (F77BLAS_H ${CMAKE_BINARY_DIR} /f77blas.h)
332+ set (F77BLAS_H ${CMAKE_BINARY_DIR} /generated / f77blas.h)
318333 file (WRITE ${F77BLAS_H} "#ifndef OPENBLAS_F77BLAS_H\n " )
319334 file (APPEND ${F77BLAS_H} "#define OPENBLAS_F77BLAS_H\n " )
320335 file (APPEND ${F77BLAS_H} "#include \" openblas_config.h\"\n " )
@@ -327,10 +342,11 @@ endif()
327342if (NOT NO_CBLAS)
328343 message (STATUS "Generating cblas.h in ${CMAKE_INSTALL_INCLUDEDIR} " )
329344
345+ set (CBLAS_H ${CMAKE_BINARY_DIR} /generated /cblas.h)
330346 file (READ ${CMAKE_CURRENT_SOURCE_DIR} /cblas.h CBLAS_H_CONTENTS)
331347 string (REPLACE "common" "openblas_config" CBLAS_H_CONTENTS_NEW "${CBLAS_H_CONTENTS} " )
332- file (WRITE ${CMAKE_BINARY_DIR} /cblas.tmp "${CBLAS_H_CONTENTS_NEW} " )
333- install (FILES ${CMAKE_BINARY_DIR} /cblas.tmp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} RENAME cblas.h )
348+ file (WRITE ${CBLAS_H} "${CBLAS_H_CONTENTS_NEW} " )
349+ install (FILES ${CBLAS_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
334350endif ()
335351
336352if (NOT NO_LAPACKE)
0 commit comments