Saturday, November 13, 2021

[SOLVED] CMake: check for standard library file using CheckIncludeFileCXX

Issue

I am trying to figure out if the current compiler supports std::format, however the following code is populating the variable CXX_FORMAT_SUPPORT with nothing. I assume I may need to add an include path, but I'm not sure how to get that for the compiler if that is the case.

# check std::format support
include(CheckIncludeFileCXX)
check_include_file_cxx("format" CXX_FORMAT_SUPPORT)
message(STATUS "CXX_FORMAT_SUPPORT: ${CXX_FORMAT_SUPPORT}")

How can I correctly populate CXX_FORMAT_SUPPORT?


Solution

The documentation is less than clear but check_include_file_cxx sets the output variable to 1 if the header is found and doesn't set the variable if it is not found.



Answered By - Alan Birtles