TestBigEndian: Performance

TestBigEndian has performance problems.

TestBigEndian re-does a lot of work for no good reason.

If you have multiple projects checking for Endianness this can add up and eat at the configuration time.

The main reason that time is taken up is because of how the macro is written:

    message(STATUS "Check if the system is big endian")
    message(STATUS "Searching 16 bit integer")

If I have 3 different targets and they all call this macro, then a bunch of work is redone because they are different variables.

Ideally the result could be stored in a global property. Calculate it once, then cache the result in a global property.

Also an include_guard wouldn’t hurt.

Why not use a single variable for each of the detections? If you need separate variables afterwards, set the wanted name based on the common detection name.

I would guess they are independent projects that are brought in via FetchContent or other means that cause upstream changes to be hard to manage.

Some top-level coordination to set the second and third based on the first would also be a solution in this case.