@@ -42,6 +42,19 @@ endif()
42
42
43
43
#######
44
44
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 ()
45
58
46
59
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." )
47
60
@@ -134,7 +147,7 @@ endif ()
134
147
135
148
# Only generate .def for dll on MSVC and always produce pdb files for debug and release
136
149
if (MSVC )
137
- if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} LESS 3.4 )
150
+ if (${CMAKE_MAJOR_VERSION} .${CMAKE_MINOR_VERSION} VERSION_LESS 3.4 )
138
151
set (OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR} /openblas.def" )
139
152
endif ()
140
153
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi" )
@@ -149,12 +162,6 @@ if (${DYNAMIC_ARCH})
149
162
endforeach ()
150
163
endif ()
151
164
152
- # Only build shared libs for MSVC
153
- if (MSVC )
154
- set (BUILD_SHARED_LIBS ON )
155
- endif ()
156
-
157
-
158
165
# add objects to the openblas lib
159
166
add_library (${OpenBLAS_LIBNAME} ${LA_SOURCES} ${LAPACKE_SOURCES} ${RELA_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE} )
160
167
target_include_directories (${OpenBLAS_LIBNAME} INTERFACE $< INSTALL_INTERFACE:include> )
@@ -166,7 +173,7 @@ endif()
166
173
167
174
# Handle MSVC exports
168
175
if (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 )
170
177
include ("${PROJECT_SOURCE_DIR} /cmake/export.cmake" )
171
178
else ()
172
179
# Creates verbose .def file (51KB vs 18KB)
@@ -314,7 +321,7 @@ install (FILES ${OPENBLAS_CONFIG_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
314
321
if (NOT NOFORTRAN )
315
322
message (STATUS "Generating f77blas.h in ${CMAKE_INSTALL_INCLUDEDIR} " )
316
323
317
- set (F77BLAS_H ${CMAKE_BINARY_DIR} /f77blas.h )
324
+ set (F77BLAS_H ${CMAKE_BINARY_DIR} /generated/ f77blas.h )
318
325
file (WRITE ${F77BLAS_H} "#ifndef OPENBLAS_F77BLAS_H\n " )
319
326
file (APPEND ${F77BLAS_H} "#define OPENBLAS_F77BLAS_H\n " )
320
327
file (APPEND ${F77BLAS_H} "#include \" openblas_config.h\"\n " )
@@ -327,10 +334,11 @@ endif()
327
334
if (NOT NO_CBLAS )
328
335
message (STATUS "Generating cblas.h in ${CMAKE_INSTALL_INCLUDEDIR} " )
329
336
337
+ set (CBLAS_H ${CMAKE_BINARY_DIR} /generated/cblas.h )
330
338
file (READ ${CMAKE_CURRENT_SOURCE_DIR} /cblas.h CBLAS_H_CONTENTS )
331
339
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 )
340
+ file (WRITE ${CBLAS_H} "${CBLAS_H_CONTENTS_NEW} " )
341
+ install (FILES ${CBLAS_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
334
342
endif ()
335
343
336
344
if (NOT NO_LAPACKE )
0 commit comments