1 function(TARGET_SUPPORTS_RELOCATABLE)
3 set(CMAKETMP ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${RANDOM})
4 get_cmake_property(ENABLED_LANGUAGES ENABLED_LANGUAGES)
5 foreach(LANG C ${ENABLED_LANGUAGES})
6 if(CMAKE_${LANG}_COMPILER)
7 set(CMAKE_COMPILER ${CMAKE_${LANG}_COMPILER})
11 if(NOT CMAKE_COMPILER)
14 file(WRITE ${CMAKETMP}/${RANDOM}.c "")
15 execute_process(COMMAND ${CMAKE_COMPILER} -nostdlib -o ${RANDOM}.o -r ${RANDOM}.c
16 WORKING_DIRECTORY ${CMAKETMP} ERROR_QUIET OUTPUT_QUIET RESULT_VARIABLE result
19 set(TARGET_SUPPORTS_RELOCATABLE 1 CACHE INTERNAL "Test TARGET_SUPPORTS_RELOCATABLE")
21 set(TARGET_SUPPORTS_RELOCATABLE 0 CACHE INTERNAL "Test TARGET_SUPPORTS_RELOCATABLE")
23 file(REMOVE_RECURSE ${CMAKETMP})
25 if(NOT DEFINED TARGET_SUPPORTS_RELOCATABLE)
26 TARGET_SUPPORTS_RELOCATABLE()