Skip to content

Commit c93822c

Browse files
authored
Merge pull request #6266 from mattip/win-cmake
tweak cmake for clang-cl
2 parents 94e4d2f + 9c3c277 commit c93822c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ set (PDBOPT "")
605605
endif()
606606
#if (USE_PERL)
607607
message(STATUS "adding postbuild instruction to rename syms")
608+
# VERBATIM quotes every COMMAND argument, so CMAKE_C_FLAGS has to be turned
609+
# into a list first: as a single string it is passed to the compiler as one
610+
# argument, and none of the flags or defines in it take effect.
611+
separate_arguments(DLLINIT_C_FLAGS NATIVE_COMMAND "${CMAKE_C_FLAGS}")
608612
add_custom_command(TARGET ${OpenBLAS_LIBNAME}_static POST_BUILD
609613
COMMAND perl ${PROJECT_SOURCE_DIR}/exports/gensymbol.pl "win2k" "${ARCH}" "${BU}" "${EXPRECISION_IN}" "${NO_CBLAS_IN}" "${NO_LAPACK_IN}" "${NO_LAPACKE_IN}" "${NEED2UNDERSCORES_IN}" "${ONLY_CBLAS_IN}" "${SYMBOLPREFIX}" "${SYMBOLSUFFIX}" "${BLD}" "${BBF16}" "${BHF16}" "${BS}" "${BD}" "${BC}" "${BZ}" > ${PROJECT_BINARY_DIR}/renamesyms.def
610614
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR} -c -o ${PROJECT_BINARY_DIR}/dllinit.o ${PROJECT_SOURCE_DIR}/exports/dllinit.c

‎cmake/cc.cmake‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ if (${CMAKE_C_COMPILER_ID} MATCHES "IntelLLVM")
3737
endif ()
3838

3939
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "LSB" OR ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
40-
set(CCOMMON_OPT "${CCOMMON_OPT} -Wall")
40+
if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
41+
# clang-cl parses -Wall as the MSVC /Wall, which is -Weverything, so the
42+
# gcc-style -Wall meant here has to be spelled /W3 (clang-cl's alias for
43+
# it). Plain -Wall yields tens of thousands of warnings.
44+
set(CCOMMON_OPT "${CCOMMON_OPT} /W3")
45+
else ()
46+
set(CCOMMON_OPT "${CCOMMON_OPT} -Wall")
47+
endif ()
4148
set(COMMON_PROF "${COMMON_PROF} -fno-inline")
4249
set(NO_UNINITIALIZED_WARN "-Wno-uninitialized")
4350
set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION})

0 commit comments

Comments
 (0)