Fix -m32 unrecognized issue when compile 32-bit target on some 64-bit systems (#866)
When compile 32-bit targets on some 64-bit systems, the "-m32" flag might be unrecognized by some gcc compilers, e.g. compiling arm32 in aarch64 system, compiling riscv32 in riscv64 system. Add check before adding "-m32" flag to gcc, and only add it if it is supported.
This commit is contained in:
parent
2af5ae5abb
commit
3f808d4596
@ -61,9 +61,13 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
|
||||
endif ()
|
||||
else ()
|
||||
add_definitions (-m32)
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
|
||||
include(CheckCCompilerFlag)
|
||||
Check_C_Compiler_Flag( -m32 M32_OK )
|
||||
if (M32_OK)
|
||||
add_definitions (-m32)
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
Reference in New Issue
Block a user