1if (NOT TARGET pico_int64_ops)
2
3    #shims for ROM functions for -lgcc functions  (listed below)
4    pico_add_library(pico_int64_ops)
5
6    # no custom implementation; falls thru to compiler
7    pico_add_library(pico_int64_ops_compiler)
8
9    # add alias "default" which is just pico.
10    add_library(pico_int64_ops_default INTERFACE)
11    if (PICO_RP2040)
12        target_link_libraries(pico_int64_ops_default INTERFACE pico_int64_ops_pico)
13    else()
14        target_link_libraries(pico_int64_ops_default INTERFACE pico_int64_ops_compiler)
15    endif()
16
17    set(PICO_DEFAULT_INT64_OPS_IMPL pico_int64_ops_default)
18
19    target_link_libraries(pico_int64_ops INTERFACE
20            $<IF:$<BOOL:$<TARGET_PROPERTY:PICO_TARGET_INT64_OPS_IMPL>>,$<TARGET_PROPERTY:PICO_TARGET_INT64_OPS_IMPL>,${PICO_DEFAULT_INT64_OPS_IMPL}>)
21
22    pico_add_library(pico_int64_ops_pico)
23    target_include_directories(pico_int64_ops_pico SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
24    pico_mirrored_target_link_libraries(pico_int64_ops_pico INTERFACE pico_base)
25
26    target_sources(pico_int64_ops_pico INTERFACE
27            ${CMAKE_CURRENT_LIST_DIR}/pico_int64_ops_aeabi.S
28    )
29
30    pico_wrap_function(pico_int64_ops_pico __aeabi_lmul)
31
32    macro(pico_set_int64_ops_implementation TARGET IMPL)
33        get_target_property(target_type ${TARGET} TYPE)
34        if ("EXECUTABLE" STREQUAL "${target_type}")
35            set_target_properties(${TARGET} PROPERTIES PICO_TARGET_INT64_OPS_IMPL "pico_int64_ops_${IMPL}")
36        else()
37            message(FATAL_ERROR "int64_ops implementation must be set on executable not library")
38        endif()
39    endmacro()
40endif()