1 2# save the folder when this file is included, for use later 3set(THIS_FILE_DIR ${CMAKE_CURRENT_LIST_DIR}) 4 5function(aws_detect_target_platform out_os out_arch) 6 if (CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Android") 7 set(${out_os} "android" PARENT_SCOPE) 8 set(${out_arch} "${ANDROID_ABI}" PARENT_SCOPE) 9 return() 10 endif() 11 try_compile( 12 RESULT_UNUSED 13 ${CMAKE_CURRENT_BINARY_DIR} 14 SOURCES "${THIS_FILE_DIR}/osdetect.c" 15 OUTPUT_VARIABLE OS_OUTPUT 16 ) 17 # Find the error in the output, then strip the identifier off 18 string(REGEX MATCH "OS ([a-zA-Z]+)" OS "${OS_OUTPUT}") 19 string(REPLACE "OS " "" OS "${OS}") 20 21 try_compile( 22 RESULT_UNUSED 23 ${CMAKE_CURRENT_BINARY_DIR} 24 SOURCES "${THIS_FILE_DIR}/archdetect.c" 25 OUTPUT_VARIABLE ARCH_OUTPUT 26 ) 27 28 # Find the error in the output, then strip the identifier off 29 string(REGEX MATCH "ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH_OUTPUT}") 30 string(REPLACE "ARCH " "" ARCH "${ARCH}") 31 32 set(${out_os} "${OS}" PARENT_SCOPE) 33 set(${out_arch} "${ARCH}" PARENT_SCOPE) 34endfunction() 35