Skip to content

Commit a1b87ea

Browse files
committed
Do not require Perl for MSVC if CMake >= 3.4
1 parent 47ebce4 commit a1b87ea

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ endif ()
119119

120120
# Only generate .def for dll on MSVC and always produce pdb files for debug and release
121121
if(MSVC)
122-
set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def")
123-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
124-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
122+
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.4)
123+
set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def")
124+
endif()
125+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
126+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
125127
endif()
126128

127129
if (${DYNAMIC_ARCH})
@@ -141,7 +143,15 @@ endif()
141143
# add objects to the openblas lib
142144
add_library(${OpenBLAS_LIBNAME} ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE})
143145

144-
include("${PROJECT_SOURCE_DIR}/cmake/export.cmake")
146+
# Handle MSVC exports
147+
if(MSVC AND BUILD_SHARED_LIBS)
148+
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.4)
149+
include("${PROJECT_SOURCE_DIR}/cmake/export.cmake")
150+
else()
151+
# Creates verbose .def file (51KB vs 18KB)
152+
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true)
153+
endif()
154+
endif()
145155

146156
# Set output for libopenblas
147157
set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
@@ -164,7 +174,6 @@ if (USE_THREAD)
164174
set_property(TARGET ${OpenBLAS_LIBNAME} PROPERTY COMPILE_OPTIONS "-pthread")
165175
set_property(TARGET ${OpenBLAS_LIBNAME} PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
166176
endif()
167-
message("PTHREAD: ${CMAKE_THREAD_LIBS_INIT}")
168177
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
169178
endif()
170179

0 commit comments

Comments
 (0)