laurencelundblade / QCBOR

Comprehensive, powerful, commercial-quality CBOR encoder/ decoder that is still suited for small devices.
Other
183 stars 47 forks source link

How to use cmake's disable float options? #175

Closed toge closed 1 year ago

toge commented 1 year ago

In the top-level CMakeLists.txt, it appears to be removing the math lib link only when QCBOR_OPT_DISABLE_FLOAT_HW_USE is True.

    # Using GCC
    target_link_libraries(qcbor
        PRIVATE
            $<$<NOT:$<BOOL:${QCBOR_OPT_DISABLE_FLOAT_HW_USE}>>:m>
    )

Assuming this implementation is ok, would you please tell me the correct usage of disable float in CMake? From reading the README.md, I didn't clearly understand how to use the three options.

laurencelundblade commented 1 year ago

To be honest, I didn't write the cmake float disable stuff, so it will take me a little time to figure it out. But I'm pretty confident that the three possible defines applies to the code work correctly as all of them are tested in every combination on every release (using Make, not cmake).

I don't know what you are trying to achieve (remove of dependency on library, smallest code size, absolute removal of everything floating point in the ABI). Probably QCBOR_DISABLE_FLOAT_HW_USE is all you need.

You don't need to define combinations. Just define QCBOR_DISABLE_FLOAT_HW_USE.

toge commented 1 year ago

@laurencelundblade Thank you for your response. I have confirmed that the three options in CMake change the behavior and code size. It is a great code.

I wanted to achive two goals(those are independent)

To achieve these, would it be adequate to specify just one option each as follows?

laurencelundblade commented 1 year ago

Yes, those two will achieve what you want. You will still be able to encode and decode floating point numbers in a very basic way too.

You can also try USEFULBUF_DISABLE_ALL_FLOAT and see if that makes code even smaller. It probably doesn't, but you could try it. With the defined you cannot do anything with floating point numbers in QCBOR at all.

toge commented 1 year ago

@laurencelundblade Now I understand. Thanks a lot!