]> www.ginac.de Git - cln.git/blob - cmake/modules/AsmUnderscore.cmake
CLN can be built with CMake
[cln.git] / cmake / modules / AsmUnderscore.cmake
1 # Check if symbols are prefixed by an underscore in assembly language.
2 set(ASM_UNDERSCORE)
3
4 set(_conftest_c ${CMAKE_BINARY_DIR}/conftest.c)
5 set(_conftest_s ${CMAKE_BINARY_DIR}/conftest.s)
6 set(_cc_ret)
7
8 file(WRITE ${_conftest_c} "int foo() { return 0; }")
9
10 # CC='ccache gcc' => "${CMAKE_C_COMPILER_ARG1}" == " gcc"
11 # (notice the leading whitespace). Grrr!
12 string(STRIP "${CMAKE_C_COMPILER_ARG1}" _c_compiler_arg1)
13 execute_process(
14         COMMAND ${CMAKE_C_COMPILER} ${_c_compiler_arg1} -S ${_conftest_c}
15         RESULT_VARIABLE _cc_ret
16 )
17 if ("${_cc_ret}" EQUAL "0")
18         file(STRINGS ${_conftest_s} _asm_underscore REGEX "_foo")
19         if (_asm_underscore)
20                 set(ASM_UNDERSCORE true)
21         endif()
22 endif()
23 file(REMOVE ${_conftest_s} ${_conftest_c})
24