I\'ve done a lot of research and been unable to find an answer to this... how can I reliably find the target architecture I\'m compiling for, using CMake? Basically, the equ
I've a Solution for the Case where the Host and Target System are the same.
First you need to call "uname -m" to get the "machine hardware name". Afterwards you need to cut off the trailing "Carriage Return" to get the actual Value back into the provided Variable.
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
Now you can print out the Variable ${ARCHITECTURE}:
message( STATUS "Architecture: ${ARCHITECTURE}" )
or do some Canonisation to map, e.g. "x86_64", "amd64", ... to e.g. "64Bit". Same goes for 32Bit. With this you can execute archtecture dependend Compilation like:
if( ${ARCHITECTURE} STREQUAL "64Bit" )
    set( BLA_LIBRARY "/opt/lib/libBla.so" )
else()
    set( BLA_LIBRARY "/opt/lib32/libBla.so" )
endif()