The proper way of forcing a 32-bit compile using CMake

If you want to compile and link for 32 bit using cmake use this for creating libraries and binaries:

Creating libraries:

add_library(mylib SHARED my_source.c)
set_target_properties(mylib PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")

creating executables:

add_executable(mybin sources.c)
set_target_properties(mybin PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")

Leave a Comment