CMake compiler feature detect

For nearly all CMake projects we choose to detect compiler features rather than make brittle, difficult to maintain nested if/elseif based on compiler vendor and version. There are still cases where if statements to work around known compiler bugs are necessary, but where we can, we use compiler feature checks instead.

An example of this is in our project demoing C11 features. The template is done is two steps

Feature checking

Suppose a project requires C11 variable length arrays. The CMakeLists.txt would look like:

include(CheckCSourceCompiles)

set(CMAKE_C_STANDARD 11)  # so that check_c_source_compiles works

check_c_source_compiles("int main(void){for (int i = 1; i < 5; i++){int a[i];} return 0;}" c11vla)

if(NOT c11vla)
 # fatal error or disable feature using C11 VLA
endif()

add_executable(c11demo demo.c)
target_compile_features(c11demo PRIVATE c_std_11)  # best practice to set per target