File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -296,9 +296,17 @@ if(CMAKE_COMPILER_IS_GNUCXX)
296
296
# Don't use -rpath.
297
297
set (CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE )
298
298
299
- set (CMAKE_C_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_C_FLAGS} " )
300
- set (CMAKE_CXX_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_CXX_FLAGS} " )
301
- set (CMAKE_Fortran_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_Fortran_FLAGS} " )
299
+ # Need to determine the target machine of the C compiler, because
300
+ # the '-m32' and '-m64' flags are supported on x86 but not on e.g. ARM.
301
+ exec_program ( "${CMAKE_C_COMPILER} -dumpmachine"
302
+ OUTPUT_VARIABLE CMAKE_C_COMPILER_MACHINE )
303
+ message ( STATUS "CMAKE_C_COMPILER_MACHINE: ${CMAKE_C_COMPILER_MACHINE} " )
304
+ # The "86" regular expression matches x86, x86_64, i686, etc.
305
+ if (${CMAKE_C_COMPILER_MACHINE} MATCHES "86" )
306
+ set (CMAKE_C_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_C_FLAGS} " )
307
+ set (CMAKE_CXX_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_CXX_FLAGS} " )
308
+ set (CMAKE_Fortran_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_Fortran_FLAGS} " )
309
+ endif ()
302
310
303
311
if (TARGET_PLATFORM EQUAL 32 )
304
312
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin" )
You can’t perform that action at this time.
0 commit comments