Skip to content

Commit f69a0be

Browse files
authored
Add getarch flags to disable AVX on x86
(and other small fixes to match Makefile behaviour)
1 parent ae9e8b1 commit f69a0be

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

cmake/system.cmake

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ if (X86_64)
7070
set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native")
7171
endif ()
7272

73+
# On x86 no AVX support is available
74+
if (X86 OR X86_64)
75+
if ((DEFINED BINARY AND BINARY EQUAL 32) OR ("$CMAKE_SIZEOF_VOID_P}" EQUAL "4"))
76+
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX -DNO_AVX2 -DNO_AVX512")
77+
endif ()
78+
endif ()
79+
7380
if (INTERFACE64)
7481
message(STATUS "Using 64-bit integers.")
7582
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DUSE64BITINT")
@@ -148,7 +155,9 @@ else()
148155
endif ()
149156

150157
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
151-
158+
if (DEFINED BINARY)
159+
message(STATUS "Compiling a ${BINARY}-bit binary.")
160+
endif ()
152161
if (NOT DEFINED NEED_PIC)
153162
set(NEED_PIC 1)
154163
endif ()
@@ -165,6 +174,9 @@ include("${PROJECT_SOURCE_DIR}/cmake/cc.cmake")
165174
if (NOT NOFORTRAN)
166175
# Fortran Compiler dependent settings
167176
include("${PROJECT_SOURCE_DIR}/cmake/fc.cmake")
177+
else ()
178+
set(NO_LAPACK 1)
179+
set(NO_LAPACKE 1)
168180
endif ()
169181

170182
if (BINARY64)
@@ -190,9 +202,14 @@ if (NEED_PIC)
190202
endif ()
191203

192204
if (DYNAMIC_ARCH)
193-
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
194-
if (DYNAMIC_OLDER)
195-
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")
205+
if (X86 OR X86_64 OR ARM64 OR PPC)
206+
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
207+
if (DYNAMIC_OLDER)
208+
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")
209+
endif ()
210+
else ()
211+
unset (DYNAMIC_ARCH)
212+
message (STATUS "DYNAMIC_ARCH is not supported on the target architecture, removing")
196213
endif ()
197214
endif ()
198215

0 commit comments

Comments
 (0)