You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CMakeLists.txt
+30
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,36 @@ if(MSVC AND MSVC_STATIC_CRT)
87
87
endforeach()
88
88
endif()
89
89
90
+
# Set default optimization level
91
+
if (NOTMSVC)
92
+
# Filter out cmake's default optimization level from release and debug flags.
93
+
# They would override any optimization level set in COMMON_OPTs
94
+
set(CompilerLangs
95
+
CXX
96
+
C
97
+
Fortran
98
+
ASM
99
+
)
100
+
foreach(CompilerLang ${CompilerLangs})
101
+
string(REGEX REPLACE "-O[0-9]|-Ofast|-Og|-Os"
102
+
"" CMAKE_${CompilerLang}_FLAGS_RELEASE
103
+
"${CMAKE_${CompilerLang}_FLAGS_RELEASE}")
104
+
string(REGEX REPLACE "-O[0-9]|-Ofast|-Og|-Os"
105
+
"" CMAKE_${CompilerLang}_FLAGS_DEDUG
106
+
"${CMAKE_${CompilerLang}_FLAGS_DEDUG}")
107
+
endforeach()
108
+
# Prepend default optimization level to COMMON_OPTs
109
+
if (CMAKE_BUILD_TYPEEQUAL"DEBUG")
110
+
set(COMMON_OPT "-Og ${COMMON_OPT}")
111
+
set(CCOMMON_OPT "-Og ${CCOMMON_OPT}")
112
+
set(FCOMMON_OPT "-Og ${FCOMMON_OPT}")
113
+
else ()
114
+
set(COMMON_OPT "-O2 ${COMMON_OPT}")
115
+
set(CCOMMON_OPT "-O2 ${CCOMMON_OPT}")
116
+
set(FCOMMON_OPT "-O2 ${FCOMMON_OPT}")
117
+
endif ()
118
+
endif ()
119
+
90
120
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.")
0 commit comments