33# Copyright(c) 2025 John Sanpe <sanpeqf@gmail.com>
44#
55
6- if (HOST_C_COMPILER)
7- set (PRINT_TYPE_LINK "-static" )
8- endif ()
9-
10- macro (print_type output name )
11- message (STATUS "Print type: " ${name} )
12- try_run (
13- RUN_RESULT
14- COMPILE_RESULT
15- ${CMAKE_CURRENT_BINARY_DIR}
16- ${CMAKE_CURRENT_LIST_DIR} /get-type.c
17- COMPILE_DEFINITIONS "-Werror -DTYPE=${name} "
18- LINK_OPTIONS "${PRINT_TYPE_LINK} "
19- RUN_OUTPUT_VARIABLE ${output}
20- COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
21- )
22- if ((NOT COMPILE_RESULT) OR (NOT RUN_RESULT EQUAL 0))
23- message ("Compile output: ${COMPILE_OUTPUT} " )
24- message ("Run result: ${RUN_RESULT} " )
25- message (FATAL_ERROR "Failed to retrieve the original type ${name} " )
26- endif ()
27- endmacro ()
28-
296if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|Darwin|GNU" )
307 set (BFDEV_PORT_TYPE "posix" )
318endif ()
@@ -42,20 +19,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Generic")
4219 set (BFDEV_PORT_TYPE "generic" )
4320endif ()
4421
45- if (BFDEV_PORT_TYPE STREQUAL "posix" )
46- print_type (BFDEV_TYPE_ADDR "size_t" )
47- print_type (BFDEV_TYPE_W64 "int64_t" )
48- print_type (BFDEV_TYPE_MAX "intmax_t" )
49- endif ()
50-
51- if (NOT BFDEV_TYPE_ADDR)
52- set (BFDEV_TYPE_ADDR "long" )
53- endif ()
54-
55- if (NOT BFDEV_TYPE_W64)
56- set (BFDEV_TYPE_W64 "long long" )
57- endif ()
58-
59- if (NOT BFDEV_TYPE_MAX)
60- set (BFDEV_TYPE_MAX "long long" )
61- endif ()
22+ include (${CMAKE_CURRENT_LIST_DIR} /get-type.cmake )
23+ get_type (BFDEV_TYPE_ADDR "size_t" "long" )
24+ get_type (BFDEV_TYPE_W64 "int64_t" "long long" )
25+ get_type (BFDEV_TYPE_MAX "intmax_t" "long long" )
0 commit comments